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