Bug 595925 - Use OpenUnsharedDatabase in cookies. r=sdwilsh, a=final+

This commit is contained in:
Dan Witte 2010-10-19 17:24:52 -07:00
parent a55ee59f45
commit 63fc2399a4
2 changed files with 9 additions and 14 deletions

View File

@ -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;

View File

@ -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.
*