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

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

Issue 2517383008: [Offline pages] Adding GetRequestsTask to RequestQueue (Closed)
Patch Set: Addressing CR feedback Created 4 years 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
« no previous file with comments | « components/offline_pages/background/get_requests_task_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "components/offline_pages/background/request_queue.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "components/offline_pages/background/change_requests_state_task.h" 12 #include "components/offline_pages/background/change_requests_state_task.h"
13 #include "components/offline_pages/background/get_requests_task.h"
13 #include "components/offline_pages/background/mark_attempt_aborted_task.h" 14 #include "components/offline_pages/background/mark_attempt_aborted_task.h"
14 #include "components/offline_pages/background/mark_attempt_completed_task.h" 15 #include "components/offline_pages/background/mark_attempt_completed_task.h"
15 #include "components/offline_pages/background/mark_attempt_started_task.h" 16 #include "components/offline_pages/background/mark_attempt_started_task.h"
16 #include "components/offline_pages/background/pick_request_task.h" 17 #include "components/offline_pages/background/pick_request_task.h"
17 #include "components/offline_pages/background/pick_request_task_factory.h" 18 #include "components/offline_pages/background/pick_request_task_factory.h"
18 #include "components/offline_pages/background/remove_requests_task.h" 19 #include "components/offline_pages/background/remove_requests_task.h"
19 #include "components/offline_pages/background/request_queue_store.h" 20 #include "components/offline_pages/background/request_queue_store.h"
20 #include "components/offline_pages/background/save_page_request.h" 21 #include "components/offline_pages/background/save_page_request.h"
21 22
22 namespace offline_pages { 23 namespace offline_pages {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 60 }
60 61
61 } // namespace 62 } // namespace
62 63
63 RequestQueue::RequestQueue(std::unique_ptr<RequestQueueStore> store) 64 RequestQueue::RequestQueue(std::unique_ptr<RequestQueueStore> store)
64 : store_(std::move(store)), weak_ptr_factory_(this) {} 65 : store_(std::move(store)), weak_ptr_factory_(this) {}
65 66
66 RequestQueue::~RequestQueue() {} 67 RequestQueue::~RequestQueue() {}
67 68
68 void RequestQueue::GetRequests(const GetRequestsCallback& callback) { 69 void RequestQueue::GetRequests(const GetRequestsCallback& callback) {
69 store_->GetRequests(base::Bind(&GetRequestsDone, callback)); 70 std::unique_ptr<Task> task(new GetRequestsTask(
71 store_.get(), base::Bind(&GetRequestsDone, callback)));
72 task_queue_.AddTask(std::move(task));
70 } 73 }
71 74
72 void RequestQueue::AddRequest(const SavePageRequest& request, 75 void RequestQueue::AddRequest(const SavePageRequest& request,
73 const AddRequestCallback& callback) { 76 const AddRequestCallback& callback) {
74 // TODO(fgorski): check that request makes sense. 77 // TODO(fgorski): check that request makes sense.
75 // TODO(fgorski): check that request does not violate policy. 78 // TODO(fgorski): check that request does not violate policy.
76 store_->AddRequest(request, base::Bind(&AddRequestDone, callback, request)); 79 store_->AddRequest(request, base::Bind(&AddRequestDone, callback, request));
77 } 80 }
78 81
79 void RequestQueue::RemoveRequests(const std::vector<int64_t>& request_ids, 82 void RequestQueue::RemoveRequests(const std::vector<int64_t>& request_ids,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 std::unique_ptr<Task> task(picker_factory_->CreatePickerTask( 128 std::unique_ptr<Task> task(picker_factory_->CreatePickerTask(
126 store_.get(), picked_callback, not_picked_callback, 129 store_.get(), picked_callback, not_picked_callback,
127 request_count_callback, conditions, disabled_requests)); 130 request_count_callback, conditions, disabled_requests));
128 131
129 // Queue up the picking task, it will call one of the callbacks when it 132 // Queue up the picking task, it will call one of the callbacks when it
130 // completes. 133 // completes.
131 task_queue_.AddTask(std::move(task)); 134 task_queue_.AddTask(std::move(task));
132 } 135 }
133 136
134 } // namespace offline_pages 137 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/background/get_requests_task_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698