dom/src/storage/DOMStorageObserver.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:53c468bb2911
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef nsIDOMStorageObserver_h__
7 #define nsIDOMStorageObserver_h__
8
9 #include "nsIObserver.h"
10 #include "nsITimer.h"
11 #include "nsWeakReference.h"
12 #include "nsTArray.h"
13 #include "nsString.h"
14
15 namespace mozilla {
16 namespace dom {
17
18 class DOMStorageObserver;
19
20 // Implementers are DOMStorageManager and DOMStorageDBParent to forward to
21 // child processes.
22 class DOMStorageObserverSink
23 {
24 public:
25 virtual ~DOMStorageObserverSink() {}
26
27 private:
28 friend class DOMStorageObserver;
29 virtual nsresult Observe(const char* aTopic, const nsACString& aScopePrefix) = 0;
30 };
31
32 // Statically (though layout statics) initialized observer receiving and processing
33 // chrome clearing notifications, such as cookie deletion etc.
34 class DOMStorageObserver : public nsIObserver
35 , public nsSupportsWeakReference
36 {
37 public:
38 NS_DECL_ISUPPORTS
39 NS_DECL_NSIOBSERVER
40
41 virtual ~DOMStorageObserver() {}
42
43 static nsresult Init();
44 static nsresult Shutdown();
45 static DOMStorageObserver* Self() { return sSelf; }
46
47 void AddSink(DOMStorageObserverSink* aObs);
48 void RemoveSink(DOMStorageObserverSink* aObs);
49 void Notify(const char* aTopic, const nsACString& aData = EmptyCString());
50
51 private:
52 static DOMStorageObserver* sSelf;
53
54 // Weak references
55 nsTArray<DOMStorageObserverSink*> mSinks;
56 nsCOMPtr<nsITimer> mDBThreadStartDelayTimer;
57 };
58
59 } // ::dom
60 } // ::mozilla
61
62 #endif

mercurial