Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / storage / SessionStorageObserver.h
blobdee472cc9c6e27a883822549407f0a7d4ead4aec
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/. */
7 #ifndef mozilla_dom_SessionStorageObserver_h
8 #define mozilla_dom_SessionStorageObserver_h
10 #include "nsISupportsImpl.h"
12 namespace mozilla::dom {
14 class SessionStorageObserverChild;
16 /**
17 * Effectively just a refcounted life-cycle management wrapper around
18 * SessionStorageObserverChild which exists to receive chrome observer
19 * notifications from the main process.
21 * ## Lifecycle ##
22 * - Created by SessionStorageManager::SessionStorageManager. Placed in the
23 * gSessionStorageObserver variable for subsequent SessionStorageManager's via
24 * SessionStorageObserver::Get lookup.
25 * - The SessionStorageObserverChild directly handles "Observe" messages,
26 * shunting them directly to StorageObserver::Notify which distributes them to
27 * individual observer sinks.
28 * - Destroyed when refcount goes to zero due to all owning
29 * SessionStorageManager being destroyed.
31 class SessionStorageObserver final {
32 friend class SessionStorageManager;
34 SessionStorageObserverChild* mActor;
36 public:
37 static SessionStorageObserver* Get();
39 NS_INLINE_DECL_REFCOUNTING(SessionStorageObserver)
41 void AssertIsOnOwningThread() const {
42 NS_ASSERT_OWNINGTHREAD(SessionStorageObserver);
45 void SetActor(SessionStorageObserverChild* aActor);
47 void ClearActor() {
48 AssertIsOnOwningThread();
49 MOZ_ASSERT(mActor);
51 mActor = nullptr;
54 private:
55 // Only created by SessionStorageManager.
56 SessionStorageObserver();
58 ~SessionStorageObserver();
61 } // namespace mozilla::dom
63 #endif // mozilla_dom_SessionStorageObserver_h