Bug 1572460 - Refactor `selection` out of the `InspectorFront`. r=yulia
[gecko.git] / dom / storage / SessionStorageObserver.cpp
blob94d548fe5fb39ea795f3c3667467983c00c13422
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"
9 namespace mozilla {
10 namespace dom {
12 namespace {
14 SessionStorageObserver* gSessionStorageObserver = nullptr;
16 } // namespace
18 SessionStorageObserver::SessionStorageObserver() : mActor(nullptr) {
19 AssertIsOnOwningThread();
20 MOZ_ASSERT(NextGenLocalStorageEnabled());
22 MOZ_ASSERT(!gSessionStorageObserver);
23 gSessionStorageObserver = this;
26 SessionStorageObserver::~SessionStorageObserver() {
27 AssertIsOnOwningThread();
29 if (mActor) {
30 mActor->SendDeleteMeInternal();
31 MOZ_ASSERT(!mActor, "SendDeleteMeInternal should have cleared!");
34 MOZ_ASSERT(gSessionStorageObserver);
35 gSessionStorageObserver = nullptr;
38 // static
39 SessionStorageObserver* SessionStorageObserver::Get() {
40 MOZ_ASSERT(NS_IsMainThread());
41 MOZ_ASSERT(NextGenLocalStorageEnabled());
43 return gSessionStorageObserver;
46 void SessionStorageObserver::SetActor(SessionStorageObserverChild* aActor) {
47 AssertIsOnOwningThread();
48 MOZ_ASSERT(aActor);
49 MOZ_ASSERT(!mActor);
51 mActor = aActor;
54 } // namespace dom
55 } // namespace mozilla