dom/src/storage/DOMStorageObserver.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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
    23 {
    24 public:
    25   virtual ~DOMStorageObserverSink() {}
    27 private:
    28   friend class DOMStorageObserver;
    29   virtual nsresult Observe(const char* aTopic, const nsACString& aScopePrefix) = 0;
    30 };
    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
    41   virtual ~DOMStorageObserver() {}
    43   static nsresult Init();
    44   static nsresult Shutdown();
    45   static DOMStorageObserver* Self() { return sSelf; }
    47   void AddSink(DOMStorageObserverSink* aObs);
    48   void RemoveSink(DOMStorageObserverSink* aObs);
    49   void Notify(const char* aTopic, const nsACString& aData = EmptyCString());
    51 private:
    52   static DOMStorageObserver* sSelf;
    54   // Weak references
    55   nsTArray<DOMStorageObserverSink*> mSinks;
    56   nsCOMPtr<nsITimer> mDBThreadStartDelayTimer;
    57 };
    59 } // ::dom
    60 } // ::mozilla
    62 #endif

mercurial