Bug 1322316 - Split SessionStorage and LocalStorage implementation - part 4 - Rename StorageManagerBase to LocalStorageManager, r=asuth
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 17 May 2017 07:01:14 +0200
changeset 358633 d6d373c78235d36229ef3b355fbaefa48d6dfa05
parent 358632 1d7d7228924b539e2e771c7d0a64e0db6e94aac6
child 358634 fc8021ded92b04ded69778a7b1f2857bb7f61741
push id90362
push useramarchesini@mozilla.com
push dateWed, 17 May 2017 05:03:33 +0000
treeherdermozilla-inbound@2f47ba116b42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1322316
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1322316 - Split SessionStorage and LocalStorage implementation - part 4 - Rename StorageManagerBase to LocalStorageManager, r=asuth
dom/storage/LocalStorage.cpp
dom/storage/LocalStorage.h
dom/storage/LocalStorageManager.cpp
dom/storage/LocalStorageManager.h
dom/storage/SessionStorage.cpp
dom/storage/StorageCache.cpp
dom/storage/StorageCache.h
dom/storage/StorageDBThread.cpp
dom/storage/StorageDBUpdater.cpp
dom/storage/StorageIPC.cpp
dom/storage/StorageIPC.h
dom/storage/StorageManager.cpp
dom/storage/StorageManager.h
dom/storage/moz.build
layout/build/nsLayoutModule.cpp
--- a/dom/storage/LocalStorage.cpp
+++ b/dom/storage/LocalStorage.cpp
@@ -1,17 +1,17 @@
 /* -*- 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 http://mozilla.org/MPL/2.0/. */
 
 #include "LocalStorage.h"
+#include "LocalStorageManager.h"
 #include "StorageCache.h"
-#include "StorageManager.h"
 
 #include "nsIObserverService.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIPermissionManager.h"
 #include "nsIPrincipal.h"
 #include "nsICookiePermission.h"
 
 #include "mozilla/dom/ContentChild.h"
@@ -38,17 +38,17 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(Local
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(LocalStorage)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END_INHERITING(Storage)
 
 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,
                            bool aIsPrivate)
   : Storage(aWindow, aPrincipal)
   , mManager(aManager)
   , mCache(aCache)
   , mDocumentURI(aDocumentURI)
@@ -174,70 +174,66 @@ LocalStorage::Clear(nsIPrincipal& aSubje
   }
 }
 
 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)
   { }
 
   NS_DECL_NSIRUNNABLE
 
 private:
   nsCOMPtr<nsISupports> mSubject;
-  const char16_t* mType;
   const bool mPrivateBrowsing;
 };
 
 NS_IMETHODIMP
 StorageNotifierRunnable::Run()
 {
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
   if (observerService) {
     observerService->NotifyObservers(mSubject,
                                      mPrivateBrowsing
                                        ? "dom-private-storage2-changed"
                                        : "dom-storage2-changed",
-                                     mType);
+                                     u"localStorage");
   }
   return NS_OK;
 }
 
 } // namespace
 
 void
 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();
     Unused << NS_WARN_IF(!cc->SendBroadcastLocalStorageChange(
       mDocumentURI, nsString(aKey), nsString(aOldValue), nsString(aNewValue),
       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,
                                    nsIPrincipal* aPrincipal,
                                    bool aIsPrivate,
                                    Storage* aStorage,
                                    bool aImmediateDispatch)
 {
@@ -253,31 +249,27 @@ LocalStorage::DispatchStorageEvent(Stora
   // Note, this DOM event should never reach JS. It is cloned later in
   // nsGlobalWindow.
   RefPtr<StorageEvent> event =
     StorageEvent::Constructor(nullptr, NS_LITERAL_STRING("storage"), dict);
 
   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();
   } else {
     NS_DispatchToMainThread(r);
   }
 
   // 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),
         nsString(aNewValue), IPC::Principal(aPrincipal), aIsPrivate);
     }
   }
 }
 
