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

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: DCHECK in default case 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:
238 case Offliner::RequestStatus::SAVE_FAILED:
239 case Offliner::RequestStatus::REQUEST_COORDINATOR_CANCELED: // timeout
240 case Offliner::RequestStatus::PRERENDERING_CANCELED:
241 // Consider processing another request in this service window.
242 TryNextRequest();
243 break;
244 case Offliner::RequestStatus::FOREGROUND_CANCELED:
fgorski 2016/08/03 16:18:59 I think you might be missing UNKNOWN and LOADED.
dougarnett 2016/08/03 16:44:08 Right, actually intentional here as those are inte
245 case Offliner::RequestStatus::PRERENDERING_FAILED:
246 // No further processing in this service window.
247 break;
248 default:
249 // Make explicit choice about new status codes that actually reach here.
250 // Their default is no further processing in this service window.
251 DCHECK(false);
252 }
232 } 253 }
233 254
234 const Scheduler::TriggerConditions 255 const Scheduler::TriggerConditions
235 RequestCoordinator::GetTriggerConditionsForUserRequest() { 256 RequestCoordinator::GetTriggerConditionsForUserRequest() {
236 Scheduler::TriggerConditions trigger_conditions( 257 Scheduler::TriggerConditions trigger_conditions(
237 policy_->PowerRequiredForUserRequestedPage(), 258 policy_->PowerRequiredForUserRequestedPage(),
238 policy_->BatteryPercentageRequiredForUserRequestedPage(), 259 policy_->BatteryPercentageRequiredForUserRequestedPage(),
239 policy_->UnmeteredNetworkRequiredForUserRequestedPage()); 260 policy_->UnmeteredNetworkRequiredForUserRequestedPage());
240 return trigger_conditions; 261 return trigger_conditions;
241 } 262 }
242 263
243 void RequestCoordinator::GetOffliner() { 264 void RequestCoordinator::GetOffliner() {
244 if (!offliner_) { 265 if (!offliner_) {
245 offliner_ = factory_->GetOffliner(policy_.get()); 266 offliner_ = factory_->GetOffliner(policy_.get());
246 } 267 }
247 } 268 }
248 269
249 } // namespace offline_pages 270 } // 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