2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-04-15 16:38:48 +04:00
|
|
|
/* 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 http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2017-01-04 16:53:01 +03:00
|
|
|
#ifndef mozilla_dom_StorageObserver_h
|
|
|
|
#define mozilla_dom_StorageObserver_h
|
2013-04-15 16:38:48 +04:00
|
|
|
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsWeakReference.h"
|
2017-09-10 20:32:13 +03:00
|
|
|
#include "nsTObserverArray.h"
|
2013-04-15 16:38:48 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2017-01-04 16:53:01 +03:00
|
|
|
class StorageObserver;
|
2013-04-15 16:38:48 +04:00
|
|
|
|
2017-01-04 16:53:01 +03:00
|
|
|
// Implementers are StorageManager and StorageDBParent to forward to
|
2013-04-15 16:38:48 +04:00
|
|
|
// child processes.
|
2017-01-04 16:53:01 +03:00
|
|
|
class StorageObserverSink
|
2013-04-15 16:38:48 +04:00
|
|
|
{
|
|
|
|
public:
|
2017-01-04 16:53:01 +03:00
|
|
|
virtual ~StorageObserverSink() {}
|
2013-04-15 16:38:48 +04:00
|
|
|
|
|
|
|
private:
|
2017-01-04 16:53:01 +03:00
|
|
|
friend class StorageObserver;
|
2016-01-05 15:25:00 +03:00
|
|
|
virtual nsresult Observe(const char* aTopic,
|
|
|
|
const nsAString& aOriginAttributesPattern,
|
|
|
|
const nsACString& aOriginScope) = 0;
|
2013-04-15 16:38:48 +04:00
|
|
|
};
|
|
|
|
|
2017-01-04 16:53:01 +03:00
|
|
|
// Statically (through layout statics) initialized observer receiving and
|
|
|
|
// processing chrome clearing notifications, such as cookie deletion etc.
|
|
|
|
class StorageObserver : public nsIObserver
|
|
|
|
, public nsSupportsWeakReference
|
2013-04-15 16:38:48 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
static nsresult Init();
|
|
|
|
static nsresult Shutdown();
|
2017-01-04 16:53:01 +03:00
|
|
|
static StorageObserver* Self() { return sSelf; }
|
2013-04-15 16:38:48 +04:00
|
|
|
|
2017-01-04 16:53:01 +03:00
|
|
|
void AddSink(StorageObserverSink* aObs);
|
|
|
|
void RemoveSink(StorageObserverSink* aObs);
|
2016-01-05 15:25:00 +03:00
|
|
|
void Notify(const char* aTopic,
|
|
|
|
const nsAString& aOriginAttributesPattern = EmptyString(),
|
|
|
|
const nsACString& aOriginScope = EmptyCString());
|
2013-04-15 16:38:48 +04:00
|
|
|
|
2017-07-26 13:19:13 +03:00
|
|
|
void
|
|
|
|
NoteBackgroundThread(nsIEventTarget* aBackgroundThread);
|
|
|
|
|
2013-04-15 16:38:48 +04:00
|
|
|
private:
|
2017-01-04 16:53:01 +03:00
|
|
|
virtual ~StorageObserver() {}
|
2014-06-23 23:56:07 +04:00
|
|
|
|
2017-09-25 23:47:38 +03:00
|
|
|
nsresult
|
|
|
|
ClearMatchingOrigin(const char16_t* aData,
|
|
|
|
nsACString& aOriginScope);
|
|
|
|
|
2016-12-19 20:48:33 +03:00
|
|
|
static void TestingPrefChanged(const char* aPrefName, void* aClosure);
|
|
|
|
|
2017-01-04 16:53:01 +03:00
|
|
|
static StorageObserver* sSelf;
|
2013-04-15 16:38:48 +04:00
|
|
|
|
2017-07-26 13:19:13 +03:00
|
|
|
nsCOMPtr<nsIEventTarget> mBackgroundThread;
|
|
|
|
|
2013-04-15 16:38:48 +04:00
|
|
|
// Weak references
|
2017-09-10 20:32:13 +03:00
|
|
|
nsTObserverArray<StorageObserverSink*> mSinks;
|
2013-04-15 16:38:48 +04:00
|
|
|
nsCOMPtr<nsITimer> mDBThreadStartDelayTimer;
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-04-15 16:38:48 +04:00
|
|
|
|
2017-01-04 16:53:01 +03:00
|
|
|
#endif // mozilla_dom_StorageObserver_h
|