Source code

Revision control

Other Tools

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/. */
6
7
#ifndef mozilla_dom_SessionStorageObserver_h
8
#define mozilla_dom_SessionStorageObserver_h
9
10
namespace mozilla {
11
namespace dom {
12
13
class SessionStorageObserverChild;
14
15
/**
16
* Effectively just a refcounted life-cycle management wrapper around
17
* SessionStorageObserverChild which exists to receive chrome observer
18
* notifications from the main process.
19
*
20
* ## Lifecycle ##
21
* - Created by SessionStorageManager::SessionStorageManager. Placed in the
22
* gSessionStorageObserver variable for subsequent SessionStorageManager's via
23
* SessionStorageObserver::Get lookup.
24
* - The SessionStorageObserverChild directly handles "Observe" messages,
25
* shunting them directly to StorageObserver::Notify which distributes them to
26
* individual observer sinks.
27
* - Destroyed when refcount goes to zero due to all owning
28
* SessionStorageManager being destroyed.
29
*/
30
class SessionStorageObserver final {
31
friend class SessionStorageManager;
32
33
SessionStorageObserverChild* mActor;
34
35
public:
36
static SessionStorageObserver* Get();
37
38
NS_INLINE_DECL_REFCOUNTING(SessionStorageObserver)
39
40
void AssertIsOnOwningThread() const {
41
NS_ASSERT_OWNINGTHREAD(SessionStorageObserver);
42
}
43
44
void SetActor(SessionStorageObserverChild* aActor);
45
46
void ClearActor() {
47
AssertIsOnOwningThread();
48
MOZ_ASSERT(mActor);
49
50
mActor = nullptr;
51
}
52
53
private:
54
// Only created by SessionStorageManager.
55
SessionStorageObserver();
56
57
~SessionStorageObserver();
58
};
59
60
} // namespace dom
61
} // namespace mozilla
62
63
#endif // mozilla_dom_SessionStorageObserver_h