Bug 1389561 - Part 1: Ensure origin initialized in Maintenance::DirectoryWork. r=janv
authorShawn Huang <shuang@mozilla.com>
Thu, 26 Oct 2017 16:59:18 +0800
changeset 388562 c4a578d5a37b2333db5f733fc4719db706716ce2
parent 388561 bab5535320119cae35608b579477826c0af65f3f
child 388563 675b7b1772d14bca2acddb79b085a2950a1a4b0d
push id32754
push userarchaeopteryx@coole-files.de
push dateFri, 27 Oct 2017 09:46:43 +0000
treeherdermozilla-central@ecef003d8367 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv
bugs1389561
milestone58.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 1389561 - Part 1: Ensure origin initialized in Maintenance::DirectoryWork. r=janv Make sure origins had been initialized in Maintenance::DirectoryWork before getting QuotaObject. It's possible that DatabaseMaintenance::Run before origins initialized.
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -18597,16 +18597,17 @@ Maintenance::DirectoryWork()
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
 
       if (!idbDirEntries) {
         continue;
       }
 
+      nsCString suffix;
       nsCString group;
       nsCString origin;
       nsTArray<nsString> databasePaths;
 
       while (true) {
         // Loop over files in the "idb" directory.
         if (IsAborted()) {
           return NS_ERROR_ABORT;
@@ -18654,27 +18655,27 @@ Maintenance::DirectoryWork()
         }
 
         if (isDirectory) {
           continue;
         }
 
         // Found a database.
         if (databasePaths.IsEmpty()) {
+          MOZ_ASSERT(suffix.IsEmpty());
           MOZ_ASSERT(group.IsEmpty());
           MOZ_ASSERT(origin.IsEmpty());
 
           int64_t dummyTimeStamp;
           bool dummyPersisted;
-          nsCString dummySuffix;
           if (NS_WARN_IF(NS_FAILED(
                 quotaManager->GetDirectoryMetadata2(originDir,
                                                     &dummyTimeStamp,
                                                     &dummyPersisted,
-                                                    dummySuffix,
+                                                    suffix,
                                                     group,
                                                     origin)))) {
             // Not much we can do here...
             continue;
           }
         }
 
         MOZ_ASSERT(!databasePaths.Contains(idbFilePath));
@@ -18682,16 +18683,31 @@ Maintenance::DirectoryWork()
         databasePaths.AppendElement(idbFilePath);
       }
 
       if (!databasePaths.IsEmpty()) {
         mDirectoryInfos.AppendElement(DirectoryInfo(persistenceType,
                                                     group,
                                                     origin,
                                                     Move(databasePaths)));
+
+        nsCOMPtr<nsIFile> directory;
+
+        // Idle maintenance may occur before origin is initailized.
+        // Ensure origin is initialized first. It will initialize all origins
+        // for temporary storage including IDB origins.
+        rv = quotaManager->EnsureOriginIsInitialized(persistenceType,
+                                                     suffix,
+                                                     group,
+                                                     origin,
+                                                     getter_AddRefs(directory));
+
+        if (NS_WARN_IF(NS_FAILED(rv))) {
+          return rv;
+        }
       }
     }
   }
 
   mState = State::BeginDatabaseMaintenance;
 
   MOZ_ALWAYS_SUCCEEDS(
     mQuotaClient->BackgroundThread()->Dispatch(this, NS_DISPATCH_NORMAL));