michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsIDOMStorageObserver_h__ michael@0: #define nsIDOMStorageObserver_h__ michael@0: michael@0: #include "nsIObserver.h" michael@0: #include "nsITimer.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsTArray.h" michael@0: #include "nsString.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class DOMStorageObserver; michael@0: michael@0: // Implementers are DOMStorageManager and DOMStorageDBParent to forward to michael@0: // child processes. michael@0: class DOMStorageObserverSink michael@0: { michael@0: public: michael@0: virtual ~DOMStorageObserverSink() {} michael@0: michael@0: private: michael@0: friend class DOMStorageObserver; michael@0: virtual nsresult Observe(const char* aTopic, const nsACString& aScopePrefix) = 0; michael@0: }; michael@0: michael@0: // Statically (though layout statics) initialized observer receiving and processing michael@0: // chrome clearing notifications, such as cookie deletion etc. michael@0: class DOMStorageObserver : public nsIObserver michael@0: , public nsSupportsWeakReference michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIOBSERVER michael@0: michael@0: virtual ~DOMStorageObserver() {} michael@0: michael@0: static nsresult Init(); michael@0: static nsresult Shutdown(); michael@0: static DOMStorageObserver* Self() { return sSelf; } michael@0: michael@0: void AddSink(DOMStorageObserverSink* aObs); michael@0: void RemoveSink(DOMStorageObserverSink* aObs); michael@0: void Notify(const char* aTopic, const nsACString& aData = EmptyCString()); michael@0: michael@0: private: michael@0: static DOMStorageObserver* sSelf; michael@0: michael@0: // Weak references michael@0: nsTArray mSinks; michael@0: nsCOMPtr mDBThreadStartDelayTimer; michael@0: }; michael@0: michael@0: } // ::dom michael@0: } // ::mozilla michael@0: michael@0: #endif