Source code

Revision control

Other Tools

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/. */
6
7
#include "SessionStorageObserver.h"
8
9
namespace mozilla {
10
namespace dom {
11
12
namespace {
13
14
SessionStorageObserver* gSessionStorageObserver = nullptr;
15
16
} // namespace
17
18
SessionStorageObserver::SessionStorageObserver() : mActor(nullptr) {
19
AssertIsOnOwningThread();
20
MOZ_ASSERT(NextGenLocalStorageEnabled());
21
22
MOZ_ASSERT(!gSessionStorageObserver);
23
gSessionStorageObserver = this;
24
}
25
26
SessionStorageObserver::~SessionStorageObserver() {
27
AssertIsOnOwningThread();
28
29
if (mActor) {
30
mActor->SendDeleteMeInternal();
31
MOZ_ASSERT(!mActor, "SendDeleteMeInternal should have cleared!");
32
}
33
34
MOZ_ASSERT(gSessionStorageObserver);
35
gSessionStorageObserver = nullptr;
36
}
37
38
// static
39
SessionStorageObserver* SessionStorageObserver::Get() {
40
MOZ_ASSERT(NS_IsMainThread());
41
MOZ_ASSERT(NextGenLocalStorageEnabled());
42
43
return gSessionStorageObserver;
44
}
45
46
void SessionStorageObserver::SetActor(SessionStorageObserverChild* aActor) {
47
AssertIsOnOwningThread();
48
MOZ_ASSERT(aActor);
49
MOZ_ASSERT(!mActor);
50
51
mActor = aActor;
52
}
53
54
} // namespace dom
55
} // namespace mozilla