Chromium Code Reviews| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 offline_pages::SavePageRequest request( | 63 offline_pages::SavePageRequest request( |
| 64 id++, url, client_id, base::Time::Now(), was_user_requested); | 64 id++, url, client_id, base::Time::Now(), was_user_requested); |
| 65 | 65 |
| 66 // Put the request on the request queue. | 66 // Put the request on the request queue. |
| 67 queue_->AddRequest(request, | 67 queue_->AddRequest(request, |
| 68 base::Bind(&RequestCoordinator::AddRequestResultCallback, | 68 base::Bind(&RequestCoordinator::AddRequestResultCallback, |
| 69 weak_ptr_factory_.GetWeakPtr())); | 69 weak_ptr_factory_.GetWeakPtr())); |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void RequestCoordinator::RemoveRequests( | |
| 74 const std::vector<ClientId>& client_ids) { | |
| 75 | |
|
fgorski
2016/08/02 05:01:22
nit: remove empty line.
Pete Williamson
2016/08/02 23:27:16
Done.
| |
| 76 queue_->RemoveRequestsByClientId( | |
| 77 client_ids, | |
| 78 base::Bind(&RequestCoordinator::UpdateRequestCallback, | |
| 79 weak_ptr_factory_.GetWeakPtr())); | |
| 80 } | |
| 81 | |
| 73 void RequestCoordinator::AddRequestResultCallback( | 82 void RequestCoordinator::AddRequestResultCallback( |
| 74 RequestQueue::AddRequestResult result, | 83 RequestQueue::AddRequestResult result, |
| 75 const SavePageRequest& request) { | 84 const SavePageRequest& request) { |
| 76 | 85 |
| 77 // Inform the scheduler that we have an outstanding task.. | 86 // Inform the scheduler that we have an outstanding task.. |
| 78 scheduler_->Schedule(GetTriggerConditionsForUserRequest()); | 87 scheduler_->Schedule(GetTriggerConditionsForUserRequest()); |
| 79 } | 88 } |
| 80 | 89 |
| 81 // Called in response to updating a request in the request queue. | 90 // Called in response to updating a request in the request queue. |
| 82 void RequestCoordinator::UpdateRequestCallback( | 91 void RequestCoordinator::UpdateRequestCallback( |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 return trigger_conditions; | 249 return trigger_conditions; |
| 241 } | 250 } |
| 242 | 251 |
| 243 void RequestCoordinator::GetOffliner() { | 252 void RequestCoordinator::GetOffliner() { |
| 244 if (!offliner_) { | 253 if (!offliner_) { |
| 245 offliner_ = factory_->GetOffliner(policy_.get()); | 254 offliner_ = factory_->GetOffliner(policy_.get()); |
| 246 } | 255 } |
| 247 } | 256 } |
| 248 | 257 |
| 249 } // namespace offline_pages | 258 } // namespace offline_pages |
| OLD | NEW |