Bumping manifests a=b2g-bump
[gecko.git] / dom / storage / DOMStorageObserver.h
blob92790ee07add80c0e52057903c37c26d472401bb
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/. */
6 #ifndef nsIDOMStorageObserver_h__
7 #define nsIDOMStorageObserver_h__
9 #include "nsIObserver.h"
10 #include "nsITimer.h"
11 #include "nsWeakReference.h"
12 #include "nsTArray.h"
13 #include "nsString.h"
15 namespace mozilla {
16 namespace dom {
18 class DOMStorageObserver;
20 // Implementers are DOMStorageManager and DOMStorageDBParent to forward to
21 // child processes.
22 class DOMStorageObserverSink
24 public:
25 virtual ~DOMStorageObserverSink() {}
27 private:
28 friend class DOMStorageObserver;
29 virtual nsresult Observe(const char* aTopic, const nsACString& aScopePrefix) = 0;
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
37 public:
38 NS_DECL_ISUPPORTS
39 NS_DECL_NSIOBSERVER
41 static nsresult Init();
42 static nsresult Shutdown();
43 static DOMStorageObserver* Self() { return sSelf; }
45 void AddSink(DOMStorageObserverSink* aObs);
46 void RemoveSink(DOMStorageObserverSink* aObs);
47 void Notify(const char* aTopic, const nsACString& aData = EmptyCString());
49 private:
50 virtual ~DOMStorageObserver() {}
52 static DOMStorageObserver* sSelf;
54 // Weak references
55 nsTArray<DOMStorageObserverSink*> mSinks;
56 nsCOMPtr<nsITimer> mDBThreadStartDelayTimer;
59 } // ::dom
60 } // ::mozilla
62 #endif