Bug 1707290 [wpt PR 28671] - Auto-expand details elements for find-in-page, a=testonly
[gecko.git] / dom / storage / SessionStorageObserver.cpp
blobedfe745528a0fc2ebe0eddbeccb4ebeeaa48d316
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 {
12 namespace dom {
14 namespace {
16 SessionStorageObserver* gSessionStorageObserver = nullptr;
18 } // namespace
20 SessionStorageObserver::SessionStorageObserver() : mActor(nullptr) {
21 AssertIsOnOwningThread();
22 MOZ_ASSERT(NextGenLocalStorageEnabled());
24 MOZ_ASSERT(!gSessionStorageObserver);
25 gSessionStorageObserver = this;
28 SessionStorageObserver::~SessionStorageObserver() {
29 AssertIsOnOwningThread();
31 if (mActor) {
32 mActor->SendDeleteMeInternal();
33 MOZ_ASSERT(!mActor, "SendDeleteMeInternal should have cleared!");
36 MOZ_ASSERT(gSessionStorageObserver);
37 gSessionStorageObserver = nullptr;
40 // static
41 SessionStorageObserver* SessionStorageObserver::Get() {
42 MOZ_ASSERT(NS_IsMainThread());
43 MOZ_ASSERT(NextGenLocalStorageEnabled());
45 return gSessionStorageObserver;
48 void SessionStorageObserver::SetActor(SessionStorageObserverChild* aActor) {
49 AssertIsOnOwningThread();
50 MOZ_ASSERT(aActor);
51 MOZ_ASSERT(!mActor);
53 mActor = aActor;
56 } // namespace dom
57 } // namespace mozilla