diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index 8fdc847d87dd..38dd91d62a83 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -731,9 +731,10 @@ nsCookieService::TryInitDB(PRBool aDeleteExistingDB) } // open a connection to the cookie database, and only cache our connection - // and statements upon success. The connection is opened shared such that - // the main and background threads can operate on the db concurrently. - rv = mStorageService->OpenDatabase(cookieFile, getter_AddRefs(mDBState->dbConn)); + // and statements upon success. The connection is opened unshared to eliminate + // cache contention between the main and background threads. + rv = mStorageService->OpenUnsharedDatabase(cookieFile, + getter_AddRefs(mDBState->dbConn)); NS_ENSURE_SUCCESS(rv, rv); // Grow cookie db in 512KB increments @@ -882,9 +883,6 @@ nsCookieService::TryInitDB(PRBool aDeleteExistingDB) // make operations on the table asynchronous, for performance mDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING("PRAGMA synchronous = OFF")); - // open in exclusive mode for performance - mDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING("PRAGMA locking_mode = EXCLUSIVE")); - // cache frequently used statements (for insertion, deletion, and updating) rv = mDBState->dbConn->CreateStatement(NS_LITERAL_CSTRING( "INSERT INTO moz_cookies (" @@ -1559,7 +1557,7 @@ nsCookieService::GetSyncDBConn() mDefaultDBState.dbConn->GetDatabaseFile(getter_AddRefs(cookieFile)); NS_ASSERTION(cookieFile, "no cookie file on connection"); - mStorageService->OpenDatabase(cookieFile, + mStorageService->OpenUnsharedDatabase(cookieFile, getter_AddRefs(mDefaultDBState.syncConn)); NS_ASSERTION(mDefaultDBState.syncConn, "can't open sync db connection"); return mDefaultDBState.syncConn; diff --git a/storage/public/mozIStorageService.idl b/storage/public/mozIStorageService.idl index edabb19ff128..2950ee50806a 100644 --- a/storage/public/mozIStorageService.idl +++ b/storage/public/mozIStorageService.idl @@ -111,12 +111,9 @@ interface mozIStorageService : nsISupports { * Each connection uses its own sqlite cache, which is inefficient, so you * should use openDatabase instead of this method unless you need a feature * of SQLite that is incompatible with a shared cache, like virtual table - * and full text indexing support. - * - * Consumers should check mozIStorageConnection::connectionReady to ensure - * that they can use the database. If this value is false, it is strongly - * recommended that the database be backed up with - * mozIStorageConnection::backupDB so user data is not lost. + * and full text indexing support. If cache contention is expected, for + * instance when operating on a database from multiple threads, using + * unshared connections may be a performance win. * * ========== * DANGER @@ -131,7 +128,7 @@ interface mozIStorageService : nsISupports { * use it only from the thread you created it from. * * @param aDatabaseFile - * A nsIFile that represents the database that is to be opened.. + * A nsIFile that represents the database that is to be opened. * * @returns a mozIStorageConnection for the requested database file. *