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

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

Issue 2196293002: Skips processing more SavePageLater requests in current processing window when one completes unsucc… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow processing to continue for some cases with TODO to split PrerenderingFailed 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
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator_unittest.cc » ('j') | 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_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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 updated_request.set_last_attempt_time(base::Time::Now()); 221 updated_request.set_last_attempt_time(base::Time::Now());
222 RequestQueue::UpdateRequestCallback update_callback = 222 RequestQueue::UpdateRequestCallback update_callback =
223 base::Bind(&RequestCoordinator::UpdateRequestCallback, 223 base::Bind(&RequestCoordinator::UpdateRequestCallback,
224 weak_ptr_factory_.GetWeakPtr()); 224 weak_ptr_factory_.GetWeakPtr());
225 queue_->UpdateRequest( 225 queue_->UpdateRequest(
226 updated_request, 226 updated_request,
227 base::Bind(&RequestCoordinator::UpdateRequestCallback, 227 base::Bind(&RequestCoordinator::UpdateRequestCallback,
228 weak_ptr_factory_.GetWeakPtr())); 228 weak_ptr_factory_.GetWeakPtr()));
229 } 229 }
230 230
231 TryNextRequest(); 231 // Determine whether we might try another request in this
232 // processing window based on how the previous request completed.
233 //
234 // TODO(dougarnett): Need to split PRERENDERING_FAILED into separate
235 // codes as to whether we should try another request or not.
236 switch (status) {
237 case Offliner::RequestStatus::SAVED:
fgorski 2016/08/03 03:40:04 It is a bit worrying that you have two scope opera
dougarnett 2016/08/03 15:33:26 worrying? This is part of the Offliner interface s
fgorski 2016/08/03 16:18:59 Acknowledged.
238 case Offliner::RequestStatus::SAVE_FAILED:
239 case Offliner::RequestStatus::REQUEST_COORDINATOR_CANCELED: // timeout
240 case Offliner::RequestStatus::PRERENDERING_CANCELED:
Pete Williamson 2016/08/02 22:20:00 Good! Let's be a bit more explicit for the cases w
dougarnett 2016/08/03 15:33:26 Done.
241 TryNextRequest();
242 break;
243 default:
244 // Stop further processing in this service window.
fgorski 2016/08/03 03:40:05 https://google.github.io/styleguide/cppguide.html#
dougarnett 2016/08/03 15:33:26 Done.
245 break;
246 }
232 } 247 }
233 248
234 const Scheduler::TriggerConditions 249 const Scheduler::TriggerConditions
235 RequestCoordinator::GetTriggerConditionsForUserRequest() { 250 RequestCoordinator::GetTriggerConditionsForUserRequest() {
236 Scheduler::TriggerConditions trigger_conditions( 251 Scheduler::TriggerConditions trigger_conditions(
237 policy_->PowerRequiredForUserRequestedPage(), 252 policy_->PowerRequiredForUserRequestedPage(),
238 policy_->BatteryPercentageRequiredForUserRequestedPage(), 253 policy_->BatteryPercentageRequiredForUserRequestedPage(),
239 policy_->UnmeteredNetworkRequiredForUserRequestedPage()); 254 policy_->UnmeteredNetworkRequiredForUserRequestedPage());
240 return trigger_conditions; 255 return trigger_conditions;
241 } 256 }
242 257
243 void RequestCoordinator::GetOffliner() { 258 void RequestCoordinator::GetOffliner() {
244 if (!offliner_) { 259 if (!offliner_) {
245 offliner_ = factory_->GetOffliner(policy_.get()); 260 offliner_ = factory_->GetOffliner(policy_.get());
246 } 261 }
247 } 262 }
248 263
249 } // namespace offline_pages 264 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698