@@ -330,22 +322,16 @@ LocalStorage::CanUseStorage(nsIPrincipal
   if (access == nsContentUtils::StorageAccess::eDeny) {
     return false;
   }
 
   mIsSessionOnly = access <= nsContentUtils::StorageAccess::eSessionScoped;
   return CanAccess(&aSubjectPrincipal);
 }
 
-LocalStorage::StorageType
-LocalStorage::GetType() const
-{
-  return mManager->Type();
-}
-
 // Defined in StorageManager.cpp
 extern bool
 PrincipalsEqual(nsIPrincipal* aObjectPrincipal,
                 nsIPrincipal* aSubjectPrincipal);
 
 bool
 LocalStorage::PrincipalEquals(nsIPrincipal* aPrincipal)
 {
--- a/dom/storage/LocalStorage.h
+++ b/dom/storage/LocalStorage.h
@@ -8,43 +8,43 @@
 #define mozilla_dom_LocalStorage_h
 
 #include "Storage.h"
 #include "nsWeakReference.h"
 
 namespace mozilla {
 namespace dom {
 
-class StorageManagerBase;
+class LocalStorageManager;
 class StorageCache;
 class StorageEvent;
 
 class LocalStorage final : public Storage
                          , public nsSupportsWeakReference
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(LocalStorage, Storage)
 
   StorageType Type() const override { return eLocalStorage; }
 
-  StorageManagerBase* GetManager() const
+  LocalStorageManager* GetManager() const
   {
     return mManager;
   }
 
   StorageCache const* GetCache() const
   {
     return mCache;
   }
 
   bool PrincipalEquals(nsIPrincipal* aPrincipal);
 
   LocalStorage(nsPIDOMWindowInner* aWindow,
-               StorageManagerBase* aManager,
+               LocalStorageManager* aManager,
                StorageCache* aCache,
                const nsAString& aDocumentURI,
                nsIPrincipal* aPrincipal,
                bool aIsPrivate);
 
   // WebIDL
 
   int64_t GetOriginQuotaUsage() const override;
@@ -86,18 +86,17 @@ public:
   //
   // aImmediateDispatch is for use by (main-thread) IPC code so that PContent
   // ordering can be maintained.  Without this, the event would be enqueued and
   // run in a future turn of the event loop, potentially allowing other PContent
   // Recv* methods to trigger script that wants to assume our localstorage
   // 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,
                        nsIPrincipal* aPrincipal,
                        bool aIsPrivate,
                        Storage* aStorage,
                        bool aImmediateDispatch);
 
@@ -112,21 +111,20 @@ protected:
   // It is an optimization since the privileges check and session only
   // state determination are complex and share the code (comes hand in
   // hand together).
   bool CanUseStorage(nsIPrincipal& aSubjectPrincipal);
 
 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;
 
   // Principal this Storage (i.e. localStorage or sessionStorage) has
   // been created for
   nsCOMPtr<nsIPrincipal> mPrincipal;
 
   // Whether this storage is running in private-browsing window.
rename from dom/storage/StorageManager.cpp
rename to dom/storage/LocalStorageManager.cpp
--- a/dom/storage/StorageManager.cpp
+++ b/dom/storage/LocalStorageManager.cpp
@@ -1,16 +1,16 @@
 /* -*- 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 http://mozilla.org/MPL/2.0/. */
 
-#include "StorageManager.h"
-#include "Storage.h"
+#include "LocalStorageManager.h"
+#include "LocalStorage.h"
 #include "StorageDBThread.h"
 
 #include "nsIScriptSecurityManager.h"
 #include "nsIEffectiveTLDService.h"
 
 #include "nsNetUtil.h"
 #include "nsNetCID.h"
 #include "nsIURL.h"
@@ -30,22 +30,21 @@ namespace mozilla {
 namespace dom {
 
 namespace {
 
 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) {
     mozilla::Preferences::AddIntVarCache(&gQuotaLimit,
                                          "dom.storage.default_quota",
                                          DEFAULT_QUOTA_LIMIT);
     preferencesInitialized = true;
   }
@@ -93,45 +92,55 @@ PrincipalsEqual(nsIPrincipal* aObjectPri
 
   if (!aObjectPrincipal) {
     return false;
   }
 
   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();
   NS_ASSERTION(observer, "No StorageObserver, cannot observe private data delete notifications!");
 
   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;
 
   nsCOMPtr<nsIURI> uri;
   rv = aPrincipal->GetURI(getter_AddRefs(uri));
   NS_ENSURE_SUCCESS(rv, rv);
   if (!uri) {
     return NS_ERROR_UNEXPECTED;
@@ -212,114 +221,98 @@ CreateQuotaDBKey(nsIPrincipal* aPrincipa
 
   return NS_OK;
 }
 
 } // namespace
 
 // 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
   // will cause malfunction.
 
   nsAutoCString scope;
   scope.Append(aOriginSuffix);
   scope.Append(':');
   scope.Append(aOriginNoSuffix);
   return scope;
 }
 
 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);
   if (!entry) {
     return nullptr;
   }
 
   return entry->cache();
 }
 
 already_AddRefed<StorageUsage>
-StorageManagerBase::GetOriginUsage(const nsACString& aOriginNoSuffix)
+LocalStorageManager::GetOriginUsage(const nsACString& aOriginNoSuffix)
 {
   RefPtr<StorageUsage> usage;
   if (mUsages.Get(aOriginNoSuffix, &usage)) {
     return usage.forget();
   }
 
   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);
 
   return usage.forget();
 }
 
 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);
   RefPtr<StorageCache> cache = entry->cache();
 
   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?");
   }
 
   CacheOriginHashtable* table = mCaches.LookupOrAdd(aCache->OriginSuffix());
   table->RemoveEntry(aCache->OriginNoSuffix());
 }
 
 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;
 
   nsAutoCString originAttrSuffix;
   aPrincipal->OriginAttributesRef().CreateSuffix(originAttrSuffix);
 
   nsAutoCString originKey;
   rv = AppendOriginNoSuffix(aPrincipal, originKey);
@@ -336,111 +329,82 @@ StorageManagerBase::GetStorageInternal(C
       return NS_OK;
     }
 
     if (aCreateMode == CreateMode::CreateIfShouldPreload) {
       // This is a demand to just preload the cache, if the scope has
       // 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 {
         if (originKey.EqualsLiteral("knalb.:about")) {
           return NS_OK;
         }
       }
     }
 
     // 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) {
     nsCOMPtr<nsPIDOMWindowInner> inner = nsPIDOMWindowInner::From(aWindow);
 
     nsCOMPtr<nsIDOMStorage> storage = new LocalStorage(
       inner, this, cache, aDocumentURI, aPrincipal, aPrivate);
     storage.forget(aRetval);
   }
 
   return NS_OK;
 }
 
 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;
 
   RefPtr<LocalStorage> storage = static_cast<LocalStorage*>(aStorage);
   if (!storage) {
     return NS_ERROR_UNEXPECTED;
   }
 
@@ -470,32 +434,28 @@ StorageManagerBase::CheckStorage(nsIPrin
 
   *aRetval = true;
   return NS_OK;
 }
 
 // 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;
     DebugOnly<bool> rv = oa.PopulateFromSuffix(iter1.Key());
     MOZ_ASSERT(rv);
     if (!aPattern.Matches(oa)) {
       // This table doesn't match the given origin attributes pattern
       continue;
@@ -510,19 +470,19 @@ StorageManagerBase::ClearCaches(uint32_t
           StringBeginsWith(cache->OriginNoSuffix(), aOriginScope)) {
         cache->UnloadItems(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)) {
     NS_ERROR("Cannot parse origin attributes pattern");
     return NS_ERROR_FAILURE;
   }
 
   // Clear everything, caches + database
@@ -548,54 +508,39 @@ StorageManagerBase::Observe(const char* 
   // Clear all private-browsing caches
   if (!strcmp(aTopic, "private-browsing-data-cleared")) {
     ClearCaches(StorageCache::kUnloadPrivate, pattern, EmptyCString());
     return NS_OK;
   }
 
   // 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;
   }
 
   if (!strcmp(aTopic, "profile-change")) {
     // For case caches are still referenced - clear them completely
     ClearCaches(StorageCache::kUnloadComplete, pattern, EmptyCString());
     mCaches.Clear();
     return NS_OK;
   }
 
   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;
   }
 
   if (!strcmp(aTopic, "test-flushed")) {
     if (!XRE_IsParentProcess()) {
       nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
@@ -607,39 +552,18 @@ StorageManagerBase::Observe(const char* 
     return NS_OK;
   }
 #endif
 
   NS_ERROR("Unexpected topic");
   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;
   }
 
   // Cause sSelf to be populated.
   nsCOMPtr<nsIDOMStorageManager> initializer =
     do_GetService("@mozilla.org/dom/localStorage-manager;1");
rename from dom/storage/StorageManager.h
rename to dom/storage/LocalStorageManager.h
--- a/dom/storage/StorageManager.h
+++ b/dom/storage/LocalStorageManager.h
@@ -20,48 +20,42 @@
 #include "nsHashKeys.h"
 
 namespace mozilla {
 
 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
   StorageCache* GetCache(const nsACString& aOriginSuffix,
                          const nsACString& aOriginNoSuffix);
   // Returns object keeping usage cache for the scope.
   already_AddRefed<StorageUsage> GetOriginUsage(const nsACString& aOriginNoSuffix);
 
   static nsCString CreateOrigin(const nsACString& aOriginSuffix,
                                 const nsACString& aOriginNoSuffix);
 
-protected:
-  explicit StorageManagerBase(LocalStorage::StorageType aType);
-  virtual ~StorageManagerBase();
+private:
+  LocalStorageManager();
+  ~LocalStorageManager();
 
-private:
   // 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.
   class StorageCacheHashKey : public nsCStringHashKey
   {
   public:
     explicit StorageCacheHashKey(const nsACString* aKey)
       : nsCStringHashKey(aKey)
@@ -107,55 +101,39 @@ private:
                               const nsAString& aDocumentURI,
                               bool aPrivate,
                               nsIDOMStorage** aRetval);
 
   // Suffix->origin->cache map
   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.
   bool mLowDiskSpace;
   bool IsLowDiskSpace() const { return mLowDiskSpace; };
 
   void ClearCaches(uint32_t aUnloadFlags,
                    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
 } // namespace mozilla
 
 #endif // mozilla_dom_StorageManager_h
--- a/dom/storage/SessionStorage.cpp
+++ b/dom/storage/SessionStorage.cpp
@@ -1,17 +1,16 @@
 /* -*- 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 http://mozilla.org/MPL/2.0/. */
 
 #include "SessionStorage.h"
 #include "SessionStorageManager.h"
-#include "StorageManager.h"
 
 #include "mozilla/dom/StorageBinding.h"
 #include "mozilla/Preferences.h"
 #include "nsContentUtils.h"
 #include "nsIPrincipal.h"
 #include "nsPIDOMWindow.h"
 
 namespace mozilla {
@@ -291,17 +290,17 @@ SessionStorageCache::Clear()
   mKeys.Clear();
 }
 
 bool
 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;
   }
 
   // Update size in our data set
   mOriginQuotaUsage = newOriginUsage;
   return true;
 }
 
--- a/dom/storage/StorageCache.cpp
+++ b/dom/storage/StorageCache.cpp
@@ -4,17 +4,17 @@
  * 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 "StorageCache.h"
 
 #include "Storage.h"
 #include "StorageDBThread.h"
 #include "StorageIPC.h"
-#include "StorageManager.h"
+#include "LocalStorageManager.h"
 
 #include "nsAutoPtr.h"
 #include "nsDOMString.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/Unused.h"
 #include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 
@@ -117,17 +117,17 @@ StorageCache::Release(void)
   nsresult rv = NS_DispatchToMainThread(event);
   if (NS_FAILED(rv)) {
     NS_WARNING("StorageCache::Release() on a non-main thread");
     StorageCacheBridge::Release();
   }
 }
 
 void
-StorageCache::Init(StorageManagerBase* aManager,
+StorageCache::Init(LocalStorageManager* aManager,
                    bool aPersistent,
                    nsIPrincipal* aPrincipal,
                    const nsACString& aQuotaOriginScope)
 {
   if (mInitialized) {
     return;
   }
 
@@ -161,17 +161,17 @@ StorageCache::Persist(const LocalStorage
   return mPersistent &&
          !aStorage->IsSessionOnly() &&
          !aStorage->IsPrivate();
 }
 
 const nsCString
 StorageCache::Origin() const
 {
-  return StorageManagerBase::CreateOrigin(mOriginSuffix, mOriginNoSuffix);
+  return LocalStorageManager::CreateOrigin(mOriginSuffix, mOriginNoSuffix);
 }
 
 StorageCache::Data&
 StorageCache::DataSet(const LocalStorage* aStorage)
 {
   uint32_t index = GetDataSetIndex(aStorage);
 
   if (index == kSessionSet && !mSessionOnlyDataSetActive) {
@@ -213,17 +213,17 @@ StorageCache::ProcessUsageDelta(uint32_t
       aDelta > 0 && mManager && mManager->IsLowDiskSpace()) {
     return false;
   }
 
   // Check limit per this origin
   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;
   }
 
   // Now check eTLD+1 limit
   if (mUsage &&
       !mUsage->CheckAndSetETLD1UsageDelta(aGetDataSetIndex, aDelta, aSource)) {
     return false;
   }
@@ -686,17 +686,17 @@ StorageUsage::LoadUsage(const int64_t aU
 bool
 StorageUsage::CheckAndSetETLD1UsageDelta(uint32_t aDataSetIndex,
   const int64_t aDelta, const StorageCache::MutationSource aSource)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   int64_t newUsage = mUsage[aDataSetIndex] + aDelta;
   if (aSource == StorageCache::ContentMutation &&
-      aDelta > 0 && newUsage > StorageManagerBase::GetQuota()) {
+      aDelta > 0 && newUsage > LocalStorageManager::GetQuota()) {
     return false;
   }
 
   mUsage[aDataSetIndex] = newUsage;
   return true;
 }
 
 
@@ -716,21 +716,21 @@ StorageCache::StartDatabase()
 
     nsresult rv = db->Init();
     if (NS_FAILED(rv)) {
       return nullptr;
     }
 
     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)) {
       return nullptr;
     }
 
     db.forget(&sDatabase);
   }
--- a/dom/storage/StorageCache.h
+++ b/dom/storage/StorageCache.h
@@ -16,18 +16,18 @@
 #include "mozilla/Monitor.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Atomics.h"
 
 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.
 // Used to populate the cache with DB data.
 class StorageCacheBridge
 {
 public:
   NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
@@ -98,17 +98,17 @@ public:
   // StorageCacheHashKey's ctor is creating this class and
   // accepts reversed-origin-no-suffix as an argument - the hashing key.
   explicit StorageCache(const nsACString* aOriginNoSuffix);
 
 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.
   void CloneFrom(const StorageCache* aThat);
 
   // Get size of per-origin data.
   int64_t GetOriginQuotaUsage(const LocalStorage* aStorage) const;
 
@@ -169,17 +169,17 @@ public:
 
 public:
   // Number of data sets we keep: default, private, session
   static const uint32_t kDataSetCount = 3;
 
 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;
   static const uint32_t kUnloadSession = 1 << 2;
   static const uint32_t kUnloadComplete =
     kUnloadDefault | kUnloadPrivate | kUnloadSession;
 
 #ifdef DOM_STORAGE_TESTS
@@ -213,17 +213,17 @@ private:
   bool ProcessUsageDelta(const LocalStorage* aStorage, const int64_t aDelta,
                          const MutationSource aSource=ContentMutation);
 
 private:
   // When a cache is reponsible for its life time (in case of localStorage data
   // 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).
   RefPtr<StorageUsage> mUsage;
 
   // Principal the cache has been initially created for, this is used only for
   // sessionStorage access checks since sessionStorage objects are strictly
   // scoped by a principal. localStorage objects on the other hand are scoped
--- a/dom/storage/StorageDBThread.cpp
+++ b/dom/storage/StorageDBThread.cpp
@@ -2,17 +2,17 @@
 /* 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 http://mozilla.org/MPL/2.0/. */
 
 #include "StorageDBThread.h"
 #include "StorageDBUpdater.h"
 #include "StorageCache.h"
-#include "StorageManager.h"
+#include "LocalStorageManager.h"
 
 #include "nsIEffectiveTLDService.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsThreadUtils.h"
 #include "nsProxyRelease.h"
 #include "mozStorageCID.h"
 #include "mozStorageHelper.h"
--- a/dom/storage/StorageDBUpdater.cpp
+++ b/dom/storage/StorageDBUpdater.cpp
@@ -1,15 +1,15 @@
 /* -*- 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 http://mozilla.org/MPL/2.0/. */
 
-#include "StorageManager.h"
+#include "LocalStorageManager.h"
 
 #include "mozIStorageBindingParamsArray.h"
 #include "mozIStorageBindingParams.h"
 #include "mozIStorageValueArray.h"
 #include "mozIStorageFunction.h"
 #include "mozilla/BasePrincipal.h"
 #include "nsVariant.h"
 #include "mozilla/Services.h"
--- a/dom/storage/StorageIPC.cpp
+++ b/dom/storage/StorageIPC.cpp
@@ -1,17 +1,17 @@
 /* -*- 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 http://mozilla.org/MPL/2.0/. */
 
 #include "StorageIPC.h"
 
-#include "StorageManager.h"
+#include "LocalStorageManager.h"
 
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/Unused.h"
 #include "nsIDiskSpaceWatcher.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
@@ -51,17 +51,17 @@ StorageDBChild::AddIPDLReference()
 void
 StorageDBChild::ReleaseIPDLReference()
 {
   MOZ_ASSERT(mIPCOpen, "Attempting to release non-existent IPDL reference");
   mIPCOpen = false;
   Release();
 }
 
-StorageDBChild::StorageDBChild(DOMLocalStorageManager* aManager)
+StorageDBChild::StorageDBChild(LocalStorageManager* aManager)
   : mManager(aManager)
   , mStatus(NS_OK)
   , mIPCOpen(false)
 {
 }
 
 StorageDBChild::~StorageDBChild()
 {
@@ -447,17 +447,17 @@ public:
   , mLoadedCount(aAlreadyLoadedCount)
   {
     // Precaution
     *mRv = NS_ERROR_UNEXPECTED;
   }
 
   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; }
   virtual bool Loaded() { return mLoaded; }
   virtual uint32_t LoadedCount() { return mLoadedCount; }
   virtual bool LoadItem(const nsAString& aKey, const nsString& aValue)
   {
     // Called on the aCache background thread
@@ -693,17 +693,17 @@ private:
 
 } // namespace
 
 // StorageDBParent::CacheParentBridge
 
 const nsCString
 StorageDBParent::CacheParentBridge::Origin() const
 {
-  return StorageManagerBase::CreateOrigin(mOriginSuffix, mOriginNoSuffix);
+  return LocalStorageManager::CreateOrigin(mOriginSuffix, mOriginNoSuffix);
 }
 
 bool
 StorageDBParent::CacheParentBridge::LoadItem(const nsAString& aKey,
                                              const nsString& aValue)
 {
   if (mLoaded) {
     return false;
--- a/dom/storage/StorageIPC.h
+++ b/dom/storage/StorageIPC.h
@@ -16,29 +16,29 @@
 #include "nsAutoPtr.h"
 
 namespace mozilla {
 
 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
 // and expects asynchronous answers. Those are then transparently
 // forwarded back to consumers on the child process.
 class StorageDBChild final : public StorageDBBridge
                            , public PStorageChild
 {
   virtual ~StorageDBChild();
 
 public:
-  explicit StorageDBChild(DOMLocalStorageManager* aManager);
+  explicit StorageDBChild(LocalStorageManager* aManager);
 
   NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
   NS_IMETHOD_(MozExternalRefCountType) Release(void);
 
   void AddIPDLReference();
   void ReleaseIPDLReference();
 
   virtual nsresult Init();
@@ -95,17 +95,17 @@ private:
   mozilla::ipc::IPCResult RecvError(const nsresult& aRv);
 
   nsTHashtable<nsCStringHashKey>& OriginsHavingData();
 
   ThreadSafeAutoRefCnt mRefCnt;
   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;
 
   // List of caches waiting for preload.  This ensures the contract that
   // AsyncPreload call references the cache for time of the preload.
   nsTHashtable<nsRefPtrHashKey<StorageCacheBridge>> mLoadingCaches;
 
--- a/dom/storage/moz.build
+++ b/dom/storage/moz.build
@@ -3,31 +3,32 @@
 # 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/.
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "DOM")
 
 EXPORTS.mozilla.dom += [
+    'LocalStorageManager.h',
     'SessionStorageManager.h',
     'Storage.h',
     'StorageIPC.h',
 ]
 
 UNIFIED_SOURCES += [
     'LocalStorage.cpp',
+    'LocalStorageManager.cpp',
     'SessionStorage.cpp',
     'SessionStorageManager.cpp',
     'Storage.cpp',
     'StorageCache.cpp',
     'StorageDBThread.cpp',
     'StorageDBUpdater.cpp',
     'StorageIPC.cpp',
-    'StorageManager.cpp',
     'StorageObserver.cpp',
     'StorageUtils.cpp',
 ]
 
 IPDL_SOURCES += [
     'PStorage.ipdl',
 ]
 
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -71,22 +71,22 @@
 
 #include "mozilla/dom/FormData.h"
 #include "nsHostObjectURI.h"
 #include "nsGlobalWindowCommands.h"
 #include "nsIControllerCommandTable.h"
 #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"
 #include "mozilla/dom/workers/ServiceWorkerManager.h"
 #include "mozilla/dom/workers/WorkerDebuggerManager.h"
 #include "mozilla/dom/Notification.h"
 #include "mozilla/OSFileConstants.h"
 #include "mozilla/Services.h"
@@ -252,18 +252,18 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(txMozilla
 NS_GENERIC_FACTORY_CONSTRUCTOR(XPathEvaluator)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(txNodeSetAdaptor, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSerializer)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(XMLHttpRequestMainThread, Init)
 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,
                                          QuotaManagerService::FactoryCreate)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ServiceWorkerManager,
                                          ServiceWorkerManager::GetInstance)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(WorkerDebuggerManager,
                                          WorkerDebuggerManager::GetInstance)
@@ -913,17 +913,17 @@ static const mozilla::Module::CIDEntry k
   { &kTRANSFORMIIX_NODESET_CID, false, nullptr, txNodeSetAdaptorConstructor },
   { &kNS_XMLSERIALIZER_CID, false, nullptr, nsDOMSerializerConstructor },
   { &kNS_FORMDATA_CID, false, nullptr, FormDataConstructor },
   { &kNS_HOSTOBJECTURI_CID, false, nullptr, nsHostObjectURIConstructor },
   { &kNS_XMLHTTPREQUEST_CID, false, nullptr, XMLHttpRequestMainThreadConstructor },
   { &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 },
   { &kQUOTAMANAGER_SERVICE_CID, false, nullptr, QuotaManagerServiceConstructor },
   { &kSERVICEWORKERMANAGER_CID, false, nullptr, ServiceWorkerManagerConstructor },
   { &kNOTIFICATIONTELEMETRYSERVICE_CID, false, nullptr, NotificationTelemetryServiceConstructor },
   { &kPUSHNOTIFIER_CID, false, nullptr, PushNotifierConstructor },
   { &kWORKERDEBUGGERMANAGER_CID, true, nullptr, WorkerDebuggerManagerConstructor },