Chromium Code Reviews| 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 d7edf9c170dd39710a5a46f45e71b2c6cd6e8fd3..d94708ebdd00a1f135e7dd189adb5cf698ee4b86 100644 |
| --- a/net/extras/sqlite/sqlite_channel_id_store.cc |
| +++ b/net/extras/sqlite/sqlite_channel_id_store.cc |
| @@ -127,6 +127,10 @@ class SQLiteChannelIDStore::Backend |
| // Batch a channel id operation (add or delete). |
| void BatchOperation(PendingOperation::OperationType op, |
| const DefaultChannelIDStore::ChannelID& channel_id); |
| + // Prunes the list of pending operations to remove any operations for an |
| + // identifier in |server_identifiers|. |
| + void PrunePendingOperationsForDeletes( |
| + const std::list<std::string>& server_identifiers); |
| // Commit our pending operations to the database. |
| void Commit(); |
| // Close() executed on the background task runner. |
| @@ -477,6 +481,28 @@ void SQLiteChannelIDStore::Backend::BatchOperation( |
| } |
| } |
| +void SQLiteChannelIDStore::Backend::PrunePendingOperationsForDeletes( |
| + const std::list<std::string>& server_identifiers) { |
| + DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
| + base::AutoLock locked(lock_); |
|
rohitrao (ping after 24h)
2015/04/06 18:42:22
I did not see a way to avoid locking around this w
|
| + |
| + for (PendingOperationsList::iterator it = pending_.begin(); |
| + it != pending_.end();) { |
| + bool remove = |
| + std::find(server_identifiers.begin(), server_identifiers.end(), |
| + (*it)->channel_id().server_identifier()) != |
| + server_identifiers.end(); |
| + |
| + if (remove) { |
| + scoped_ptr<PendingOperation> po(*it); |
| + it = pending_.erase(it); |
| + --num_pending_; |
| + } else { |
| + ++it; |
| + } |
| + } |
| +} |
| + |
| void SQLiteChannelIDStore::Backend::Commit() { |
| DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
| @@ -567,6 +593,9 @@ void SQLiteChannelIDStore::Backend::BackgroundDeleteAllInList( |
| if (!db_.get()) |
| return; |
| + // Force a commit of any pending writes before issuing deletes. |
|
mef
2015/04/06 20:17:44
I think this comment is stale.
rohitrao (ping after 24h)
2015/04/07 14:21:37
Done.
|
| + PrunePendingOperationsForDeletes(server_identifiers); |
| + |
| sql::Statement del_smt(db_->GetCachedStatement( |
| SQL_FROM_HERE, "DELETE FROM origin_bound_certs WHERE origin=?")); |
| if (!del_smt.is_valid()) { |