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

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

Issue 2197573003: Provide API in RequestCoordinator to remove results by client ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback per DougArnett 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // If the client does not need the pages after all, then cancel them.
dougarnett 2016/08/01 18:28:35 drop comment here - just keep .h comment up-to-dat
Pete Williamson 2016/08/01 23:23:07 Done.
74 void RequestCoordinator::RemoveRequests(
75 const std::vector<ClientId>& client_ids) {
76
77 queue_->RemoveRequestsByClientId(
78 client_ids,
79 base::Bind(&RequestCoordinator::UpdateRequestCallback,
80 weak_ptr_factory_.GetWeakPtr()));
81 }
82
73 void RequestCoordinator::AddRequestResultCallback( 83 void RequestCoordinator::AddRequestResultCallback(
74 RequestQueue::AddRequestResult result, 84 RequestQueue::AddRequestResult result,
75 const SavePageRequest& request) { 85 const SavePageRequest& request) {
76 86
77 // Inform the scheduler that we have an outstanding task.. 87 // Inform the scheduler that we have an outstanding task..
78 scheduler_->Schedule(GetTriggerConditionsForUserRequest()); 88 scheduler_->Schedule(GetTriggerConditionsForUserRequest());
79 } 89 }
80 90
81 // Called in response to updating a request in the request queue. 91 // Called in response to updating a request in the request queue.
82 void RequestCoordinator::UpdateRequestCallback( 92 void RequestCoordinator::UpdateRequestCallback(
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return trigger_conditions; 250 return trigger_conditions;
241 } 251 }
242 252
243 void RequestCoordinator::GetOffliner() { 253 void RequestCoordinator::GetOffliner() {
244 if (!offliner_) { 254 if (!offliner_) {
245 offliner_ = factory_->GetOffliner(policy_.get()); 255 offliner_ = factory_->GetOffliner(policy_.get());
246 } 256 }
247 } 257 }
248 258
249 } // namespace offline_pages 259 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698