dom/src/storage/DOMStorageObserver.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/src/storage/DOMStorageObserver.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsIDOMStorageObserver_h__
    1.10 +#define nsIDOMStorageObserver_h__
    1.11 +
    1.12 +#include "nsIObserver.h"
    1.13 +#include "nsITimer.h"
    1.14 +#include "nsWeakReference.h"
    1.15 +#include "nsTArray.h"
    1.16 +#include "nsString.h"
    1.17 +
    1.18 +namespace mozilla {
    1.19 +namespace dom {
    1.20 +
    1.21 +class DOMStorageObserver;
    1.22 +
    1.23 +// Implementers are DOMStorageManager and DOMStorageDBParent to forward to
    1.24 +// child processes.
    1.25 +class DOMStorageObserverSink
    1.26 +{
    1.27 +public:
    1.28 +  virtual ~DOMStorageObserverSink() {}
    1.29 +
    1.30 +private:
    1.31 +  friend class DOMStorageObserver;
    1.32 +  virtual nsresult Observe(const char* aTopic, const nsACString& aScopePrefix) = 0;
    1.33 +};
    1.34 +
    1.35 +// Statically (though layout statics) initialized observer receiving and processing
    1.36 +// chrome clearing notifications, such as cookie deletion etc.
    1.37 +class DOMStorageObserver : public nsIObserver
    1.38 +                         , public nsSupportsWeakReference
    1.39 +{
    1.40 +public:
    1.41 +  NS_DECL_ISUPPORTS
    1.42 +  NS_DECL_NSIOBSERVER
    1.43 +
    1.44 +  virtual ~DOMStorageObserver() {}
    1.45 +
    1.46 +  static nsresult Init();
    1.47 +  static nsresult Shutdown();
    1.48 +  static DOMStorageObserver* Self() { return sSelf; }
    1.49 +
    1.50 +  void AddSink(DOMStorageObserverSink* aObs);
    1.51 +  void RemoveSink(DOMStorageObserverSink* aObs);
    1.52 +  void Notify(const char* aTopic, const nsACString& aData = EmptyCString());
    1.53 +
    1.54 +private:
    1.55 +  static DOMStorageObserver* sSelf;
    1.56 +
    1.57 +  // Weak references
    1.58 +  nsTArray<DOMStorageObserverSink*> mSinks;
    1.59 +  nsCOMPtr<nsITimer> mDBThreadStartDelayTimer;
    1.60 +};
    1.61 +
    1.62 +} // ::dom
    1.63 +} // ::mozilla
    1.64 +
    1.65 +#endif

mercurial