Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / storage / SessionStorageObserver.cpp
blob2963a046bed8a623a115cf19abf0480275adf141
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "SessionStorageObserver.h"
8 #include "StorageIPC.h"
9 #include "mozilla/dom/LocalStorageCommon.h"
11 namespace mozilla::dom {
13 namespace {
15 SessionStorageObserver* gSessionStorageObserver = nullptr;
17 } // namespace
19 SessionStorageObserver::SessionStorageObserver() : mActor(nullptr) {
20 AssertIsOnOwningThread();
21 MOZ_ASSERT(NextGenLocalStorageEnabled());
23 MOZ_ASSERT(!gSessionStorageObserver);
24 gSessionStorageObserver = this;
27 SessionStorageObserver::~SessionStorageObserver() {
28 AssertIsOnOwningThread();
30 if (mActor) {
31 mActor->SendDeleteMeInternal();
32 MOZ_ASSERT(!mActor, "SendDeleteMeInternal should have cleared!");
35 MOZ_ASSERT(gSessionStorageObserver);
36 gSessionStorageObserver = nullptr;
39 // static
40 SessionStorageObserver* SessionStorageObserver::Get() {
41 MOZ_ASSERT(NS_IsMainThread());
42 MOZ_ASSERT(NextGenLocalStorageEnabled());
44 return gSessionStorageObserver;
47 void SessionStorageObserver::SetActor(SessionStorageObserverChild* aActor) {
48 AssertIsOnOwningThread();
49 MOZ_ASSERT(aActor);
50 MOZ_ASSERT(!mActor);
52 mActor = aActor;
55 } // namespace mozilla::dom