author Sebastian Hengst <>
Thu, 14 Sep 2017 23:18:49 +0200
changeset 381048 edddc72cb9a8b62fa6e921332c32128594fede6c
parent 379973 5d74712bb1627824ef2abbc8fc4a5e28352e5f42
child 383242 7ae47699361c77e4282d9532160d2d220bbd28cf
permissions -rw-r--r--
Backed out changeset 67ca40453027 (bug 1393031) for failing e.g. reftest layout/reftests/image/image-srcset-basic-selection-2x-ref.html on QuantumRender. r=backout

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef mozilla_dom_StorageObserver_h
#define mozilla_dom_StorageObserver_h

#include "nsIObserver.h"
#include "nsITimer.h"
#include "nsWeakReference.h"
#include "nsTObserverArray.h"
#include "nsString.h"

namespace mozilla {
namespace dom {

class StorageObserver;

// Implementers are StorageManager and StorageDBParent to forward to
// child processes.
class StorageObserverSink
  virtual ~StorageObserverSink() {}

  friend class StorageObserver;
  virtual nsresult Observe(const char* aTopic,
                           const nsAString& aOriginAttributesPattern,
                           const nsACString& aOriginScope) = 0;

// Statically (through layout statics) initialized observer receiving and
// processing chrome clearing notifications, such as cookie deletion etc.
class StorageObserver : public nsIObserver
                      , public nsSupportsWeakReference

  static nsresult Init();
  static nsresult Shutdown();
  static StorageObserver* Self() { return sSelf; }

  void AddSink(StorageObserverSink* aObs);
  void RemoveSink(StorageObserverSink* aObs);
  void Notify(const char* aTopic,
              const nsAString& aOriginAttributesPattern = EmptyString(),
              const nsACString& aOriginScope = EmptyCString());

  NoteBackgroundThread(nsIEventTarget* aBackgroundThread);

  virtual ~StorageObserver() {}

  static void TestingPrefChanged(const char* aPrefName, void* aClosure);

  static StorageObserver* sSelf;

  nsCOMPtr<nsIEventTarget> mBackgroundThread;

  // Weak references
  nsTObserverArray<StorageObserverSink*> mSinks;
  nsCOMPtr<nsITimer> mDBThreadStartDelayTimer;

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_StorageObserver_h