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/. */
6 
7 #ifndef mozilla_dom_PerformanceWorker_h
8 #define mozilla_dom_PerformanceWorker_h
9 
10 #include "Performance.h"
11 
12 namespace mozilla {
13 namespace dom {
14 
15 class WorkerPrivate;
16 
17 class PerformanceWorker final : public Performance {
18  public:
19   explicit PerformanceWorker(WorkerPrivate* aWorkerPrivate);
20 
AsPerformanceStorage()21   PerformanceStorage* AsPerformanceStorage() override {
22     MOZ_CRASH("This should not be called on workers.");
23     return nullptr;
24   }
25 
Timing()26   virtual PerformanceTiming* Timing() override {
27     MOZ_CRASH("This should not be called on workers.");
28     return nullptr;
29   }
30 
Navigation()31   virtual PerformanceNavigation* Navigation() override {
32     MOZ_CRASH("This should not be called on workers.");
33     return nullptr;
34   }
35 
SetFCPTimingEntry(PerformancePaintTiming * aEntry)36   virtual void SetFCPTimingEntry(PerformancePaintTiming* aEntry) override {
37     MOZ_CRASH("This should not be called on workers.");
38   }
39 
40   TimeStamp CreationTimeStamp() const override;
41 
42   DOMHighResTimeStamp CreationTime() const override;
43 
GetMozMemory(JSContext * aCx,JS::MutableHandle<JSObject * > aObj)44   virtual void GetMozMemory(JSContext* aCx,
45                             JS::MutableHandle<JSObject*> aObj) override {
46     MOZ_CRASH("This should not be called on workers.");
47   }
48 
GetDOMTiming()49   virtual nsDOMNavigationTiming* GetDOMTiming() const override {
50     MOZ_CRASH("This should not be called on workers.");
51     return nullptr;
52   }
53 
54   virtual uint64_t GetRandomTimelineSeed() override;
55 
GetChannel()56   virtual nsITimedChannel* GetChannel() const override {
57     MOZ_CRASH("This should not be called on workers.");
58     return nullptr;
59   }
60 
QueueNavigationTimingEntry()61   void QueueNavigationTimingEntry() override {
62     MOZ_CRASH("This should not be called on workers.");
63   }
64 
UpdateNavigationTimingEntry()65   void UpdateNavigationTimingEntry() override {
66     MOZ_CRASH("This should not be called on workers.");
67   }
68 
InsertEventTimingEntry(PerformanceEventTiming *)69   void InsertEventTimingEntry(PerformanceEventTiming*) override {
70     MOZ_CRASH("This should not be called on workers.");
71   }
72 
BufferEventTimingEntryIfNeeded(PerformanceEventTiming *)73   void BufferEventTimingEntryIfNeeded(PerformanceEventTiming*) override {
74     MOZ_CRASH("This should not be called on workers.");
75   }
76 
DispatchPendingEventTimingEntries()77   void DispatchPendingEventTimingEntries() override {
78     MOZ_CRASH("This should not be called on workders.");
79   }
80 
EventCounts()81   class EventCounts* EventCounts() override {
82     MOZ_CRASH("This should not be called on workers");
83   }
84 
85   bool CrossOriginIsolated() const override;
86 
87  protected:
88   ~PerformanceWorker();
89 
90   void InsertUserEntry(PerformanceEntry* aEntry) override;
91 
DispatchBufferFullEvent()92   void DispatchBufferFullEvent() override {
93     // Nothing to do here. See bug 1432758.
94   }
95 
96  private:
97   WorkerPrivate* mWorkerPrivate;
98 };
99 
100 }  // namespace dom
101 }  // namespace mozilla
102 
103 #endif  // mozilla_dom_PerformanceWorker_h
104