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

Side by Side Diff: components/offline_pages/background/request_queue_in_memory_store.cc

Issue 2053163002: [Offline pages] Adding persistent request queue based on SQLite (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/background/request_queue_in_memory_store.h" 5 #include "components/offline_pages/background/request_queue_in_memory_store.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "components/offline_pages/background/save_page_request.h" 10 #include "components/offline_pages/background/save_page_request.h"
(...skipping 25 matching lines...) Expand all
36 requests_.insert(std::make_pair(request.request_id(), request)); 36 requests_.insert(std::make_pair(request.request_id(), request));
37 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 37 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
38 base::Bind(callback, status)); 38 base::Bind(callback, status));
39 } 39 }
40 40
41 void RequestQueueInMemoryStore::RemoveRequests( 41 void RequestQueueInMemoryStore::RemoveRequests(
42 const std::vector<int64_t>& request_ids, 42 const std::vector<int64_t>& request_ids,
43 const RemoveCallback& callback) { 43 const RemoveCallback& callback) {
44 // In case the |request_ids| is empty, the result will be true, but the count 44 // In case the |request_ids| is empty, the result will be true, but the count
45 // of deleted pages will be empty. 45 // of deleted pages will be empty.
46 bool result = true; 46 bool result = true;
Pete Williamson 2016/06/14 21:54:45 If result is never false, do we still need it in t
fgorski 2016/06/14 22:38:05 done.
47 int count = 0; 47 int count = 0;
48 RequestsMap::iterator iter; 48 RequestsMap::iterator iter;
49 for (auto request_id : request_ids) { 49 for (auto request_id : request_ids) {
50 iter = requests_.find(request_id); 50 iter = requests_.find(request_id);
51 if (iter != requests_.end()) { 51 if (iter != requests_.end()) {
52 requests_.erase(iter); 52 requests_.erase(iter);
53 ++count; 53 ++count;
54 } else {
55 result = false;
56 } 54 }
57 } 55 }
58 56
59 base::ThreadTaskRunnerHandle::Get()->PostTask( 57 base::ThreadTaskRunnerHandle::Get()->PostTask(
60 FROM_HERE, base::Bind(callback, result, count)); 58 FROM_HERE, base::Bind(callback, result, count));
61 } 59 }
62 60
63 void RequestQueueInMemoryStore::Reset(const ResetCallback& callback) { 61 void RequestQueueInMemoryStore::Reset(const ResetCallback& callback) {
64 requests_.clear(); 62 requests_.clear();
65 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 63 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
66 base::Bind(callback, true)); 64 base::Bind(callback, true));
67 } 65 }
68 66
69 } // namespace offline_pages 67 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698