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 
12 namespace mozilla {
13 namespace 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 
32   void AddEntryOnWorker(UniquePtr<PerformanceProxyData>&& aData);
33 
34  private:
35   PerformanceStorageWorker();
36   ~PerformanceStorageWorker();
37 
38   Mutex mMutex;
39 
40   // Protected by mutex.
41   // Created and released on worker-thread. Used also on main-thread.
42   RefPtr<WeakWorkerRef> mWorkerRef;
43 };
44 
45 }  // namespace dom
46 }  // namespace mozilla
47 
48 #endif  // mozilla_dom_PerformanceStorageWorker_h
49