| Index: components/offline_pages/background/request_queue_in_memory_store.cc
|
| diff --git a/components/offline_pages/background/request_queue_in_memory_store.cc b/components/offline_pages/background/request_queue_in_memory_store.cc
|
| index defb87e311ffed9c84328e47b31764f9da3d00d9..1aeeee91728e0db855663f82c1397b8e20219b1e 100644
|
| --- a/components/offline_pages/background/request_queue_in_memory_store.cc
|
| +++ b/components/offline_pages/background/request_queue_in_memory_store.cc
|
| @@ -39,7 +39,7 @@ void RequestQueueInMemoryStore::RemoveRequests(
|
| const std::vector<int64_t>& request_ids,
|
| const RemoveCallback& callback) {
|
| // In case the |request_ids| is empty, the result will be true, but the count
|
| - // of deleted pages will be empty.
|
| + // of deleted pages will be 0.
|
| int count = 0;
|
| RequestsMap::iterator iter;
|
| for (auto request_id : request_ids) {
|
| @@ -54,6 +54,34 @@ void RequestQueueInMemoryStore::RemoveRequests(
|
| FROM_HERE, base::Bind(callback, true, count));
|
| }
|
|
|
| +void RequestQueueInMemoryStore::RemoveRequestsByClientId(
|
| + const std::vector<ClientId>& client_ids,
|
| + const RemoveCallback& callback) {
|
| + // In case the |client_ids| is empty, the result will be true, but the count
|
| + // of deleted pages will be 0.
|
| + int count = 0;
|
| +
|
| + // Once for each client id in our list
|
| + for (auto client_id : client_ids) {
|
| + // Check it against each request in the store.
|
| + for (auto iter = requests_.begin();
|
| + iter != requests_.end();
|
| + ++iter) {
|
| + // Check against each incoming client ID, and delete if we have a match.
|
| + if ((*iter).second.client_id() == client_id) {
|
| + requests_.erase(iter);
|
| + // This delete will invalidate the iterator, so move on to the next
|
| + // entry.
|
| + ++count;
|
| + break;
|
| + }
|
| + }
|
| + }
|
| +
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE, base::Bind(callback, true, count));
|
| +}
|
| +
|
| void RequestQueueInMemoryStore::Reset(const ResetCallback& callback) {
|
| requests_.clear();
|
| base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
|
|