Bug 1475218 - Disable PBackgroundLocalStorageCache on Android; r=asuth
authorJan Varga <jan.varga@gmail.com>
Tue, 21 Aug 2018 17:27:42 +0200
changeset 480923 a2181b2ee1fc61dfc9bbb20e36df656b251704ad
parent 480922 8eac225243d8e0846f39c0fc1e4d831765ff6991
child 480924 577ffed9f102439db47afebcef95bbaaa2e04c93
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersasuth
bugs1475218
milestone63.0a1
Bug 1475218 - Disable PBackgroundLocalStorageCache on Android; r=asuth There can be only one content process on Fennec so there's nothing to synchronize.
dom/storage/LocalStorageCache.cpp
dom/storage/LocalStorageManager.cpp
--- a/dom/storage/LocalStorageCache.cpp
+++ b/dom/storage/LocalStorageCache.cpp
@@ -438,17 +438,19 @@ LocalStorageCache::SetItem(const LocalSt
   }
 
   data.mKeys.Put(aKey, aValue);
 
   if (aSource != ContentMutation) {
     return NS_OK;
   }
 
+#if !defined(MOZ_WIDGET_ANDROID)
   NotifyObservers(aStorage, nsString(aKey), aOld, aValue);
+#endif
 
   if (Persist(aStorage)) {
     StorageDBChild* storageChild = StorageDBChild::Get();
     if (!storageChild) {
       NS_ERROR("Writing to localStorage after the database has been shut down"
                ", data lose!");
       return NS_ERROR_NOT_INITIALIZED;
     }
@@ -486,17 +488,19 @@ LocalStorageCache::RemoveItem(const Loca
                           static_cast<int64_t>(aKey.Length()));
   Unused << ProcessUsageDelta(aStorage, delta, aSource);
   data.mKeys.Remove(aKey);
 
   if (aSource != ContentMutation) {
     return NS_OK;
   }
 
+#if !defined(MOZ_WIDGET_ANDROID)
   NotifyObservers(aStorage, nsString(aKey), aOld, VoidString());
+#endif
 
   if (Persist(aStorage)) {
     StorageDBChild* storageChild = StorageDBChild::Get();
     if (!storageChild) {
       NS_ERROR("Writing to localStorage after the database has been shut down"
                ", data lose!");
       return NS_ERROR_NOT_INITIALIZED;
     }
@@ -534,19 +538,21 @@ LocalStorageCache::Clear(const LocalStor
     Unused << ProcessUsageDelta(aStorage, -data.mOriginQuotaUsage, aSource);
     data.mKeys.Clear();
   }
 
   if (aSource != ContentMutation) {
     return hadData ? NS_OK : NS_SUCCESS_DOM_NO_OPERATION;
   }
 
+#if !defined(MOZ_WIDGET_ANDROID)
   if (hadData) {
     NotifyObservers(aStorage, VoidString(), VoidString(), VoidString());
   }
+#endif
 
   if (Persist(aStorage) && (refresh || hadData)) {
     StorageDBChild* storageChild = StorageDBChild::Get();
     if (!storageChild) {
       NS_ERROR("Writing to localStorage after the database has been shut down"
                ", data lose!");
       return NS_ERROR_NOT_INITIALIZED;
     }
--- a/dom/storage/LocalStorageManager.cpp
+++ b/dom/storage/LocalStorageManager.cpp
@@ -241,16 +241,17 @@ LocalStorageManager::GetStorageInternal(
         }
       } else {
         if (originKey.EqualsLiteral("knalb.:about")) {
           return NS_OK;
         }
       }
     }
 
+#if !defined(MOZ_WIDGET_ANDROID)
     PBackgroundChild* backgroundActor =
       BackgroundChild::GetOrCreateForCurrentThread();
     if (NS_WARN_IF(!backgroundActor)) {
       return NS_ERROR_FAILURE;
     }
 
     PrincipalInfo principalInfo;
     rv = mozilla::ipc::PrincipalToPrincipalInfo(aPrincipal, &principalInfo);
@@ -258,31 +259,34 @@ LocalStorageManager::GetStorageInternal(
       return rv;
     }
 
     uint32_t privateBrowsingId;
     rv = aPrincipal->GetPrivateBrowsingId(&privateBrowsingId);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
+#endif
 
     // 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);
 
+#if !defined(MOZ_WIDGET_ANDROID)
     LocalStorageCacheChild* actor = new LocalStorageCacheChild(cache);
 
     MOZ_ALWAYS_TRUE(
       backgroundActor->SendPBackgroundLocalStorageCacheConstructor(
                                                             actor,
                                                             principalInfo,
                                                             originKey,
                                                             privateBrowsingId));
 
     cache->SetActor(actor);
+#endif
   }
 
   if (aRetval) {
     nsCOMPtr<nsPIDOMWindowInner> inner = nsPIDOMWindowInner::From(aWindow);
 
     nsCOMPtr<nsIDOMStorage> storage = new LocalStorage(
       inner, this, cache, aDocumentURI, aPrincipal, aPrivate);
     storage.forget(aRetval);