Bug 780625 - Followup fix for "Don't install quota handlers on chrome databases". r=bent
authorJan Varga <jan.varga@gmail.com>
Wed, 08 Aug 2012 06:35:48 +0200
changeset 101782 6a732d5ea1e8
parent 101781 6be6808c2a4a
child 101783 9c24b7287c5b
push id23250
push useremorley@mozilla.com
push dateWed, 08 Aug 2012 16:23:03 +0000
treeherdermozilla-central@b99a81e70b06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs780625
milestone17.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 780625 - Followup fix for "Don't install quota handlers on chrome databases". r=bent
dom/indexedDB/FileManager.cpp
dom/indexedDB/FileManager.h
dom/indexedDB/IndexedDatabaseManager.cpp
dom/indexedDB/OpenDatabaseHelper.cpp
--- a/dom/indexedDB/FileManager.cpp
+++ b/dom/indexedDB/FileManager.cpp
@@ -36,17 +36,18 @@ EnumerateToTArray(const PRUint64& aKey,
 
   return PL_DHASH_NEXT;
 }
 
 } // anonymous namespace
 
 nsresult
 FileManager::Init(nsIFile* aDirectory,
-                  mozIStorageConnection* aConnection)
+                  mozIStorageConnection* aConnection,
+                  FactoryPrivilege aPrivilege)
 {
   NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
 
   mFileInfos.Init();
 
   bool exists;
   nsresult rv = aDirectory->Exists(&exists);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -98,18 +99,20 @@ FileManager::Init(nsIFile* aDirectory,
     nsCOMPtr<nsIFile> file;
     rv = aDirectory->Clone(getter_AddRefs(file));
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = file->Append(name);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (flag) {
-      rv = ss->UpdateQuotaInformationForFile(file);
-      NS_ENSURE_SUCCESS(rv, rv);
+      if (aPrivilege != Chrome) {
+        rv = ss->UpdateQuotaInformationForFile(file);
+        NS_ENSURE_SUCCESS(rv, rv);
+      }
     }
     else {
       rv = file->Remove(false);
       if (NS_FAILED(rv)) {
         NS_WARNING("Failed to remove orphaned file!");
       }
     }
   }
--- a/dom/indexedDB/FileManager.h
+++ b/dom/indexedDB/FileManager.h
@@ -55,17 +55,18 @@ public:
   }
 
   bool Invalidated() const
   {
     return mInvalidated;
   }
 
   nsresult Init(nsIFile* aDirectory,
-                mozIStorageConnection* aConnection);
+                mozIStorageConnection* aConnection,
+                FactoryPrivilege aPrivilege);
 
   nsresult Load(mozIStorageConnection* aConnection);
 
   nsresult Invalidate();
 
   already_AddRefed<nsIFile> GetDirectory();
 
   already_AddRefed<FileInfo> GetFileInfo(PRInt64 aId);
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -728,17 +728,17 @@ IndexedDatabaseManager::SetCurrentWindow
 PRUint32
 IndexedDatabaseManager::GetIndexedDBQuotaMB()
 {
   return PRUint32(NS_MAX(gIndexedDBQuotaMB, 0));
 }
 
 nsresult
 IndexedDatabaseManager::EnsureOriginIsInitialized(const nsACString& aOrigin,
-                                                  FactoryPrivilege mPrivilege,
+                                                  FactoryPrivilege aPrivilege,
                                                   nsIFile** aDirectory)
 {
 #ifdef DEBUG
   {
     bool correctThread;
     NS_ASSERTION(NS_SUCCEEDED(mIOThread->IsOnCurrentThread(&correctThread)) &&
                  correctThread,
                  "Running on the wrong thread!");
@@ -781,17 +781,17 @@ IndexedDatabaseManager::EnsureOriginIsIn
   rv = patternFile->GetNativePath(pattern);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Now tell SQLite to start tracking this pattern for content.
   nsCOMPtr<mozIStorageServiceQuotaManagement> ss =
     do_GetService(MOZ_STORAGE_SERVICE_CONTRACTID);
   NS_ENSURE_TRUE(ss, NS_ERROR_FAILURE);
 
-  if (mPrivilege != Chrome) {
+  if (aPrivilege != Chrome) {
     rv = ss->SetQuotaForFilenamePattern(pattern,
                                         GetIndexedDBQuotaMB() * 1024 * 1024,
                                         mQuotaCallbackSingleton, nsnull);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // We need to see if there are any files in the directory already. If they
   // are database files then we need to create file managers for them and also
@@ -873,22 +873,22 @@ IndexedDatabaseManager::EnsureOriginIsIn
     }
 
     nsString databaseName;
     rv = stmt->GetString(0, databaseName);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsRefPtr<FileManager> fileManager = new FileManager(aOrigin, databaseName);
 
-    rv = fileManager->Init(fileManagerDirectory, connection);
+    rv = fileManager->Init(fileManagerDirectory, connection, aPrivilege);
     NS_ENSURE_SUCCESS(rv, rv);
 
     fileManagers->AppendElement(fileManager);
 
-    if (mPrivilege != Chrome) {
+    if (aPrivilege != Chrome) {
       rv = ss->UpdateQuotaInformationForFile(file);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     validSubdirs.PutEntry(dbBaseFilename);
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/indexedDB/OpenDatabaseHelper.cpp
+++ b/dom/indexedDB/OpenDatabaseHelper.cpp
@@ -1686,17 +1686,17 @@ OpenDatabaseHelper::DoDatabaseWork()
   if (mCurrentVersion != mRequestedVersion) {
     mState = eSetVersionPending;
   }
 
   mFileManager = mgr->GetOrCreateFileManager(mASCIIOrigin, mName);
   NS_ENSURE_TRUE(mFileManager, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
 
   if (!mFileManager->Inited()) {
-    rv = mFileManager->Init(fileManagerDirectory, connection);
+    rv = mFileManager->Init(fileManagerDirectory, connection, mPrivilege);
     NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
   }
 
   if (!mFileManager->Loaded()) {
     rv = mFileManager->Load(connection);
     NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
   }