зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1370456 - Batch operations for nsCookieService, r=jduell
--HG-- extra : rebase_source : 0a2788a1d6d8d650f1ccdcdc4c7e875e6c5aabac
This commit is contained in:
Родитель
3227b2735a
Коммит
515d0e58e1
|
@ -2726,6 +2726,7 @@ nsCookieService::AsyncReadComplete()
|
|||
NS_ASSERTION(mDefaultDBState->pendingRead, "no pending read");
|
||||
NS_ASSERTION(mDefaultDBState->readListener, "no read listener");
|
||||
|
||||
mozStorageTransaction transaction(mDefaultDBState->dbConn, false);
|
||||
// Merge the data read on the background thread with the data synchronously
|
||||
// read on the main thread. Note that transactions on the cookie table may
|
||||
// have occurred on the main thread since, making the background data stale.
|
||||
|
@ -2740,6 +2741,8 @@ nsCookieService::AsyncReadComplete()
|
|||
|
||||
AddCookieToList(tuple.key, tuple.cookie, mDefaultDBState, nullptr, false);
|
||||
}
|
||||
DebugOnly<nsresult> rv = transaction.Commit();
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
mDefaultDBState->stmtReadDomain = nullptr;
|
||||
mDefaultDBState->pendingRead = nullptr;
|
||||
|
@ -2864,11 +2867,14 @@ nsCookieService::EnsureReadDomain(const nsCookieKey &aKey)
|
|||
aKey.mOriginAttributes));
|
||||
}
|
||||
|
||||
mozStorageTransaction transaction(mDefaultDBState->dbConn, false);
|
||||
// Add the cookies to the table in a single operation. This makes sure that
|
||||
// either all the cookies get added, or in the case of corruption, none.
|
||||
for (uint32_t i = 0; i < array.Length(); ++i) {
|
||||
AddCookieToList(aKey, array[i], mDefaultDBState, nullptr, false);
|
||||
}
|
||||
rv = transaction.Commit();
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
// Add it to the hashset of read entries, so we don't read it again.
|
||||
mDefaultDBState->readSet.PutEntry(aKey);
|
||||
|
@ -2956,6 +2962,7 @@ nsCookieService::EnsureReadComplete()
|
|||
tuple->cookie = GetCookieFromRow(stmt, attrs);
|
||||
}
|
||||
|
||||
mozStorageTransaction transaction(mDefaultDBState->dbConn, false);
|
||||
// Add the cookies to the table in a single operation. This makes sure that
|
||||
// either all the cookies get added, or in the case of corruption, none.
|
||||
for (uint32_t i = 0; i < array.Length(); ++i) {
|
||||
|
@ -2963,6 +2970,8 @@ nsCookieService::EnsureReadComplete()
|
|||
AddCookieToList(tuple.key, tuple.cookie, mDefaultDBState, nullptr,
|
||||
false);
|
||||
}
|
||||
rv = transaction.Commit();
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
mDefaultDBState->syncConn = nullptr;
|
||||
mDefaultDBState->readSet.Clear();
|
||||
|
@ -4899,6 +4908,7 @@ nsCookieService::RemoveCookiesWithOriginAttributes(
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
mozStorageTransaction transaction(mDBState->dbConn, false);
|
||||
// Iterate the hash table of nsCookieEntry.
|
||||
for (auto iter = mDBState->hostTable.Iter(); !iter.Done(); iter.Next()) {
|
||||
nsCookieEntry* entry = iter.Get();
|
||||
|
@ -4931,6 +4941,8 @@ nsCookieService::RemoveCookiesWithOriginAttributes(
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
DebugOnly<nsresult> rv = transaction.Commit();
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче