Bug 1593246 - Part 4: Overload SessionStorageManager::GetSessionStorageCacheHelper r=dom-workers-and-storage-reviewers,asuth
authorYaron Tausky <ytausky@mozilla.com>
Mon, 09 Dec 2019 19:38:34 +0000
changeset 506309 de6b543ce6d7b0b59aa0d78ea793a93919a737c3
parent 506308 44fb598d3ad83467805f960e973a6757c125ea5a
child 506310 ca57bc90a3f8580d533b2f9ee1a99e965cd5fbd4
push id36902
push useraciure@mozilla.com
push dateWed, 11 Dec 2019 03:34:51 +0000
treeherdermozilla-central@7635669b8d72 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdom-workers-and-storage-reviewers, asuth
bugs1593246
milestone73.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 1593246 - Part 4: Overload SessionStorageManager::GetSessionStorageCacheHelper r=dom-workers-and-storage-reviewers,asuth Depends on D55660 Differential Revision: https://phabricator.services.mozilla.com/D55661
dom/storage/SessionStorageManager.cpp
dom/storage/SessionStorageManager.h
--- a/dom/storage/SessionStorageManager.cpp
+++ b/dom/storage/SessionStorageManager.cpp
@@ -84,44 +84,52 @@ SessionStorageManager::GetSessionStorage
     nsIPrincipal* aPrincipal, nsIPrincipal* aStoragePrincipal,
     RefPtr<SessionStorageCache>* aRetVal) {
   return GetSessionStorageCacheHelper(aPrincipal, true, nullptr, aRetVal);
 }
 
 nsresult SessionStorageManager::GetSessionStorageCacheHelper(
     nsIPrincipal* aPrincipal, bool aMakeIfNeeded,
     SessionStorageCache* aCloneFrom, RefPtr<SessionStorageCache>* aRetVal) {
-  *aRetVal = nullptr;
-
   nsAutoCString originKey;
   nsAutoCString originAttributes;
   nsresult rv = GenerateOriginKey(aPrincipal, originAttributes, originKey);
   if (NS_FAILED(rv)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
+  return GetSessionStorageCacheHelper(originAttributes, originKey,
+                                      aMakeIfNeeded, aCloneFrom, aRetVal);
+}
+
+nsresult SessionStorageManager::GetSessionStorageCacheHelper(
+    const nsACString& aOriginAttrs, const nsACString& aOriginKey,
+    bool aMakeIfNeeded, SessionStorageCache* aCloneFrom,
+    RefPtr<SessionStorageCache>* aRetVal) {
+  *aRetVal = nullptr;
+
   OriginKeyHashTable* table;
-  if (!mOATable.Get(originAttributes, &table)) {
+  if (!mOATable.Get(aOriginAttrs, &table)) {
     if (aMakeIfNeeded) {
       table = new OriginKeyHashTable();
-      mOATable.Put(originAttributes, table);
+      mOATable.Put(aOriginAttrs, table);
     } else {
       return NS_OK;
     }
   }
 
   RefPtr<SessionStorageCache> cache;
-  if (!table->Get(originKey, getter_AddRefs(cache))) {
+  if (!table->Get(aOriginKey, getter_AddRefs(cache))) {
     if (aMakeIfNeeded) {
       if (aCloneFrom) {
         cache = aCloneFrom->Clone();
       } else {
         cache = new SessionStorageCache();
       }
-      table->Put(originKey, cache);
+      table->Put(aOriginKey, cache);
     } else {
       return NS_OK;
     }
   }
 
   *aRetVal = std::move(cache);
 
   return NS_OK;
--- a/dom/storage/SessionStorageManager.h
+++ b/dom/storage/SessionStorageManager.h
@@ -50,16 +50,22 @@ class SessionStorageManager final : publ
                      const OriginAttributesPattern& aPattern,
                      const nsACString& aOriginScope);
 
   nsresult GetSessionStorageCacheHelper(nsIPrincipal* aPrincipal,
                                         bool aMakeIfNeeded,
                                         SessionStorageCache* aCloneFrom,
                                         RefPtr<SessionStorageCache>* aRetVal);
 
+  nsresult GetSessionStorageCacheHelper(const nsACString& aOriginAttrs,
+                                        const nsACString& aOriginKey,
+                                        bool aMakeIfNeeded,
+                                        SessionStorageCache* aCloneFrom,
+                                        RefPtr<SessionStorageCache>* aRetVal);
+
   typedef nsRefPtrHashtable<nsCStringHashKey, SessionStorageCache>
       OriginKeyHashTable;
   nsClassHashtable<nsCStringHashKey, OriginKeyHashTable> mOATable;
 
   RefPtr<SessionStorageObserver> mObserver;
 
   RefPtr<BrowsingContext> mBrowsingContext;
 };