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

Unified Diff: components/offline_pages/background/request_coordinator.cc

Issue 2467333003: [Offline Pages] Coordinator checks for net connection before starting next req (Closed)
Patch Set: Got tests running Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/background/request_coordinator.cc
diff --git a/components/offline_pages/background/request_coordinator.cc b/components/offline_pages/background/request_coordinator.cc
index 120c08db9b92122170187545e8727f4c00faff31..87b8f9ccbd7b5e0512d8672950a4d23ca2047c10 100644
--- a/components/offline_pages/background/request_coordinator.cc
+++ b/components/offline_pages/background/request_coordinator.cc
@@ -474,7 +474,6 @@ bool RequestCoordinator::StartProcessingInternal(
current_conditions_.reset(new DeviceConditions(device_conditions));
if (is_starting_ || is_busy_)
return false;
- is_starting_ = true;
processing_state_ = processing_state;
scheduler_callback_ = callback;
@@ -533,6 +532,7 @@ RequestCoordinator::TryImmediateStart() {
}
void RequestCoordinator::TryNextRequest() {
+ is_starting_ = true;
base::TimeDelta processing_time_budget;
if (processing_state_ == ProcessingWindowState::SCHEDULED_WINDOW) {
processing_time_budget = base::TimeDelta::FromSeconds(
@@ -543,11 +543,13 @@ void RequestCoordinator::TryNextRequest() {
policy_->GetProcessingTimeBudgetForImmediateLoadInSeconds());
}
- // If there is no time left in the budget, return to the scheduler.
- // We do not remove the pending task that was set up earlier in case
- // we run out of time, so the background scheduler will return to us
- // at the next opportunity to run background tasks.
- if ((base::Time::Now() - operation_start_time_) > processing_time_budget) {
+ // If there is no network or no time left in the budget, return to the
+ // scheduler. We do not remove the pending scheduler task that was set
+ // up earlier in case we run out of time, so the background scheduler
+ // will return to us at the next opportunity to run background tasks.
+ if (GetConnectionType() ==
+ net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE ||
+ (base::Time::Now() - operation_start_time_) > processing_time_budget) {
is_starting_ = false;
// Let the scheduler know we are done processing.
« 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