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

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

Issue 2221323003: Add an API to Pause and Resume background offlining requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback per Dimich Created 4 years, 4 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_coordinator.h" 5 #include "components/offline_pages/background/request_coordinator.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 callback.Run(client_ids); 117 callback.Run(client_ids);
118 } 118 }
119 119
120 void RequestCoordinator::RemoveRequests( 120 void RequestCoordinator::RemoveRequests(
121 const std::vector<ClientId>& client_ids) { 121 const std::vector<ClientId>& client_ids) {
122 queue_->RemoveRequestsByClientId( 122 queue_->RemoveRequestsByClientId(
123 client_ids, base::Bind(&RequestCoordinator::UpdateMultipleRequestCallback, 123 client_ids, base::Bind(&RequestCoordinator::UpdateMultipleRequestCallback,
124 weak_ptr_factory_.GetWeakPtr())); 124 weak_ptr_factory_.GetWeakPtr()));
125 } 125 }
126 126
127 void RequestCoordinator::PauseRequests(
128 const std::vector<int64_t>& request_ids) {
129 queue_->ChangeRequestsState(
130 request_ids, SavePageRequest::RequestState::PAUSED,
131 base::Bind(&RequestCoordinator::UpdateMultipleRequestCallback,
132 weak_ptr_factory_.GetWeakPtr()));
133 }
134
135 void RequestCoordinator::ResumeRequests(
136 const std::vector<int64_t>& request_ids) {
137 queue_->ChangeRequestsState(
138 request_ids, SavePageRequest::RequestState::AVAILABLE,
139 base::Bind(&RequestCoordinator::UpdateMultipleRequestCallback,
140 weak_ptr_factory_.GetWeakPtr()));
141 // TODO: Should we also schedule a task, in case there is not one scheduled?
142 }
143
127 void RequestCoordinator::AddRequestResultCallback( 144 void RequestCoordinator::AddRequestResultCallback(
128 RequestQueue::AddRequestResult result, 145 RequestQueue::AddRequestResult result,
129 const SavePageRequest& request) { 146 const SavePageRequest& request) {
130 147
131 // Inform the scheduler that we have an outstanding task.. 148 // Inform the scheduler that we have an outstanding task..
132 scheduler_->Schedule(GetTriggerConditionsForUserRequest()); 149 scheduler_->Schedule(GetTriggerConditionsForUserRequest());
133 } 150 }
134 151
135 // Called in response to updating a request in the request queue. 152 // Called in response to updating a request in the request queue.
136 void RequestCoordinator::UpdateRequestCallback( 153 void RequestCoordinator::UpdateRequestCallback(
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 return trigger_conditions; 375 return trigger_conditions;
359 } 376 }
360 377
361 void RequestCoordinator::GetOffliner() { 378 void RequestCoordinator::GetOffliner() {
362 if (!offliner_) { 379 if (!offliner_) {
363 offliner_ = factory_->GetOffliner(policy_.get()); 380 offliner_ = factory_->GetOffliner(policy_.get());
364 } 381 }
365 } 382 }
366 383
367 } // namespace offline_pages 384 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698