| OLD | NEW |
| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 callback.Run(requests); | 105 callback.Run(requests); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void RequestCoordinator::RemoveRequests( | 108 void RequestCoordinator::RemoveRequests( |
| 109 const std::vector<int64_t>& request_ids) { | 109 const std::vector<int64_t>& request_ids) { |
| 110 queue_->RemoveRequests(request_ids, | 110 queue_->RemoveRequests(request_ids, |
| 111 base::Bind(&RequestCoordinator::RemoveRequestsCallback, | 111 base::Bind(&RequestCoordinator::RemoveRequestsCallback, |
| 112 weak_ptr_factory_.GetWeakPtr())); | 112 weak_ptr_factory_.GetWeakPtr())); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void RequestCoordinator::PauseRequests( |
| 116 const std::vector<int64_t>& request_ids) { |
| 117 queue_->ChangeRequestsState( |
| 118 request_ids, SavePageRequest::RequestState::PAUSED, |
| 119 base::Bind(&RequestCoordinator::UpdateMultipleRequestCallback, |
| 120 weak_ptr_factory_.GetWeakPtr())); |
| 121 } |
| 122 |
| 123 void RequestCoordinator::ResumeRequests( |
| 124 const std::vector<int64_t>& request_ids) { |
| 125 queue_->ChangeRequestsState( |
| 126 request_ids, SavePageRequest::RequestState::AVAILABLE, |
| 127 base::Bind(&RequestCoordinator::UpdateMultipleRequestCallback, |
| 128 weak_ptr_factory_.GetWeakPtr())); |
| 129 // TODO: Should we also schedule a task, in case there is not one scheduled? |
| 130 } |
| 131 |
| 115 void RequestCoordinator::AddRequestResultCallback( | 132 void RequestCoordinator::AddRequestResultCallback( |
| 116 RequestQueue::AddRequestResult result, | 133 RequestQueue::AddRequestResult result, |
| 117 const SavePageRequest& request) { | 134 const SavePageRequest& request) { |
| 118 | 135 |
| 119 // Inform the scheduler that we have an outstanding task.. | 136 // Inform the scheduler that we have an outstanding task.. |
| 120 scheduler_->Schedule(GetTriggerConditionsForUserRequest()); | 137 scheduler_->Schedule(GetTriggerConditionsForUserRequest()); |
| 121 } | 138 } |
| 122 | 139 |
| 123 // Called in response to updating a request in the request queue. | 140 // Called in response to updating a request in the request queue. |
| 124 void RequestCoordinator::UpdateRequestCallback( | 141 void RequestCoordinator::UpdateRequestCallback( |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 return trigger_conditions; | 371 return trigger_conditions; |
| 355 } | 372 } |
| 356 | 373 |
| 357 void RequestCoordinator::GetOffliner() { | 374 void RequestCoordinator::GetOffliner() { |
| 358 if (!offliner_) { | 375 if (!offliner_) { |
| 359 offliner_ = factory_->GetOffliner(policy_.get()); | 376 offliner_ = factory_->GetOffliner(policy_.get()); |
| 360 } | 377 } |
| 361 } | 378 } |
| 362 | 379 |
| 363 } // namespace offline_pages | 380 } // namespace offline_pages |
| OLD | NEW |