Bug 1389561 - Part 2: Add MOZ_DIAGNOSTIC_ASSERT for mTemporaryStorageInitialized, r=janv
authorShawn Huang <shuang@mozilla.com>
Wed, 11 Oct 2017 15:44:16 +0800
changeset 428085 20571bff3967d08e90c1b20b1e5175ef27164274
parent 428084 d2091f915c6aecd2ef2b6157f73d0f9bfbc29f95
child 428086 3029acae6f822f6e148bf8ad64a719513c655883
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersjanv
bugs1389561
milestone58.0a1
Bug 1389561 - Part 2: Add MOZ_DIAGNOSTIC_ASSERT for mTemporaryStorageInitialized, r=janv
dom/quota/ActorsParent.cpp
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -3833,16 +3833,23 @@ QuotaManager::GetQuotaObject(Persistence
   if (aFileSizeOut) {
     *aFileSizeOut = 0;
   }
 
   if (aPersistenceType == PERSISTENCE_TYPE_PERSISTENT) {
     return nullptr;
   }
 
+#if defined(NIGHTLY_BUILD)
+  {
+    MutexAutoLock autoLock(mQuotaMutex);
+    MOZ_DIAGNOSTIC_ASSERT(mTemporaryStorageInitialized);
+  }
+#endif
+
   nsString path;
   nsresult rv = aFile->GetPath(path);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   int64_t fileSize;
 
   bool exists;
   rv = aFile->Exists(&exists);
@@ -3918,16 +3925,23 @@ already_AddRefed<QuotaObject>
 QuotaManager::GetQuotaObject(PersistenceType aPersistenceType,
                              const nsACString& aGroup,
                              const nsACString& aOrigin,
                              const nsAString& aPath,
                              int64_t* aFileSizeOut /* = nullptr */)
 {
   NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
 
+#if defined(NIGHTLY_BUILD)
+  if (aPersistenceType != PERSISTENCE_TYPE_PERSISTENT){
+    MutexAutoLock autoLock(mQuotaMutex);
+    MOZ_DIAGNOSTIC_ASSERT(mTemporaryStorageInitialized);
+  }
+#endif
+
   if (aFileSizeOut) {
     *aFileSizeOut = 0;
   }
 
   nsresult rv;
   nsCOMPtr<nsIFile> file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
@@ -5237,17 +5251,24 @@ QuotaManager::EnsureOriginIsInitializedI
         return rv;
       }
 
       rv = GetTemporaryStorageLimit(storageDir, mTemporaryStorageUsage,
                                     &mTemporaryStorageLimit);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
+#if defined(NIGHTLY_BUILD)
+  {
+    MutexAutoLock autoLock(mQuotaMutex);
     mTemporaryStorageInitialized = true;
+  }
+#else
+    mTemporaryStorageInitialized = true;
+#endif
 
     CheckTemporaryStorageLimits();
   }
 
   bool created;
   rv = EnsureOriginDirectory(directory, &created);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -5323,17 +5344,26 @@ QuotaManager::OriginClearCompleted(Persi
 }
 
 void
 QuotaManager::ResetOrClearCompleted()
 {
   AssertIsOnIOThread();
 
   mInitializedOrigins.Clear();
-  mTemporaryStorageInitialized = false;
+
+#if defined(NIGHTLY_BUILD)
+  {
+    MutexAutoLock autoLock(mQuotaMutex);
+    mTemporaryStorageInitialized = false;
+  }
+#else
+    mTemporaryStorageInitialized = false;
+#endif
+
   mStorageInitialized = false;
 
   ReleaseIOThreadObjects();
 }
 
 Client*
 QuotaManager::GetClient(Client::Type aClientType)
 {