Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: net/extras/sqlite/sqlite_channel_id_store.cc

Issue 2874973002: Flush Channel IDs when Cookies get saved to a persistent backend (Closed)
Patch Set: Initialize channel_id_service to nullptr Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/extras/sqlite/sqlite_channel_id_store.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/extras/sqlite/sqlite_channel_id_store.cc
diff --git a/net/extras/sqlite/sqlite_channel_id_store.cc b/net/extras/sqlite/sqlite_channel_id_store.cc
index 56c6f6b9c03c52e8ffc08da9e5f8d8864d2c9cef..10fb2f974871b24d2ac12684719181c7f8a4bc57 100644
--- a/net/extras/sqlite/sqlite_channel_id_store.cc
+++ b/net/extras/sqlite/sqlite_channel_id_store.cc
@@ -100,6 +100,9 @@ class SQLiteChannelIDStore::Backend
void SetForceKeepSessionState();
+ // Posts a task to flush pending operations to the database.
+ void Flush();
+
private:
friend class base::RefCountedThreadSafe<SQLiteChannelIDStore::Backend>;
@@ -481,17 +484,10 @@ void SQLiteChannelIDStore::Backend::DeleteAllInList(
void SQLiteChannelIDStore::Backend::BatchOperation(
PendingOperation::OperationType op,
const DefaultChannelIDStore::ChannelID& channel_id) {
- // These thresholds used to be 30 seconds or 512 outstanding operations (the
- // same values used in CookieMonster). Since cookies can be bound to Channel
- // IDs, it's possible for a cookie to get committed to the cookie database
- // before the Channel ID it is bound to gets committed. Decreasing these
- // thresholds increases the chance that the Channel ID will be committed
- // before or at the same time as the cookie.
-
- // Commit every 2 seconds.
- static const int kCommitIntervalMs = 2 * 1000;
- // Commit right away if we have more than 3 outstanding operations.
- static const size_t kCommitAfterBatchSize = 3;
+ // Commit every 30 seconds.
+ static const int kCommitIntervalMs = 30 * 1000;
+ // Commit right away if we have more than 512 outstanding operations.
+ static const size_t kCommitAfterBatchSize = 512;
// We do a full copy of the cert here, and hopefully just here.
std::unique_ptr<PendingOperation> po(new PendingOperation(op, channel_id));
@@ -538,6 +534,11 @@ void SQLiteChannelIDStore::Backend::PrunePendingOperationsForDeletes(
}
}
+void SQLiteChannelIDStore::Backend::Flush() {
+ background_task_runner_->PostTask(FROM_HERE,
+ base::Bind(&Backend::Commit, this));
+}
+
void SQLiteChannelIDStore::Backend::Commit() {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
@@ -687,6 +688,10 @@ void SQLiteChannelIDStore::SetForceKeepSessionState() {
backend_->SetForceKeepSessionState();
}
+void SQLiteChannelIDStore::Flush() {
+ backend_->Flush();
+}
+
SQLiteChannelIDStore::~SQLiteChannelIDStore() {
backend_->Close();
// We release our reference to the Backend, though it will probably still have
« no previous file with comments | « net/extras/sqlite/sqlite_channel_id_store.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698