Bug 1322316 - Split SessionStorage and LocalStorage implementation - part 4 - Rename StorageManagerBase to LocalStorageManager, r=asuth

--HG--
rename : dom/storage/StorageManager.cpp => dom/storage/LocalStorageManager.cpp
rename : dom/storage/StorageManager.h => dom/storage/LocalStorageManager.h
This commit is contained in:
Andrea Marchesini 2017-05-17 07:01:14 +02:00
parent 92cdd8d98b
commit 9ace5e5eb5
13 changed files with 129 additions and 243 deletions

View File

@ -5,8 +5,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "LocalStorage.h"
#include "LocalStorageManager.h"
#include "StorageCache.h"
#include "StorageManager.h"
#include "nsIObserverService.h"
#include "nsIScriptSecurityManager.h"
@ -43,7 +43,7 @@ NS_IMPL_ADDREF_INHERITED(LocalStorage, Storage)
NS_IMPL_RELEASE_INHERITED(LocalStorage, Storage)
LocalStorage::LocalStorage(nsPIDOMWindowInner* aWindow,
StorageManagerBase* aManager,
LocalStorageManager* aManager,
StorageCache* aCache,
const nsAString& aDocumentURI,
nsIPrincipal* aPrincipal,
@ -179,11 +179,9 @@ namespace {
class StorageNotifierRunnable : public Runnable
{
public:
StorageNotifierRunnable(nsISupports* aSubject, const char16_t* aType,
bool aPrivateBrowsing)
StorageNotifierRunnable(nsISupports* aSubject, bool aPrivateBrowsing)
: Runnable("StorageNotifierRunnable")
, mSubject(aSubject)
, mType(aType)
, mPrivateBrowsing(aPrivateBrowsing)
{ }
@ -191,7 +189,6 @@ public:
private:
nsCOMPtr<nsISupports> mSubject;
const char16_t* mType;
const bool mPrivateBrowsing;
};
@ -205,7 +202,7 @@ StorageNotifierRunnable::Run()
mPrivateBrowsing
? "dom-private-storage2-changed"
: "dom-storage2-changed",
mType);
u"localStorage");
}
return NS_OK;
}
@ -217,7 +214,7 @@ LocalStorage::BroadcastChangeNotification(const nsSubstring& aKey,
const nsSubstring& aOldValue,
const nsSubstring& aNewValue)
{
if (!XRE_IsParentProcess() && GetType() == eLocalStorage && Principal()) {
if (!XRE_IsParentProcess() && Principal()) {
// If we are in a child process, we want to send a message to the parent in
// order to broadcast the StorageEvent correctly to any child process.
dom::ContentChild* cc = dom::ContentChild::GetSingleton();
@ -226,13 +223,12 @@ LocalStorage::BroadcastChangeNotification(const nsSubstring& aKey,
IPC::Principal(Principal()), mIsPrivate));
}
DispatchStorageEvent(GetType(), mDocumentURI, aKey, aOldValue, aNewValue,
DispatchStorageEvent(mDocumentURI, aKey, aOldValue, aNewValue,
Principal(), mIsPrivate, this, false);
}
/* static */ void
LocalStorage::DispatchStorageEvent(StorageType aStorageType,
const nsAString& aDocumentURI,
LocalStorage::DispatchStorageEvent(const nsAString& aDocumentURI,
const nsAString& aKey,
const nsAString& aOldValue,
const nsAString& aNewValue,
@ -258,11 +254,7 @@ LocalStorage::DispatchStorageEvent(StorageType aStorageType,
event->SetPrincipal(aPrincipal);
RefPtr<StorageNotifierRunnable> r =
new StorageNotifierRunnable(event,
aStorageType == eLocalStorage
? u"localStorage"
: u"sessionStorage",
aIsPrivate);
new StorageNotifierRunnable(event, aIsPrivate);
if (aImmediateDispatch) {
Unused << r->Run();
@ -272,7 +264,7 @@ LocalStorage::DispatchStorageEvent(StorageType aStorageType,
// If we are in the parent process and we have the principal, we want to
// broadcast this event to every other process.
if (aStorageType == eLocalStorage && XRE_IsParentProcess() && aPrincipal) {
if (XRE_IsParentProcess() && aPrincipal) {
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
Unused << cp->SendDispatchLocalStorageChange(
nsString(aDocumentURI), nsString(aKey), nsString(aOldValue),
@ -335,12 +327,6 @@ LocalStorage::CanUseStorage(nsIPrincipal& aSubjectPrincipal)
return CanAccess(&aSubjectPrincipal);
}
LocalStorage::StorageType
LocalStorage::GetType() const
{
return mManager->Type();
}
// Defined in StorageManager.cpp
extern bool
PrincipalsEqual(nsIPrincipal* aObjectPrincipal,

View File

@ -13,7 +13,7 @@
namespace mozilla {
namespace dom {
class StorageManagerBase;
class LocalStorageManager;
class StorageCache;
class StorageEvent;
@ -26,7 +26,7 @@ public:
StorageType Type() const override { return eLocalStorage; }
StorageManagerBase* GetManager() const
LocalStorageManager* GetManager() const
{
return mManager;
}
@ -39,7 +39,7 @@ public:
bool PrincipalEquals(nsIPrincipal* aPrincipal);
LocalStorage(nsPIDOMWindowInner* aWindow,
StorageManagerBase* aManager,
LocalStorageManager* aManager,
StorageCache* aCache,
const nsAString& aDocumentURI,
nsIPrincipal* aPrincipal,
@ -91,8 +91,7 @@ public:
// changes have already been applied. This is the case for message manager
// messages which are used by ContentTask testing logic and webextensions.
static void
DispatchStorageEvent(StorageType aStorageType,
const nsAString& aDocumentURI,
DispatchStorageEvent(const nsAString& aDocumentURI,
const nsAString& aKey,
const nsAString& aOldValue,
const nsAString& aNewValue,
@ -117,11 +116,10 @@ protected:
private:
~LocalStorage();
friend class StorageManagerBase;
friend class LocalStorageManager;
friend class StorageCache;
nsCOMPtr<nsPIDOMWindowInner> mWindow;
RefPtr<StorageManagerBase> mManager;
RefPtr<LocalStorageManager> mManager;
RefPtr<StorageCache> mCache;
nsString mDocumentURI;

View File

@ -4,8 +4,8 @@
* 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/. */
#include "StorageManager.h"
#include "Storage.h"
#include "LocalStorageManager.h"
#include "LocalStorage.h"
#include "StorageDBThread.h"
#include "nsIScriptSecurityManager.h"
@ -35,12 +35,11 @@ int32_t gQuotaLimit = DEFAULT_QUOTA_LIMIT;
} // namespace
DOMLocalStorageManager*
DOMLocalStorageManager::sSelf = nullptr;
LocalStorageManager* LocalStorageManager::sSelf = nullptr;
// static
uint32_t
StorageManagerBase::GetQuota()
LocalStorageManager::GetQuota()
{
static bool preferencesInitialized = false;
if (!preferencesInitialized) {
@ -98,12 +97,11 @@ PrincipalsEqual(nsIPrincipal* aObjectPrincipal, nsIPrincipal* aSubjectPrincipal)
return aSubjectPrincipal->Equals(aObjectPrincipal);
}
NS_IMPL_ISUPPORTS(StorageManagerBase,
NS_IMPL_ISUPPORTS(LocalStorageManager,
nsIDOMStorageManager)
StorageManagerBase::StorageManagerBase(LocalStorage::StorageType aType)
LocalStorageManager::LocalStorageManager()
: mCaches(8)
, mType(aType)
, mLowDiskSpace(false)
{
StorageObserver* observer = StorageObserver::Self();
@ -112,21 +110,32 @@ StorageManagerBase::StorageManagerBase(LocalStorage::StorageType aType)
if (observer) {
observer->AddSink(this);
}
NS_ASSERTION(!sSelf, "Somebody is trying to do_CreateInstance(\"@mozilla/dom/localStorage-manager;1\"");
sSelf = this;
if (!XRE_IsParentProcess()) {
// Do this only on the child process. The thread IPC bridge
// is also used to communicate chrome observer notifications.
// Note: must be called after we set sSelf
StorageCache::StartDatabase();
}
}
StorageManagerBase::~StorageManagerBase()
LocalStorageManager::~LocalStorageManager()
{
StorageObserver* observer = StorageObserver::Self();
if (observer) {
observer->RemoveSink(this);
}
sSelf = nullptr;
}
namespace {
nsresult
AppendOriginNoSuffix(nsIPrincipal* aPrincipal,
nsACString& aKey)
AppendOriginNoSuffix(nsIPrincipal* aPrincipal, nsACString& aKey)
{
nsresult rv;
@ -217,8 +226,8 @@ CreateQuotaDBKey(nsIPrincipal* aPrincipal,
// static
nsCString
StorageManagerBase::CreateOrigin(const nsACString& aOriginSuffix,
const nsACString& aOriginNoSuffix)
LocalStorageManager::CreateOrigin(const nsACString& aOriginSuffix,
const nsACString& aOriginNoSuffix)
{
// Note: some hard-coded sqlite statements are dependent on the format this
// method returns. Changing this without updating those sqlite statements
@ -232,8 +241,8 @@ StorageManagerBase::CreateOrigin(const nsACString& aOriginSuffix,
}
StorageCache*
StorageManagerBase::GetCache(const nsACString& aOriginSuffix,
const nsACString& aOriginNoSuffix)
LocalStorageManager::GetCache(const nsACString& aOriginSuffix,
const nsACString& aOriginNoSuffix)
{
CacheOriginHashtable* table = mCaches.LookupOrAdd(aOriginSuffix);
StorageCacheHashKey* entry = table->GetEntry(aOriginNoSuffix);
@ -245,7 +254,7 @@ StorageManagerBase::GetCache(const nsACString& aOriginSuffix,
}
already_AddRefed<StorageUsage>
StorageManagerBase::GetOriginUsage(const nsACString& aOriginNoSuffix)
LocalStorageManager::GetOriginUsage(const nsACString& aOriginNoSuffix)
{
RefPtr<StorageUsage> usage;
if (mUsages.Get(aOriginNoSuffix, &usage)) {
@ -254,11 +263,9 @@ StorageManagerBase::GetOriginUsage(const nsACString& aOriginNoSuffix)
usage = new StorageUsage(aOriginNoSuffix);
if (mType == eLocalStorage) {
StorageDBBridge* db = StorageCache::StartDatabase();
if (db) {
db->AsyncGetUsage(usage);
}
StorageDBBridge* db = StorageCache::StartDatabase();
if (db) {
db->AsyncGetUsage(usage);
}
mUsages.Put(aOriginNoSuffix, usage);
@ -267,9 +274,9 @@ StorageManagerBase::GetOriginUsage(const nsACString& aOriginNoSuffix)
}
already_AddRefed<StorageCache>
StorageManagerBase::PutCache(const nsACString& aOriginSuffix,
const nsACString& aOriginNoSuffix,
nsIPrincipal* aPrincipal)
LocalStorageManager::PutCache(const nsACString& aOriginSuffix,
const nsACString& aOriginNoSuffix,
nsIPrincipal* aPrincipal)
{
CacheOriginHashtable* table = mCaches.LookupOrAdd(aOriginSuffix);
StorageCacheHashKey* entry = table->PutEntry(aOriginNoSuffix);
@ -278,27 +285,13 @@ StorageManagerBase::PutCache(const nsACString& aOriginSuffix,
nsAutoCString quotaOrigin;
CreateQuotaDBKey(aPrincipal, quotaOrigin);
switch (mType) {
case eSessionStorage:
// Lifetime handled by the manager, don't persist
entry->HardRef();
cache->Init(this, false, aPrincipal, quotaOrigin);
break;
case eLocalStorage:
// Lifetime handled by the cache, do persist
cache->Init(this, true, aPrincipal, quotaOrigin);
break;
default:
MOZ_ASSERT(false);
}
// Lifetime handled by the cache, do persist
cache->Init(this, true, aPrincipal, quotaOrigin);
return cache.forget();
}
void
StorageManagerBase::DropCache(StorageCache* aCache)
LocalStorageManager::DropCache(StorageCache* aCache)
{
if (!NS_IsMainThread()) {
NS_WARNING("StorageManager::DropCache called on a non-main thread, shutting down?");
@ -309,12 +302,12 @@ StorageManagerBase::DropCache(StorageCache* aCache)
}
nsresult
StorageManagerBase::GetStorageInternal(CreateMode aCreateMode,
mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal,
const nsAString& aDocumentURI,
bool aPrivate,
nsIDOMStorage** aRetval)
LocalStorageManager::GetStorageInternal(CreateMode aCreateMode,
mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal,
const nsAString& aDocumentURI,
bool aPrivate,
nsIDOMStorage** aRetval)
{
nsresult rv;
@ -341,7 +334,7 @@ StorageManagerBase::GetStorageInternal(CreateMode aCreateMode,
// no data stored, bypass creation and preload of the cache.
StorageDBBridge* db = StorageCache::GetDatabase();
if (db) {
if (!db->ShouldPreloadOrigin(StorageManagerBase::CreateOrigin(originAttrSuffix, originKey))) {
if (!db->ShouldPreloadOrigin(LocalStorageManager::CreateOrigin(originAttrSuffix, originKey))) {
return NS_OK;
}
} else {
@ -354,10 +347,6 @@ StorageManagerBase::GetStorageInternal(CreateMode aCreateMode,
// There is always a single instance of a cache per scope
// in a single instance of a DOM storage manager.
cache = PutCache(originAttrSuffix, originKey, aPrincipal);
} else if (mType == eSessionStorage) {
if (!cache->CheckPrincipal(aPrincipal)) {
return NS_ERROR_DOM_SECURITY_ERR;
}
}
if (aRetval) {
@ -372,70 +361,45 @@ StorageManagerBase::GetStorageInternal(CreateMode aCreateMode,
}
NS_IMETHODIMP
StorageManagerBase::PrecacheStorage(nsIPrincipal* aPrincipal,
nsIDOMStorage** aRetval)
LocalStorageManager::PrecacheStorage(nsIPrincipal* aPrincipal,
nsIDOMStorage** aRetval)
{
return GetStorageInternal(CreateMode::CreateIfShouldPreload, nullptr,
aPrincipal, EmptyString(), false, aRetval);
}
NS_IMETHODIMP
StorageManagerBase::CreateStorage(mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal,
const nsAString& aDocumentURI,
bool aPrivate,
nsIDOMStorage** aRetval)
LocalStorageManager::CreateStorage(mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal,
const nsAString& aDocumentURI,
bool aPrivate,
nsIDOMStorage** aRetval)
{
return GetStorageInternal(CreateMode::CreateAlways, aWindow, aPrincipal,
aDocumentURI, aPrivate, aRetval);
}
NS_IMETHODIMP
StorageManagerBase::GetStorage(mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal,
bool aPrivate,
nsIDOMStorage** aRetval)
LocalStorageManager::GetStorage(mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal,
bool aPrivate,
nsIDOMStorage** aRetval)
{
return GetStorageInternal(CreateMode::UseIfExistsNeverCreate, aWindow,
aPrincipal, EmptyString(), aPrivate, aRetval);
}
NS_IMETHODIMP
StorageManagerBase::CloneStorage(nsIDOMStorage* aStorage)
LocalStorageManager::CloneStorage(nsIDOMStorage* aStorage)
{
if (mType != eSessionStorage) {
// Cloning is supported only for sessionStorage
return NS_ERROR_NOT_IMPLEMENTED;
}
RefPtr<LocalStorage> storage = static_cast<LocalStorage*>(aStorage);
if (!storage) {
return NS_ERROR_UNEXPECTED;
}
const StorageCache* origCache = storage->GetCache();
StorageCache* existingCache = GetCache(origCache->OriginSuffix(),
origCache->OriginNoSuffix());
if (existingCache) {
// Do not replace an existing sessionStorage.
return NS_ERROR_NOT_AVAILABLE;
}
// Since this manager is sessionStorage manager, PutCache hard references
// the cache in our hashtable.
RefPtr<StorageCache> newCache = PutCache(origCache->OriginSuffix(),
origCache->OriginNoSuffix(),
origCache->Principal());
newCache->CloneFrom(origCache);
return NS_OK;
// Cloning is supported only for sessionStorage
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
StorageManagerBase::CheckStorage(nsIPrincipal* aPrincipal,
nsIDOMStorage* aStorage,
bool* aRetval)
LocalStorageManager::CheckStorage(nsIPrincipal* aPrincipal,
nsIDOMStorage* aStorage,
bool* aRetval)
{
nsresult rv;
@ -475,22 +439,18 @@ StorageManagerBase::CheckStorage(nsIPrincipal* aPrincipal,
// Obsolete nsIDOMStorageManager methods
NS_IMETHODIMP
StorageManagerBase::GetLocalStorageForPrincipal(nsIPrincipal* aPrincipal,
const nsAString& aDocumentURI,
bool aPrivate,
nsIDOMStorage** aRetval)
LocalStorageManager::GetLocalStorageForPrincipal(nsIPrincipal* aPrincipal,
const nsAString& aDocumentURI,
bool aPrivate,
nsIDOMStorage** aRetval)
{
if (mType != eLocalStorage) {
return NS_ERROR_UNEXPECTED;
}
return CreateStorage(nullptr, aPrincipal, aDocumentURI, aPrivate, aRetval);
}
void
StorageManagerBase::ClearCaches(uint32_t aUnloadFlags,
const OriginAttributesPattern& aPattern,
const nsACString& aOriginScope)
LocalStorageManager::ClearCaches(uint32_t aUnloadFlags,
const OriginAttributesPattern& aPattern,
const nsACString& aOriginScope)
{
for (auto iter1 = mCaches.Iter(); !iter1.Done(); iter1.Next()) {
OriginAttributes oa;
@ -515,9 +475,9 @@ StorageManagerBase::ClearCaches(uint32_t aUnloadFlags,
}
nsresult
StorageManagerBase::Observe(const char* aTopic,
const nsAString& aOriginAttributesPattern,
const nsACString& aOriginScope)
LocalStorageManager::Observe(const char* aTopic,
const nsAString& aOriginAttributesPattern,
const nsACString& aOriginScope)
{
OriginAttributesPattern pattern;
if (!pattern.Init(aOriginAttributesPattern)) {
@ -553,11 +513,6 @@ StorageManagerBase::Observe(const char* aTopic,
// Clear localStorage data beloging to an origin pattern
if (!strcmp(aTopic, "origin-attr-pattern-cleared")) {
// sessionStorage is expected to stay
if (mType == eSessionStorage) {
return NS_OK;
}
ClearCaches(StorageCache::kUnloadComplete, pattern, EmptyCString());
return NS_OK;
}
@ -570,27 +525,17 @@ StorageManagerBase::Observe(const char* aTopic,
}
if (!strcmp(aTopic, "low-disk-space")) {
if (mType == eLocalStorage) {
mLowDiskSpace = true;
}
mLowDiskSpace = true;
return NS_OK;
}
if (!strcmp(aTopic, "no-low-disk-space")) {
if (mType == eLocalStorage) {
mLowDiskSpace = false;
}
mLowDiskSpace = false;
return NS_OK;
}
#ifdef DOM_STORAGE_TESTS
if (!strcmp(aTopic, "test-reload")) {
if (mType != eLocalStorage) {
return NS_OK;
}
// This immediately completely reloads all caches from the database.
ClearCaches(StorageCache::kTestReload, pattern, EmptyCString());
return NS_OK;
@ -612,29 +557,8 @@ StorageManagerBase::Observe(const char* aTopic,
return NS_ERROR_UNEXPECTED;
}
// DOMLocalStorageManager
DOMLocalStorageManager::DOMLocalStorageManager()
: StorageManagerBase(eLocalStorage)
{
NS_ASSERTION(!sSelf, "Somebody is trying to do_CreateInstance(\"@mozilla/dom/localStorage-manager;1\"");
sSelf = this;
if (!XRE_IsParentProcess()) {
// Do this only on the child process. The thread IPC bridge
// is also used to communicate chrome observer notifications.
// Note: must be called after we set sSelf
StorageCache::StartDatabase();
}
}
DOMLocalStorageManager::~DOMLocalStorageManager()
{
sSelf = nullptr;
}
DOMLocalStorageManager*
DOMLocalStorageManager::Ensure()
LocalStorageManager*
LocalStorageManager::Ensure()
{
if (sSelf) {
return sSelf;

View File

@ -25,18 +25,13 @@ class OriginAttributesPattern;
namespace dom {
const LocalStorage::StorageType eSessionStorage = LocalStorage::eSessionStorage;
const LocalStorage::StorageType eLocalStorage = LocalStorage::eLocalStorage;
class StorageManagerBase : public nsIDOMStorageManager
, public StorageObserverSink
class LocalStorageManager final : public nsIDOMStorageManager
, public StorageObserverSink
{
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMSTORAGEMANAGER
public:
virtual LocalStorage::StorageType Type() { return mType; }
// Reads the preference for DOM storage quota
static uint32_t GetQuota();
// Gets (but not ensures) cache for the given scope
@ -48,15 +43,14 @@ public:
static nsCString CreateOrigin(const nsACString& aOriginSuffix,
const nsACString& aOriginNoSuffix);
protected:
explicit StorageManagerBase(LocalStorage::StorageType aType);
virtual ~StorageManagerBase();
private:
LocalStorageManager();
~LocalStorageManager();
// StorageObserverSink, handler to various chrome clearing notification
virtual nsresult Observe(const char* aTopic,
const nsAString& aOriginAttributesPattern,
const nsACString& aOriginScope) override;
nsresult Observe(const char* aTopic,
const nsAString& aOriginAttributesPattern,
const nsACString& aOriginScope) override;
// Since nsTHashtable doesn't like multiple inheritance, we have to aggregate
// StorageCache into the entry.
@ -112,8 +106,6 @@ private:
typedef nsTHashtable<StorageCacheHashKey> CacheOriginHashtable;
nsClassHashtable<nsCStringHashKey, CacheOriginHashtable> mCaches;
const LocalStorage::StorageType mType;
// If mLowDiskSpace is true it indicates a low device storage situation and
// so no localStorage writes are allowed. sessionStorage writes are still
// allowed.
@ -124,35 +116,21 @@ private:
const OriginAttributesPattern& aPattern,
const nsACString& aKeyPrefix);
protected:
// Global getter of localStorage manager service
static LocalStorageManager* Self() { return sSelf; }
// Like Self, but creates an instance if we're not yet initialized.
static LocalStorageManager* Ensure();
private:
// Keeps usage cache objects for eTLD+1 scopes we have touched.
nsDataHashtable<nsCStringHashKey, RefPtr<StorageUsage> > mUsages;
friend class StorageCache;
// Releases cache since it is no longer referrered by any Storage object.
virtual void DropCache(StorageCache* aCache);
};
// Derived classes to allow two different contract ids, one for localStorage and
// one for sessionStorage management. localStorage manager is used as service
// scoped to the application while sessionStorage managers are instantiated by
// each top doc shell in the application since sessionStorages are isolated per
// top level browsing context. The code may easily by shared by both.
class DOMLocalStorageManager final : public StorageManagerBase
{
public:
DOMLocalStorageManager();
virtual ~DOMLocalStorageManager();
// Global getter of localStorage manager service
static DOMLocalStorageManager* Self() { return sSelf; }
// Like Self, but creates an instance if we're not yet initialized.
static DOMLocalStorageManager* Ensure();
private:
static DOMLocalStorageManager* sSelf;
static LocalStorageManager* sSelf;
};
} // namespace dom

View File

@ -6,7 +6,6 @@
#include "SessionStorage.h"
#include "SessionStorageManager.h"
#include "StorageManager.h"
#include "mozilla/dom/StorageBinding.h"
#include "mozilla/Preferences.h"
@ -296,7 +295,7 @@ SessionStorageCache::ProcessUsageDelta(int64_t aDelta)
{
// Check limit per this origin
uint64_t newOriginUsage = mOriginQuotaUsage + aDelta;
if (aDelta > 0 && newOriginUsage > StorageManagerBase::GetQuota()) {
if (aDelta > 0 && newOriginUsage > LocalStorageManager::GetQuota()) {
return false;
}

View File

@ -9,7 +9,7 @@
#include "Storage.h"
#include "StorageDBThread.h"
#include "StorageIPC.h"
#include "StorageManager.h"
#include "LocalStorageManager.h"
#include "nsAutoPtr.h"
#include "nsDOMString.h"
@ -122,7 +122,7 @@ StorageCache::Release(void)
}
void
StorageCache::Init(StorageManagerBase* aManager,
StorageCache::Init(LocalStorageManager* aManager,
bool aPersistent,
nsIPrincipal* aPrincipal,
const nsACString& aQuotaOriginScope)
@ -166,7 +166,7 @@ StorageCache::Persist(const LocalStorage* aStorage) const
const nsCString
StorageCache::Origin() const
{
return StorageManagerBase::CreateOrigin(mOriginSuffix, mOriginNoSuffix);
return LocalStorageManager::CreateOrigin(mOriginSuffix, mOriginNoSuffix);
}
StorageCache::Data&
@ -218,7 +218,7 @@ StorageCache::ProcessUsageDelta(uint32_t aGetDataSetIndex, const int64_t aDelta,
Data& data = mData[aGetDataSetIndex];
uint64_t newOriginUsage = data.mOriginQuotaUsage + aDelta;
if (aSource == ContentMutation &&
aDelta > 0 && newOriginUsage > StorageManagerBase::GetQuota()) {
aDelta > 0 && newOriginUsage > LocalStorageManager::GetQuota()) {
return false;
}
@ -691,7 +691,7 @@ StorageUsage::CheckAndSetETLD1UsageDelta(uint32_t aDataSetIndex,
int64_t newUsage = mUsage[aDataSetIndex] + aDelta;
if (aSource == StorageCache::ContentMutation &&
aDelta > 0 && newUsage > StorageManagerBase::GetQuota()) {
aDelta > 0 && newUsage > LocalStorageManager::GetQuota()) {
return false;
}
@ -721,11 +721,11 @@ StorageCache::StartDatabase()
sDatabase = db.forget();
} else {
// Use DOMLocalStorageManager::Ensure in case we're called from
// Use LocalStorageManager::Ensure in case we're called from
// DOMSessionStorageManager's initializer and we haven't yet initialized the
// local storage manager.
RefPtr<StorageDBChild> db = new StorageDBChild(
DOMLocalStorageManager::Ensure());
LocalStorageManager::Ensure());
nsresult rv = db->Init();
if (NS_FAILED(rv)) {

View File

@ -21,8 +21,8 @@ namespace mozilla {
namespace dom {
class LocalStorage;
class LocalStorageManager;
class StorageUsage;
class StorageManagerBase;
class StorageDBBridge;
// Interface class on which only the database or IPC may call.
@ -103,7 +103,7 @@ protected:
virtual ~StorageCache();
public:
void Init(StorageManagerBase* aManager, bool aPersistent,
void Init(LocalStorageManager* aManager, bool aPersistent,
nsIPrincipal* aPrincipal, const nsACString& aQuotaOriginScope);
// Copies all data from the other storage.
@ -174,7 +174,7 @@ public:
private:
// API to clear the cache data, this is invoked by chrome operations
// like cookie deletion.
friend class StorageManagerBase;
friend class LocalStorageManager;
static const uint32_t kUnloadDefault = 1 << 0;
static const uint32_t kUnloadPrivate = 1 << 1;
@ -218,7 +218,7 @@ private:
// cache) we need to refer our manager since removal of the cache from the
// hash table is handled in the destructor by call to the manager. Cache
// could potentially overlive the manager, hence the hard ref.
RefPtr<StorageManagerBase> mManager;
RefPtr<LocalStorageManager> mManager;
// Reference to the usage counter object we check on for eTLD+1 quota limit.
// Obtained from the manager during initialization (Init method).

View File

@ -7,7 +7,7 @@
#include "StorageDBThread.h"
#include "StorageDBUpdater.h"
#include "StorageCache.h"
#include "StorageManager.h"
#include "LocalStorageManager.h"
#include "nsIEffectiveTLDService.h"
#include "nsDirectoryServiceUtils.h"

View File

@ -4,7 +4,7 @@
* 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/. */
#include "StorageManager.h"
#include "LocalStorageManager.h"
#include "mozIStorageBindingParamsArray.h"
#include "mozIStorageBindingParams.h"

View File

@ -6,7 +6,7 @@
#include "StorageIPC.h"
#include "StorageManager.h"
#include "LocalStorageManager.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ContentParent.h"
@ -56,7 +56,7 @@ StorageDBChild::ReleaseIPDLReference()
Release();
}
StorageDBChild::StorageDBChild(DOMLocalStorageManager* aManager)
StorageDBChild::StorageDBChild(LocalStorageManager* aManager)
: mManager(aManager)
, mStatus(NS_OK)
, mIPCOpen(false)
@ -452,7 +452,7 @@ public:
virtual const nsCString Origin() const
{
return StorageManagerBase::CreateOrigin(mSuffix, mOrigin);
return LocalStorageManager::CreateOrigin(mSuffix, mOrigin);
}
virtual const nsCString& OriginNoSuffix() const { return mOrigin; }
virtual const nsCString& OriginSuffix() const { return mSuffix; }
@ -698,7 +698,7 @@ private:
const nsCString
StorageDBParent::CacheParentBridge::Origin() const
{
return StorageManagerBase::CreateOrigin(mOriginSuffix, mOriginNoSuffix);
return LocalStorageManager::CreateOrigin(mOriginSuffix, mOriginNoSuffix);
}
bool

View File

@ -21,7 +21,7 @@ class OriginAttributesPattern;
namespace dom {
class DOMLocalStorageManager;
class LocalStorageManager;
// Child side of the IPC protocol, exposes as DB interface but
// is responsible to send all requests to the parent process
@ -33,7 +33,7 @@ class StorageDBChild final : public StorageDBBridge
virtual ~StorageDBChild();
public:
explicit StorageDBChild(DOMLocalStorageManager* aManager);
explicit StorageDBChild(LocalStorageManager* aManager);
NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
NS_IMETHOD_(MozExternalRefCountType) Release(void);
@ -100,7 +100,7 @@ private:
NS_DECL_OWNINGTHREAD
// Held to get caches to forward answers to.
RefPtr<DOMLocalStorageManager> mManager;
RefPtr<LocalStorageManager> mManager;
// Origins having data hash, for optimization purposes only
nsAutoPtr<nsTHashtable<nsCStringHashKey>> mOriginsHavingData;

View File

@ -8,6 +8,7 @@ with Files("**"):
BUG_COMPONENT = ("Core", "DOM")
EXPORTS.mozilla.dom += [
'LocalStorageManager.h',
'SessionStorageManager.h',
'Storage.h',
'StorageIPC.h',
@ -15,6 +16,7 @@ EXPORTS.mozilla.dom += [
UNIFIED_SOURCES += [
'LocalStorage.cpp',
'LocalStorageManager.cpp',
'SessionStorage.cpp',
'SessionStorageManager.cpp',
'Storage.cpp',
@ -22,7 +24,6 @@ UNIFIED_SOURCES += [
'StorageDBThread.cpp',
'StorageDBUpdater.cpp',
'StorageIPC.cpp',
'StorageManager.cpp',
'StorageObserver.cpp',
'StorageUtils.cpp',
]

View File

@ -76,12 +76,12 @@
#include "nsJSProtocolHandler.h"
#include "nsScriptNameSpaceManager.h"
#include "nsIControllerContext.h"
#include "StorageManager.h"
#include "nsJSON.h"
#include "nsZipArchive.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/DOMException.h"
#include "mozilla/dom/DOMRequest.h"
#include "mozilla/dom/LocalStorageManager.h"
#include "mozilla/dom/network/UDPSocketChild.h"
#include "mozilla/dom/quota/QuotaManagerService.h"
#include "mozilla/dom/SessionStorageManager.h"
@ -257,8 +257,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(FormData)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHostObjectURI)
NS_GENERIC_FACTORY_CONSTRUCTOR(DOMParser)
NS_GENERIC_FACTORY_CONSTRUCTOR(Exception)
NS_GENERIC_FACTORY_CONSTRUCTOR(LocalStorageManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(SessionStorageManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(DOMLocalStorageManager)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(DOMRequestService,
DOMRequestService::FactoryCreate)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(QuotaManagerService,
@ -918,7 +918,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kNS_DOMPARSER_CID, false, nullptr, DOMParserConstructor },
{ &kNS_XPCEXCEPTION_CID, false, nullptr, ExceptionConstructor },
{ &kNS_DOMSESSIONSTORAGEMANAGER_CID, false, nullptr, SessionStorageManagerConstructor },
{ &kNS_DOMLOCALSTORAGEMANAGER_CID, false, nullptr, DOMLocalStorageManagerConstructor },
{ &kNS_DOMLOCALSTORAGEMANAGER_CID, false, nullptr, LocalStorageManagerConstructor },
{ &kNS_DOMJSON_CID, false, nullptr, NS_NewJSON },
{ &kNS_TEXTEDITOR_CID, false, nullptr, TextEditorConstructor },
{ &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor },