Bug 1322316 - Split SessionStorage and LocalStorage implementation - part 3 - SessionStorageManager, r=asuth
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 17 May 2017 07:01:14 +0200
changeset 409201 1d7d7228924b539e2e771c7d0a64e0db6e94aac6
parent 409200 d959241eaf7d41b9d391e2dfb027d9321a719b63
child 409202 d6d373c78235d36229ef3b355fbaefa48d6dfa05
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [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 3 - SessionStorageManager, r=asuth
dom/storage/LocalStorage.h
dom/storage/SessionStorage.cpp
dom/storage/SessionStorage.h
dom/storage/SessionStorageManager.cpp
dom/storage/SessionStorageManager.h
dom/storage/Storage.h
dom/storage/StorageManager.cpp
dom/storage/StorageManager.h
dom/storage/StorageUtils.cpp
dom/storage/StorageUtils.h
dom/storage/moz.build
layout/build/nsLayoutModule.cpp
--- a/dom/storage/LocalStorage.h
+++ b/dom/storage/LocalStorage.h
@@ -19,22 +19,17 @@ class StorageEvent;
 
 class LocalStorage final : public Storage
                          , public nsSupportsWeakReference
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(LocalStorage, Storage)
 
-  enum StorageType {
-    eLocalStorage = 1,
-    eSessionStorage = 2
-  };
-
-  StorageType GetType() const;
+  StorageType Type() const override { return eLocalStorage; }
 
   StorageManagerBase* GetManager() const
   {
     return mManager;
   }
 
   StorageCache const* GetCache() const
   {
--- a/dom/storage/SessionStorage.cpp
+++ b/dom/storage/SessionStorage.cpp
@@ -1,43 +1,67 @@
 /* -*- 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 {
 namespace dom {
 
 // ----------------------------------------------------------------------------
 // SessionStorage
 // ----------------------------------------------------------------------------
 
+NS_IMPL_CYCLE_COLLECTION_INHERITED(SessionStorage, Storage, mManager);
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SessionStorage)
+NS_INTERFACE_MAP_END_INHERITING(Storage)
+
+NS_IMPL_ADDREF_INHERITED(SessionStorage, Storage)
+NS_IMPL_RELEASE_INHERITED(SessionStorage, Storage)
+
 SessionStorage::SessionStorage(nsPIDOMWindowInner* aWindow,
                                nsIPrincipal* aPrincipal,
-                               SessionStorageCache* aCache)
+                               SessionStorageCache* aCache,
+                               SessionStorageManager* aManager,
+                               const nsAString& aDocumentURI,
+                               bool aIsPrivate)
   : Storage(aWindow, aPrincipal)
   , mCache(aCache)
+  , mManager(aManager)
+  , mDocumentURI(aDocumentURI)
+  , mIsPrivate(aIsPrivate)
 {
   MOZ_ASSERT(aCache);
 }
 
 SessionStorage::~SessionStorage()
 {
 }
 
+already_AddRefed<SessionStorage>
+SessionStorage::Clone() const
+{
+  RefPtr<SessionStorage> storage =
+    new SessionStorage(GetParentObject(), Principal(), mCache, mManager,
+                       mDocumentURI, mIsPrivate);
+  return storage.forget();
+}
+
 int64_t
 SessionStorage::GetOriginQuotaUsage() const
 {
   return mCache->GetOriginQuotaUsage();
 }
 
 uint32_t
 SessionStorage::GetLength(nsIPrincipal& aSubjectPrincipal,
@@ -276,10 +300,23 @@ SessionStorageCache::ProcessUsageDelta(i
     return false;
   }
 
   // Update size in our data set
   mOriginQuotaUsage = newOriginUsage;
   return true;
 }
 
+already_AddRefed<SessionStorageCache>
+SessionStorageCache::Clone() const
+{
+  RefPtr<SessionStorageCache> cache = new SessionStorageCache();
+  cache->mOriginQuotaUsage = mOriginQuotaUsage;
+
+  for (auto iter = mKeys.ConstIter(); !iter.Done(); iter.Next()) {
+    cache->mKeys.Put(iter.Key(), iter.Data());
+  }
+
+  return cache.forget();
+}
+
 } // dom namespace
 } // mozilla namespace
--- a/dom/storage/SessionStorage.h
+++ b/dom/storage/SessionStorage.h
@@ -11,23 +11,39 @@
 #include "nsDataHashtable.h"
 
 class nsIPrincipal;
 
 namespace mozilla {
 namespace dom {
 
 class SessionStorageCache;
+class SessionStorageManager;
 
 class SessionStorage final : public Storage
 {
 public:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SessionStorage, Storage)
+
   SessionStorage(nsPIDOMWindowInner* aWindow,
                  nsIPrincipal* aPrincipal,
-                 SessionStorageCache* aCache);
+                 SessionStorageCache* aCache,
+                 SessionStorageManager* aManager,
+                 const nsAString& aDocumentURI,
+                 bool aIsPrivate);
+
+  StorageType Type() const override { return eSessionStorage; }
+
+  SessionStorageManager* Manager() const { return mManager; }
+
+  SessionStorageCache* Cache() const { return mCache; }
+
+  already_AddRefed<SessionStorage>
+  Clone() const;
 
   int64_t GetOriginQuotaUsage() const override;
 
   // WebIDL
   uint32_t GetLength(nsIPrincipal& aSubjectPrincipal,
                      ErrorResult& aRv) override;
 
   void Key(uint32_t aIndex, nsAString& aResult,
@@ -61,16 +77,20 @@ private:
   bool ProcessUsageDelta(int64_t aDelta);
 
   void
   BroadcastChangeNotification(const nsAString& aKey,
                               const nsAString& aOldValue,
                               const nsAString& aNewValue);
 
   RefPtr<SessionStorageCache> mCache;
+  RefPtr<SessionStorageManager> mManager;
+
+  nsString mDocumentURI;
+  bool mIsPrivate;
 };
 
 class SessionStorageCache final
 {
 public:
   NS_INLINE_DECL_REFCOUNTING(SessionStorageCache)
 
   SessionStorageCache();
@@ -91,16 +111,19 @@ public:
   nsresult SetItem(const nsAString& aKey, const nsAString& aValue,
                    nsString& aOldValue);
 
   nsresult RemoveItem(const nsAString& aKey,
                       nsString& aOldValue);
 
   void Clear();
 
+  already_AddRefed<SessionStorageCache>
+  Clone() const;
+
 private:
   ~SessionStorageCache() = default;
 
   bool ProcessUsageDelta(int64_t aDelta);
 
   int64_t mOriginQuotaUsage;
   nsDataHashtable<nsStringHashKey, nsString> mKeys;
 };
new file mode 100644
--- /dev/null
+++ b/dom/storage/SessionStorageManager.cpp
@@ -0,0 +1,203 @@
+/* -*- 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 "SessionStorageManager.h"
+#include "SessionStorage.h"
+#include "StorageUtils.h"
+
+namespace mozilla {
+namespace dom {
+
+using namespace StorageUtils;
+
+NS_IMPL_ISUPPORTS(SessionStorageManager, nsIDOMStorageManager)
+
+SessionStorageManager::SessionStorageManager()
+{}
+
+SessionStorageManager::~SessionStorageManager()
+{}
+
+NS_IMETHODIMP
+SessionStorageManager::PrecacheStorage(nsIPrincipal* aPrincipal,
+                                       nsIDOMStorage** aRetval)
+{
+  // Nothing to preload.
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+SessionStorageManager::CreateStorage(mozIDOMWindow* aWindow,
+                                     nsIPrincipal* aPrincipal,
+                                     const nsAString& aDocumentURI,
+                                     bool aPrivate,
+                                     nsIDOMStorage** aRetval)
+{
+  nsAutoCString originKey;
+  nsAutoCString originAttributes;
+  nsresult rv = GenerateOriginKey(aPrincipal, originAttributes, originKey);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  OriginKeyHashTable* table;
+  if (!mOATable.Get(originAttributes, &table)) {
+    table = new OriginKeyHashTable();
+    mOATable.Put(originAttributes, table);
+  }
+
+  RefPtr<SessionStorageCache> cache;
+  if (!table->Get(originKey, getter_AddRefs(cache))) {
+    cache = new SessionStorageCache();
+    table->Put(originKey, cache);
+  }
+
+  nsCOMPtr<nsPIDOMWindowInner> inner = nsPIDOMWindowInner::From(aWindow);
+
+  RefPtr<SessionStorage> storage =
+    new SessionStorage(inner, aPrincipal, cache, this, aDocumentURI, aPrivate);
+
+  storage.forget(aRetval);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+SessionStorageManager::GetStorage(mozIDOMWindow* aWindow,
+                                  nsIPrincipal* aPrincipal,
+                                  bool aPrivate,
+                                  nsIDOMStorage** aRetval)
+{
+  *aRetval = nullptr;
+
+  nsAutoCString originKey;
+  nsAutoCString originAttributes;
+  nsresult rv = GenerateOriginKey(aPrincipal, originAttributes, originKey);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  OriginKeyHashTable* table;
+  if (!mOATable.Get(originAttributes, &table)) {
+    return NS_OK;
+  }
+
+  RefPtr<SessionStorageCache> cache;
+  if (!table->Get(originKey, getter_AddRefs(cache))) {
+    return NS_OK;
+  }
+
+  nsCOMPtr<nsPIDOMWindowInner> inner = nsPIDOMWindowInner::From(aWindow);
+
+  RefPtr<SessionStorage> storage =
+    new SessionStorage(inner, aPrincipal, cache, this, EmptyString(), aPrivate);
+
+  storage.forget(aRetval);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+SessionStorageManager::CloneStorage(nsIDOMStorage* aStorage)
+{
+  if (NS_WARN_IF(!aStorage)) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  RefPtr<Storage> storage = static_cast<Storage*>(aStorage);
+  if (storage->Type() != Storage::eSessionStorage) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  nsAutoCString originKey;
+  nsAutoCString originAttributes;
+  nsresult rv = GenerateOriginKey(storage->Principal(), originAttributes,
+                                  originKey);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  OriginKeyHashTable* table;
+  if (!mOATable.Get(originAttributes, &table)) {
+    table = new OriginKeyHashTable();
+    mOATable.Put(originAttributes, table);
+  }
+
+  RefPtr<SessionStorageCache> cache;
+  if (table->Get(originKey, getter_AddRefs(cache))) {
+    // Do not replace an existing sessionStorage.
+    return NS_OK;
+  }
+
+  cache = static_cast<SessionStorage*>(aStorage)->Cache()->Clone();
+  MOZ_ASSERT(cache);
+
+  table->Put(originKey, cache);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+SessionStorageManager::CheckStorage(nsIPrincipal* aPrincipal,
+                                    nsIDOMStorage* aStorage,
+                                    bool* aRetval)
+{
+  if (NS_WARN_IF(!aStorage)) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  if (!aPrincipal) {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
+
+  nsAutoCString originKey;
+  nsAutoCString originAttributes;
+  nsresult rv = GenerateOriginKey(aPrincipal, originAttributes, originKey);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  *aRetval = false;
+
+  OriginKeyHashTable* table;
+  if (!mOATable.Get(originAttributes, &table)) {
+    return NS_OK;
+  }
+
+  RefPtr<SessionStorageCache> cache;
+  if (!table->Get(originKey, getter_AddRefs(cache))) {
+    return NS_OK;
+  }
+
+  RefPtr<Storage> storage = static_cast<Storage*>(aStorage);
+  if (storage->Type() != Storage::eSessionStorage) {
+    return NS_OK;
+  }
+
+  RefPtr<SessionStorage> sessionStorage =
+    static_cast<SessionStorage*>(aStorage);
+  if (sessionStorage->Cache() != cache) {
+    return NS_OK;
+  }
+
+/* TODO
+  if (!storage->PrincipalEquals(aPrincipal)) {
+    return NS_OK;
+  }
+*/
+
+  *aRetval = true;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+SessionStorageManager::GetLocalStorageForPrincipal(nsIPrincipal* aPrincipal,
+                                                   const nsAString& aDocumentURI,
+                                                   bool aPrivate,
+                                                   nsIDOMStorage** aRetval)
+{
+  return NS_ERROR_UNEXPECTED;
+}
+
+} // dom namespace
+} // mozilla namespace
new file mode 100644
--- /dev/null
+++ b/dom/storage/SessionStorageManager.h
@@ -0,0 +1,37 @@
+/* -*- 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/. */
+
+#ifndef mozilla_dom_SessionStorageManager_h
+#define mozilla_dom_SessionStorageManager_h
+
+#include "nsIDOMStorageManager.h"
+#include "nsClassHashtable.h"
+#include "nsRefPtrHashtable.h"
+
+namespace mozilla {
+namespace dom {
+
+class SessionStorageCache;
+
+class SessionStorageManager final : public nsIDOMStorageManager
+{
+public:
+  SessionStorageManager();
+
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIDOMSTORAGEMANAGER
+
+private:
+  ~SessionStorageManager();
+
+  typedef nsRefPtrHashtable<nsCStringHashKey, SessionStorageCache> OriginKeyHashTable;
+  nsClassHashtable<nsCStringHashKey, OriginKeyHashTable> mOATable;
+};
+
+} // dom namespace
+} // mozilla namespace
+
+#endif // mozilla_dom_SessionStorageManager_h
--- a/dom/storage/Storage.h
+++ b/dom/storage/Storage.h
@@ -27,20 +27,33 @@ class Storage : public nsIDOMStorage
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Storage,
                                                          nsIDOMStorage)
 
   Storage(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal);
 
+  enum StorageType {
+    eSessionStorage,
+    eLocalStorage,
+  };
+
+  virtual StorageType Type() const = 0;
+
   virtual int64_t GetOriginQuotaUsage() const = 0;
 
   virtual bool CanAccess(nsIPrincipal* aPrincipal);
 
+  nsIPrincipal*
+  Principal() const
+  {
+    return mPrincipal;
+  }
+
   // WebIDL
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
 
   nsPIDOMWindowInner* GetParentObject() const
   {
     return mWindow;
   }
@@ -94,22 +107,16 @@ public:
   virtual void
   Clear(nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) = 0;
 
   virtual bool IsSessionOnly() const = 0;
 
 protected:
   virtual ~Storage();
 
-  nsIPrincipal*
-  Principal() const
-  {
-    return mPrincipal;
-  }
-
 private:
   nsCOMPtr<nsPIDOMWindowInner> mWindow;
   nsCOMPtr<nsIPrincipal> mPrincipal;
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/storage/StorageManager.cpp
+++ b/dom/storage/StorageManager.cpp
@@ -643,22 +643,10 @@ DOMLocalStorageManager::Ensure()
   // Cause sSelf to be populated.
   nsCOMPtr<nsIDOMStorageManager> initializer =
     do_GetService("@mozilla.org/dom/localStorage-manager;1");
   MOZ_ASSERT(sSelf, "Didn't initialize?");
 
   return sSelf;
 }
 
-// DOMSessionStorageManager
-
-DOMSessionStorageManager::DOMSessionStorageManager()
-  : StorageManagerBase(eSessionStorage)
-{
-  if (!XRE_IsParentProcess()) {
-    // Do this only on the child process.  The thread IPC bridge
-    // is also used to communicate chrome observer notifications.
-    StorageCache::StartDatabase();
-  }
-}
-
 } // namespace dom
 } // namespace mozilla
--- a/dom/storage/StorageManager.h
+++ b/dom/storage/StorageManager.h
@@ -150,18 +150,12 @@ public:
 
   // Like Self, but creates an instance if we're not yet initialized.
   static DOMLocalStorageManager* Ensure();
 
 private:
   static DOMLocalStorageManager* sSelf;
 };
 
-class DOMSessionStorageManager final : public StorageManagerBase
-{
-public:
-  DOMSessionStorageManager();
-};
-
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_StorageManager_h
new file mode 100644
--- /dev/null
+++ b/dom/storage/StorageUtils.cpp
@@ -0,0 +1,71 @@
+/* -*- 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 "StorageUtils.h"
+
+namespace mozilla {
+namespace dom {
+namespace StorageUtils {
+
+nsresult
+GenerateOriginKey(nsIPrincipal* aPrincipal, nsACString& aOriginAttrSuffix,
+                  nsACString& aOriginKey)
+{
+  MOZ_ASSERT(aPrincipal);
+
+  aPrincipal->OriginAttributesRef().CreateSuffix(aOriginAttrSuffix);
+
+  nsCOMPtr<nsIURI> uri;
+  nsresult rv = aPrincipal->GetURI(getter_AddRefs(uri));
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (!uri) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  nsAutoCString domainOrigin;
+  rv = uri->GetAsciiHost(domainOrigin);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  if (domainOrigin.IsEmpty()) {
+    // For the file:/// protocol use the exact directory as domain.
+    bool isScheme = false;
+    if (NS_SUCCEEDED(uri->SchemeIs("file", &isScheme)) && isScheme) {
+      nsCOMPtr<nsIURL> url = do_QueryInterface(uri, &rv);
+      NS_ENSURE_SUCCESS(rv, rv);
+      rv = url->GetDirectory(domainOrigin);
+      NS_ENSURE_SUCCESS(rv, rv);
+    }
+  }
+
+  // Append reversed domain
+  nsAutoCString reverseDomain;
+  rv = CreateReversedDomain(domainOrigin, reverseDomain);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+
+  aOriginKey.Append(reverseDomain);
+
+  // Append scheme
+  nsAutoCString scheme;
+  rv = uri->GetScheme(scheme);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  aOriginKey.Append(':');
+  aOriginKey.Append(scheme);
+
+  // Append port if any
+  int32_t port = NS_GetRealPort(uri);
+  if (port != -1) {
+    aOriginKey.Append(nsPrintfCString(":%d", port));
+  }
+
+  return NS_OK;
+}
+
+} // StorageUtils namespace
+} // dom namespace
+} // mozilla namespace
new file mode 100644
--- /dev/null
+++ b/dom/storage/StorageUtils.h
@@ -0,0 +1,24 @@
+/* -*- 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/. */
+
+#ifndef mozilla_dom_StorageUtils_h
+#define mozilla_dom_StorageUtils_h
+
+class nsIPrincipal;
+
+namespace mozilla {
+namespace dom {
+namespace StorageUtils {
+
+nsresult
+GenerateOriginKey(nsIPrincipal* aPrincipal, nsACString& aOriginAttrSuffix,
+                  nsACString& aOriginKey);
+
+} // StorageUtils namespace
+} // dom namespace
+} // mozilla namespace
+
+#endif // mozilla_dom_StorageUtils_h
--- a/dom/storage/moz.build
+++ b/dom/storage/moz.build
@@ -3,30 +3,33 @@
 # 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 += [
+    'SessionStorageManager.h',
     'Storage.h',
     'StorageIPC.h',
 ]
 
 UNIFIED_SOURCES += [
     'LocalStorage.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',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -79,16 +79,17 @@
 #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/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"
 
 #ifdef MOZ_WEBSPEECH_TEST_BACKEND
 #include "mozilla/dom/FakeSpeechRecognitionService.h"
@@ -251,17 +252,17 @@ 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(DOMSessionStorageManager)
+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,
@@ -911,17 +912,17 @@ static const mozilla::Module::CIDEntry k
   { &kTRANSFORMIIX_XPATH_EVALUATOR_CID, false, nullptr, XPathEvaluatorConstructor },
   { &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, DOMSessionStorageManagerConstructor },
+  { &kNS_DOMSESSIONSTORAGEMANAGER_CID, false, nullptr, SessionStorageManagerConstructor },
   { &kNS_DOMLOCALSTORAGEMANAGER_CID, false, nullptr, DOMLocalStorageManagerConstructor },
   { &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 },