Bug 541356 - session lost after restart. Part 1: Fix AddCookieToList(). r=sdwilsh

This commit is contained in:
Dan Witte 2010-05-24 18:09:34 -07:00
parent 91c79aee06
commit 8ac39437d3

View File

@ -2911,18 +2911,21 @@ nsCookieService::AddCookieToList(const nsCString &aBaseDomain,
// if it's a non-session cookie and hasn't just been read from the db, write it out. // if it's a non-session cookie and hasn't just been read from the db, write it out.
if (aWriteToDB && !aCookie->IsSession() && mDBState->dbConn) { if (aWriteToDB && !aCookie->IsSession() && mDBState->dbConn) {
nsCOMPtr<mozIStorageBindingParamsArray> array(aParamsArray); mozIStorageStatement *stmt = mDBState->stmtInsert;
if (!array) { nsCOMPtr<mozIStorageBindingParamsArray> paramsArray(aParamsArray);
mDBState->stmtInsert->NewBindingParamsArray(getter_AddRefs(array)); if (!paramsArray) {
stmt->NewBindingParamsArray(getter_AddRefs(paramsArray));
} }
bindCookieParameters(array, aCookie); bindCookieParameters(paramsArray, aCookie);
// If we were supplied an array to store parameters, we shouldn't call // If we were supplied an array to store parameters, we shouldn't call
// executeAsync - someone up the stack will do this for us. // executeAsync - someone up the stack will do this for us.
if (!aParamsArray) { if (!aParamsArray) {
nsresult rv = stmt->BindParameters(paramsArray);
NS_ASSERT_SUCCESS(rv);
nsCOMPtr<mozIStoragePendingStatement> handle; nsCOMPtr<mozIStoragePendingStatement> handle;
nsresult rv = mDBState->stmtInsert->ExecuteAsync(&sInsertCookieDBListener, rv = stmt->ExecuteAsync(&sInsertCookieDBListener,
getter_AddRefs(handle)); getter_AddRefs(handle));
NS_ASSERT_SUCCESS(rv); NS_ASSERT_SUCCESS(rv);
} }
} }