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