PerformanceStorageWorker.h (1498B)
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_PerformanceStorageWorker_h 8 #define mozilla_dom_PerformanceStorageWorker_h 9 10 #include "PerformanceStorage.h" 11 #include "mozilla/Mutex.h" 12 13 namespace mozilla::dom { 14 15 class WeakWorkerRef; 16 class WorkerPrivate; 17 18 class PerformanceProxyData; 19 20 class PerformanceStorageWorker final : public PerformanceStorage { 21 public: 22 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PerformanceStorageWorker, override) 23 24 static already_AddRefed<PerformanceStorageWorker> Create( 25 WorkerPrivate* aWorkerPrivate); 26 27 void ShutdownOnWorker(); 28 29 void AddEntry(nsIHttpChannel* aChannel, 30 nsITimedChannel* aTimedChannel) override; 31 void AddEntry(const nsString& aEntryName, const nsString& aInitiatorType, 32 UniquePtr<PerformanceTimingData>&& aData) override; 33 void AddEntryOnWorker(UniquePtr<PerformanceProxyData>&& aData); 34 35 private: 36 PerformanceStorageWorker(); 37 ~PerformanceStorageWorker(); 38 39 Mutex mMutex; 40 41 // Protected by mutex. 42 // Created and released on worker-thread. Used also on main-thread. 43 RefPtr<WeakWorkerRef> mWorkerRef MOZ_GUARDED_BY(mMutex); 44 }; 45 46 } // namespace mozilla::dom 47 48 #endif // mozilla_dom_PerformanceStorageWorker_h