Line data Source code
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_StorageNotifierService_h
8 : #define mozilla_dom_StorageNotifierService_h
9 :
10 : class nsPIDOMWindowInner;
11 :
12 : namespace mozilla {
13 : namespace dom {
14 :
15 : class StorageEvent;
16 :
17 7 : class StorageNotificationObserver
18 : {
19 : public:
20 : NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
21 :
22 : virtual void
23 : ObserveStorageNotification(StorageEvent* aEvent,
24 : const char16_t* aStorageType,
25 : bool aPrivateBrowsing) = 0;
26 :
27 : virtual nsIEventTarget*
28 : GetEventTarget() const = 0;
29 : };
30 :
31 : class StorageNotifierService final
32 : {
33 : public:
34 18 : NS_INLINE_DECL_REFCOUNTING(StorageNotifierService)
35 :
36 : static StorageNotifierService*
37 : GetOrCreate();
38 :
39 : static void
40 : Broadcast(StorageEvent* aEvent, const char16_t* aStorageType,
41 : bool aPrivateBrowsing, bool aImmediateDispatch);
42 :
43 : void
44 : Register(StorageNotificationObserver* aObserver);
45 :
46 : void
47 : Unregister(StorageNotificationObserver* aObserver);
48 :
49 : private:
50 : StorageNotifierService();
51 : ~StorageNotifierService();
52 :
53 : nsTObserverArray<RefPtr<StorageNotificationObserver>> mObservers;
54 : };
55 :
56 : } // namespace dom
57 : } // namespace mozilla
58 :
59 : #endif // mozilla_dom_StorageNotifierService_h
|