Backed out changesets 2f1fe3baec7c and 8beafe5ccc65 (bug 861920) because they depend on bug 861894, which was also backed out.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 10 May 2013 11:09:28 -0400
changeset 142458 41ca6c75671e336bd89c83f322e578f720b2cf7e
parent 142457 07f18a9becbe784652702c44fa97ac0d4ea1cd4a
child 142459 150241980e66d828ea9803db901f3f15cda134f0
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs861920, 861894
milestone23.0a1
backs out2f1fe3baec7cc6e02ccb679d23e449792ebaf897
8beafe5ccc6516f63c45cc26fed5b786b054baac
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
Backed out changesets 2f1fe3baec7c and 8beafe5ccc65 (bug 861920) because they depend on bug 861894, which was also backed out. DONTBUILD
dom/src/storage/DOMStorageCache.cpp
dom/src/storage/DOMStorageIPC.cpp
dom/src/storage/DOMStorageManager.cpp
dom/src/storage/DOMStorageManager.h
dom/src/storage/DOMStorageObserver.cpp
dom/tests/mochitest/localstorage/Makefile.in
dom/tests/mochitest/localstorage/test_lowDeviceStorage.html
--- a/dom/src/storage/DOMStorageCache.cpp
+++ b/dom/src/storage/DOMStorageCache.cpp
@@ -189,21 +189,16 @@ bool
 DOMStorageCache::ProcessUsageDelta(const DOMStorage* aStorage, int64_t aDelta)
 {
   return ProcessUsageDelta(GetDataSetIndex(aStorage), aDelta);
 }
 
 bool
 DOMStorageCache::ProcessUsageDelta(uint32_t aGetDataSetIndex, const int64_t aDelta)
 {
-  // Check if we are in a low disk space situation
-  if (aDelta > 0 && mManager && mManager->IsLowDiskSpace()) {
-    return false;
-  }
-
   // Check limit per this origin
   Data& data = mData[aGetDataSetIndex];
   uint64_t newOriginUsage = data.mOriginQuotaUsage + aDelta;
   if (aDelta > 0 && newOriginUsage > DOMStorageManager::GetQuota()) {
     return false;
   }
 
   // Now check eTLD+1 limit
--- a/dom/src/storage/DOMStorageIPC.cpp
+++ b/dom/src/storage/DOMStorageIPC.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DOMStorageIPC.h"
 
 #include "DOMStorageManager.h"
 
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/unused.h"
-#include "nsIDiskSpaceWatcher.h"
 
 namespace mozilla {
 namespace dom {
 
 // ----------------------------------------------------------------------------
 // Child
 // ----------------------------------------------------------------------------
 
@@ -290,20 +289,20 @@ DOMStorageDBParent::ReleaseIPDLReference
 {
   NS_ABORT_IF_FALSE(mIPCOpen, "Attempting to release non-existent IPDL reference");
   mIPCOpen = false;
   Release();
 }
 
 namespace { // anon
 
-class SendInitialChildDataRunnable : public nsRunnable
+class SendScopesHavingDataRunnable : public nsRunnable
 {
 public:
-  SendInitialChildDataRunnable(DOMStorageDBParent* aParent)
+  SendScopesHavingDataRunnable(DOMStorageDBParent* aParent)
     : mParent(aParent)
   {}
 
 private:
   NS_IMETHOD Run()
   {
     if (!mParent->IPCOpen()) {
       return NS_OK;
@@ -311,27 +310,16 @@ private:
 
     DOMStorageDBBridge* db = DOMStorageCache::GetDatabase();
     if (db) {
       InfallibleTArray<nsCString> scopes;
       db->GetScopesHavingData(&scopes);
       mozilla::unused << mParent->SendScopesHavingData(scopes);
     }
 
-    // We need to check if the device is in a low disk space situation, so
-    // we can forbid in that case any write in localStorage.
-    nsCOMPtr<nsIDiskSpaceWatcher> diskSpaceWatcher =
-      do_GetService("@mozilla.org/toolkit/disk-space-watcher;1");
-    bool lowDiskSpace = false;
-    diskSpaceWatcher->GetIsDiskFull(&lowDiskSpace);
-    if (lowDiskSpace) {
-      mozilla::unused << mParent->SendObserve(
-        nsDependentCString("low-disk-space"), EmptyCString());
-    }
-
     return NS_OK;
   }
 
   nsRefPtr<DOMStorageDBParent> mParent;
 };
 
 } // anon
 
@@ -343,18 +331,18 @@ DOMStorageDBParent::DOMStorageDBParent()
     observer->AddSink(this);
   }
 
   // We are always open by IPC only
   AddIPDLReference();
 
   // Cannot send directly from here since the channel
   // is not completely built at this moment.
-  nsRefPtr<SendInitialChildDataRunnable> r =
-    new SendInitialChildDataRunnable(this);
+  nsRefPtr<SendScopesHavingDataRunnable> r =
+    new SendScopesHavingDataRunnable(this);
   NS_DispatchToCurrentThread(r);
 }
 
 DOMStorageDBParent::~DOMStorageDBParent()
 {
   DOMStorageObserver* observer = DOMStorageObserver::Self();
   if (observer) {
     observer->RemoveSink(this);
--- a/dom/src/storage/DOMStorageManager.cpp
+++ b/dom/src/storage/DOMStorageManager.cpp
@@ -104,17 +104,16 @@ PrincipalsEqual(nsIPrincipal* aObjectPri
   return true;
 }
 
 NS_IMPL_ISUPPORTS1(DOMStorageManager,
                    nsIDOMStorageManager)
 
 DOMStorageManager::DOMStorageManager(nsPIDOMStorage::StorageType aType)
   : mType(aType)
-  , mLowDiskSpace(false)
 {
   mCaches.Init(10);
   DOMStorageObserver* observer = DOMStorageObserver::Self();
   NS_ASSERTION(observer, "No DOMStorageObserver, cannot observe private data delete notifications!");
 
   if (observer) {
     observer->AddSink(this);
   }
@@ -562,32 +561,16 @@ DOMStorageManager::Observe(const char* a
     // For case caches are still referenced - clear them completely
     ClearCacheEnumeratorData data(DOMStorageCache::kUnloadComplete);
     mCaches.EnumerateEntries(ClearCacheEnumerator, &data);
 
     mCaches.Clear();
     return NS_OK;
   }
 
-  if (!strcmp(aTopic, "low-disk-space")) {
-    if (mType == LocalStorage) {
-      mLowDiskSpace = true;
-    }
-
-    return NS_OK;
-  }
-
-  if (!strcmp(aTopic, "no-low-disk-space")) {
-    if (mType == LocalStorage) {
-      mLowDiskSpace = false;
-    }
-
-    return NS_OK;
-  }
-
 #ifdef DOM_STORAGE_TESTS
   if (!strcmp(aTopic, "test-reload")) {
     if (mType != LocalStorage) {
       return NS_OK;
     }
 
     // This immediately completely reloads all caches from the database.
     ClearCacheEnumeratorData data(DOMStorageCache::kTestReload);
--- a/dom/src/storage/DOMStorageManager.h
+++ b/dom/src/storage/DOMStorageManager.h
@@ -82,22 +82,16 @@ private:
                               const nsAString& aDocumentURI,
                               bool aPrivate,
                               nsIDOMStorage** aRetval);
 
   // Scope->cache map
   nsTHashtable<DOMStorageCacheHashKey> mCaches;
   const nsPIDOMStorage::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; };
-
   static PLDHashOperator ClearCacheEnumerator(DOMStorageCacheHashKey* aCache,
                                               void* aClosure);
 
 protected:
   friend class DOMStorageCache;
   // Releases cache since it is no longer referrered by any DOMStorage object.
   virtual void DropCache(DOMStorageCache* aCache);
 };
--- a/dom/src/storage/DOMStorageObserver.cpp
+++ b/dom/src/storage/DOMStorageObserver.cpp
@@ -63,21 +63,16 @@ DOMStorageObserver::Init()
   obs->AddObserver(sSelf, "last-pb-context-exited", true);
   obs->AddObserver(sSelf, "webapps-clear-data", true);
 
   // Shutdown
   obs->AddObserver(sSelf, "profile-after-change", true);
   obs->AddObserver(sSelf, "profile-before-change", true);
   obs->AddObserver(sSelf, "xpcom-shutdown", true);
 
-  // Observe low device storage notifications. Only in the parent.
-  if (XRE_GetProcessType() == GeckoProcessType_Default) {
-    obs->AddObserver(sSelf, "disk-space-watcher", true);
-  }
-
 #ifdef DOM_STORAGE_TESTS
   // Testing
   obs->AddObserver(sSelf, "domstorage-test-flush-force", true);
   if (XRE_GetProcessType() == GeckoProcessType_Default) {
     // Only to forward to child process.
     obs->AddObserver(sSelf, "domstorage-test-flushed", true);
   }
 
@@ -300,26 +295,16 @@ DOMStorageObserver::Observe(nsISupports*
     rv = DOMStorageCache::StopDatabase();
     if (NS_FAILED(rv)) {
       NS_WARNING("Error while stopping DOMStorage DB background thread");
     }
 
     return NS_OK;
   }
 
-  if (!strcmp(aTopic, "disk-space-watcher")) {
-    if (NS_LITERAL_STRING("full").Equals(aData)) {
-      Notify("low-disk-space");
-    } else if (NS_LITERAL_STRING("free").Equals(aData)) {
-      Notify("no-low-disk-space");
-    }
-
-    return NS_OK;
-  }
-
 #ifdef DOM_STORAGE_TESTS
   if (!strcmp(aTopic, "domstorage-test-flush-force")) {
     DOMStorageDBBridge* db = DOMStorageCache::GetDatabase();
     if (db) {
       db->AsyncFlush();
     }
 
     return NS_OK;
--- a/dom/tests/mochitest/localstorage/Makefile.in
+++ b/dom/tests/mochitest/localstorage/Makefile.in
@@ -46,17 +46,16 @@ MOCHITEST_FILES	= \
     test_localStorageOriginsPortDiffs.html \
     test_localStorageOriginsDomainDiffs.html \
     test_localStorageOriginsSchemaDiffs.html \
     test_localStorageReplace.html \
     test_localStorageQuota.html \
     test_localStorageQuotaSessionOnly.html \
     test_localStorageQuotaSessionOnly2.html \
     test_localStorageKeyOrder.html \
-    test_lowDeviceStorage.html \
     test_storageConstructor.html \
     $(NULL)
 
 MOCHITEST_CHROME_FILES = \
     test_localStorageBasePrivateBrowsing_perwindowpb.html \
     test_localStorageFromChrome.xhtml \
     test_localStorageQuotaPrivateBrowsing_perwindowpb.html \
     test_app_uninstall.html \
deleted file mode 100644
--- a/dom/tests/mochitest/localstorage/test_lowDeviceStorage.html
+++ /dev/null
@@ -1,76 +0,0 @@
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title>Test localStorage usage while in a low device storage situation</title>
-
-<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<script type="text/javascript" src="localStorageCommon.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-
-<script type="text/javascript">
-
-/*
-This test does the following:
-- Stores an item in localStorage.
-- Checks the stored value.
-- Emulates a low device storage situation.
-- Gets the stored item again.
-- Removes the stored item.
-- Fails storing a new value.
-- Emulates recovering from a low device storage situation.
-- Stores a new value.
-- Checks the stored value.
-*/
-
-function lowDeviceStorage(lowStorage) {
-  var data = lowStorage ? "full" : "free";
-  os().notifyObservers(null, "disk-space-watcher", data);
-}
-
-function startTest() {
-  // Add a test item.
-  localStorage.setItem("item", "value");
-  is(localStorage.getItem("item"), "value", "getItem()");
-
-  // Emulates a low device storage situation.
-  lowDeviceStorage(true);
-
-  // Checks that we can still access to the stored item.
-  is(localStorage.getItem("item"), "value",
-     "getItem() during a device storage situation");
-
-  // Removes the stored item.
-  localStorage.removeItem("item");
-  is(localStorage.getItem("item"), undefined,
-     "getItem() after removing the item");
-
-  // Fails storing a new item.
-  try {
-    localStorage.setItem("newItem", "value");
-    ok(false, "Storing a new item is expected to fail");
-  } catch(e) {
-    ok(true, "Got an expected exception " + e);
-  } finally {
-    is(localStorage.getItem("newItem"), undefined,
-       "setItem while device storage is low");
-  }
-
-  // Emulates recovering from a low device storage situation.
-  lowDeviceStorage(false);
-
-  // Add a test item after recovering from the low device storage situation.
-  localStorage.setItem("newItem", "value");
-  is(localStorage.getItem("newItem"), "value",
-     "getItem() with available storage");
-
-  SimpleTest.finish();
-}
-
-SimpleTest.waitForExplicitFinish();
-
-</script>
-
-</head>
-
-<body onload="startTest();">
-</body>
-</html>