Bug 1194319 - Correctly deal with all possible ways that initializing the permission manager DB connection can fail; r=mystor
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 18 Aug 2015 15:37:12 -0400
changeset 258298 9cf478be459a0f719a156b1a61b4c102e00bd705
parent 258297 9cd3be664954cedf3b3924a558754514b5a9cbff
child 258299 18f274867bcc02231fe2eefa837ca2c7a2d92528
push id29249
push userryanvm@gmail.com
push dateWed, 19 Aug 2015 11:17:27 +0000
treeherdermozilla-central@706b23a03d1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmystor
bugs1194319
milestone43.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 1194319 - Correctly deal with all possible ways that initializing the permission manager DB connection can fail; r=mystor
extensions/cookie/nsPermissionManager.cpp
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -841,32 +841,32 @@ nsPermissionManager::InitDB(bool aRemove
     NS_ENSURE_SUCCESS(rv, rv);
     if (exists) {
       rv = permissionsFile->Remove(false);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   rv = OpenDatabase(permissionsFile);
-  if (rv == NS_ERROR_UNEXPECTED) {
-    return rv;
-  } else if (rv == NS_ERROR_FILE_CORRUPTED) {
+  if (rv == NS_ERROR_FILE_CORRUPTED) {
     LogToConsole(NS_LITERAL_STRING("permissions.sqlite is corrupted! Try again!"));
 
     // Add telemetry probe
     mozilla::Telemetry::Accumulate(mozilla::Telemetry::PERMISSIONS_SQL_CORRUPTED, 1);
 
     // delete corrupted permissions.sqlite and try again
     rv = permissionsFile->Remove(false);
     NS_ENSURE_SUCCESS(rv, rv);
     LogToConsole(NS_LITERAL_STRING("Corrupted permissions.sqlite has been removed."));
 
     rv = OpenDatabase(permissionsFile);
     NS_ENSURE_SUCCESS(rv, rv);
     LogToConsole(NS_LITERAL_STRING("OpenDatabase to permissions.sqlite is successful!"));
+  } else if (NS_FAILED(rv)) {
+    return rv;
   }
 
   bool ready;
   mDBConn->GetConnectionReady(&ready);
   if (!ready) {
     LogToConsole(NS_LITERAL_STRING("Fail to get connection to permissions.sqlite! Try again!"));
 
     // delete and try again