Bug 1472338: part 2) Change `clipboard.readText()` to read from the clipboard asynchr...
[gecko.git] / dom / performance / PerformanceEntry.h
blobbb65792ac15440e8a99d30536faeab2129793a67
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_PerformanceEntry_h___
8 #define mozilla_dom_PerformanceEntry_h___
10 #include "nsDOMNavigationTiming.h"
11 #include "nsString.h"
12 #include "nsWrapperCache.h"
13 #include "nsAtom.h"
14 #include "mozilla/dom/PerformanceObserverBinding.h"
16 class nsISupports;
18 namespace mozilla {
19 namespace dom {
20 class PerformanceResourceTiming;
22 // http://www.w3.org/TR/performance-timeline/#performanceentry
23 class PerformanceEntry : public nsISupports, public nsWrapperCache {
24 protected:
25 virtual ~PerformanceEntry();
27 public:
28 PerformanceEntry(nsISupports* aParent, const nsAString& aName,
29 const nsAString& aEntryType);
31 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PerformanceEntry)
34 nsISupports* GetParentObject() const { return mParent; }
36 void GetName(nsAString& aName) const {
37 if (mName) {
38 mName->ToString(aName);
42 const nsAtom* GetName() const { return mName; }
44 void GetEntryType(nsAString& aEntryType) const {
45 if (mEntryType) {
46 mEntryType->ToString(aEntryType);
50 const nsAtom* GetEntryType() const { return mEntryType; }
52 void SetEntryType(const nsAString& aEntryType) {
53 mEntryType = NS_Atomize(aEntryType);
56 virtual DOMHighResTimeStamp StartTime() const { return 0; }
58 virtual DOMHighResTimeStamp Duration() const { return 0; }
60 virtual const PerformanceResourceTiming* ToResourceTiming() const {
61 return nullptr;
64 virtual bool ShouldAddEntryToObserverBuffer(
65 PerformanceObserverInit& aOption) const;
67 virtual void BufferEntryIfNeeded() {}
69 virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
71 protected:
72 virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
74 private:
75 nsCOMPtr<nsISupports> mParent;
76 RefPtr<nsAtom> mName;
77 RefPtr<nsAtom> mEntryType;
80 // Helper classes
81 class MOZ_STACK_CLASS PerformanceEntryComparator final {
82 public:
83 bool Equals(const PerformanceEntry* aElem1,
84 const PerformanceEntry* aElem2) const {
85 MOZ_ASSERT(aElem1 && aElem2, "Trying to compare null performance entries");
86 return aElem1->StartTime() == aElem2->StartTime();
89 bool LessThan(const PerformanceEntry* aElem1,
90 const PerformanceEntry* aElem2) const {
91 MOZ_ASSERT(aElem1 && aElem2, "Trying to compare null performance entries");
92 return aElem1->StartTime() < aElem2->StartTime();
96 } // namespace dom
97 } // namespace mozilla
99 #endif /* mozilla_dom_PerformanceEntry_h___ */