Bug 1472338: part 2) Change `clipboard.readText()` to read from the clipboard asynchr...
[gecko.git] / dom / performance / PerformanceMainThread.h
blob07bc85e9569663378464059e455b0d6cdcf3d845
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_PerformanceMainThread_h
8 #define mozilla_dom_PerformanceMainThread_h
10 #include "Performance.h"
11 #include "PerformanceStorage.h"
13 namespace mozilla {
14 namespace dom {
16 class PerformanceNavigationTiming;
17 class PerformanceEventTiming;
19 class PerformanceMainThread final : public Performance,
20 public PerformanceStorage {
21 public:
22 PerformanceMainThread(nsPIDOMWindowInner* aWindow,
23 nsDOMNavigationTiming* aDOMTiming,
24 nsITimedChannel* aChannel, bool aPrincipal);
26 NS_DECL_ISUPPORTS_INHERITED
27 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PerformanceMainThread,
28 Performance)
30 PerformanceStorage* AsPerformanceStorage() override { return this; }
32 virtual PerformanceTiming* Timing() override;
34 virtual PerformanceNavigation* Navigation() override;
36 virtual void AddEntry(nsIHttpChannel* channel,
37 nsITimedChannel* timedChannel) override;
39 // aData must be non-null.
40 virtual void AddEntry(const nsString& entryName,
41 const nsString& initiatorType,
42 UniquePtr<PerformanceTimingData>&& aData) override;
44 // aPerformanceTimingData must be non-null.
45 void AddRawEntry(UniquePtr<PerformanceTimingData> aPerformanceTimingData,
46 const nsAString& aInitiatorType,
47 const nsAString& aEntryName);
48 virtual void SetFCPTimingEntry(PerformancePaintTiming* aEntry) override;
50 void InsertEventTimingEntry(PerformanceEventTiming*) override;
51 void BufferEventTimingEntryIfNeeded(PerformanceEventTiming*) override;
52 void DispatchPendingEventTimingEntries() override;
54 TimeStamp CreationTimeStamp() const override;
56 DOMHighResTimeStamp CreationTime() const override;
58 virtual void GetMozMemory(JSContext* aCx,
59 JS::MutableHandle<JSObject*> aObj) override;
61 virtual nsDOMNavigationTiming* GetDOMTiming() const override {
62 return mDOMTiming;
65 virtual uint64_t GetRandomTimelineSeed() override {
66 return GetDOMTiming()->GetRandomTimelineSeed();
69 virtual nsITimedChannel* GetChannel() const override { return mChannel; }
71 // The GetEntries* methods need to be overriden in order to add the
72 // the document entry of type navigation.
73 virtual void GetEntries(nsTArray<RefPtr<PerformanceEntry>>& aRetval) override;
75 // Return entries which qualify availableFromTimeline boolean check
76 virtual void GetEntriesByType(
77 const nsAString& aEntryType,
78 nsTArray<RefPtr<PerformanceEntry>>& aRetval) override;
80 // There are entries that we don't want expose via performance, however
81 // we do want PerformanceObserver to get them
82 void GetEntriesByTypeForObserver(
83 const nsAString& aEntryType,
84 nsTArray<RefPtr<PerformanceEntry>>& aRetval) override;
85 virtual void GetEntriesByName(
86 const nsAString& aName, const Optional<nsAString>& aEntryType,
87 nsTArray<RefPtr<PerformanceEntry>>& aRetval) override;
89 void UpdateNavigationTimingEntry() override;
90 void QueueNavigationTimingEntry() override;
92 bool CrossOriginIsolated() const override;
94 size_t SizeOfEventEntries(mozilla::MallocSizeOf aMallocSizeOf) const override;
96 static constexpr uint32_t kDefaultEventTimingBufferSize = 150;
97 static constexpr uint32_t kDefaultEventTimingDurationThreshold = 104;
98 static constexpr double kDefaultEventTimingMinDuration = 16.0;
100 class EventCounts* EventCounts() override;
102 protected:
103 ~PerformanceMainThread();
105 void CreateNavigationTimingEntry();
107 void InsertUserEntry(PerformanceEntry* aEntry) override;
109 bool IsPerformanceTimingAttribute(const nsAString& aName) override;
111 DOMHighResTimeStamp GetPerformanceTimingFromString(
112 const nsAString& aTimingName) override;
114 void DispatchBufferFullEvent() override;
116 RefPtr<PerformanceNavigationTiming> mDocEntry;
117 RefPtr<nsDOMNavigationTiming> mDOMTiming;
118 nsCOMPtr<nsITimedChannel> mChannel;
119 RefPtr<PerformanceTiming> mTiming;
120 RefPtr<PerformanceNavigation> mNavigation;
121 RefPtr<PerformancePaintTiming> mFCPTiming;
122 JS::Heap<JSObject*> mMozMemory;
124 const bool mCrossOriginIsolated;
126 nsTArray<RefPtr<PerformanceEventTiming>> mEventTimingEntries;
128 AutoCleanLinkedList<RefPtr<PerformanceEventTiming>>
129 mPendingEventTimingEntries;
130 bool mHasDispatchedInputEvent = false;
132 RefPtr<PerformanceEventTiming> mFirstInputEvent;
133 RefPtr<PerformanceEventTiming> mPendingPointerDown;
135 private:
136 bool mHasQueuedRefreshdriverObserver = false;
138 RefPtr<class EventCounts> mEventCounts;
139 void IncEventCount(const nsAtom* aType);
141 PresShell* GetPresShell();
144 } // namespace dom
145 } // namespace mozilla
147 #endif // mozilla_dom_PerformanceMainThread_h