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"
12 #include "nsWrapperCache.h"
14 #include "mozilla/dom/PerformanceObserverBinding.h"
20 class PerformanceResourceTiming
;
22 // http://www.w3.org/TR/performance-timeline/#performanceentry
23 class PerformanceEntry
: public nsISupports
, public nsWrapperCache
{
25 virtual ~PerformanceEntry();
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 {
38 mName
->ToString(aName
);
42 const nsAtom
* GetName() const { return mName
; }
44 void GetEntryType(nsAString
& aEntryType
) const {
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 {
64 virtual bool ShouldAddEntryToObserverBuffer(
65 PerformanceObserverInit
& aOption
) const;
67 virtual void BufferEntryIfNeeded() {}
69 virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
) const;
72 virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf
) const;
75 nsCOMPtr
<nsISupports
> mParent
;
77 RefPtr
<nsAtom
> mEntryType
;
81 class MOZ_STACK_CLASS PerformanceEntryComparator final
{
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();
97 } // namespace mozilla
99 #endif /* mozilla_dom_PerformanceEntry_h___ */