Chromium Code Reviews| 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 8dcc4d94def87f3cd13e2d2d56eefe69908e5153..458b361265f3c410b266e9d332fc827fa3372c0b 100644 |
| --- a/components/offline_pages/background/request_coordinator.cc |
| +++ b/components/offline_pages/background/request_coordinator.cc |
| @@ -559,8 +559,10 @@ RequestCoordinator::TryImmediateStart() { |
| } |
| if (GetConnectionType() == |
| - net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) |
| + net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) { |
| + RequestConnectedEventForStarting(); |
|
Pete Williamson
2016/12/01 01:34:08
Should we remove ourselves from the notifier when
dougarnett
2016/12/01 19:25:22
Yeah, I'll add as an else here - in case another p
|
| return OfflinerImmediateStartStatus::NO_CONNECTION; |
| + } |
| // Start processing with manufactured conservative battery conditions |
| // (i.e., assume no battery). |
| @@ -574,6 +576,17 @@ RequestCoordinator::TryImmediateStart() { |
| return OfflinerImmediateStartStatus::NOT_ACCEPTED; |
| } |
| +void RequestCoordinator::RequestConnectedEventForStarting() { |
| + connection_notifier_.reset(new ConnectionNotifier( |
| + base::Bind(&RequestCoordinator::HandleConnectedEventForStarting, |
| + weak_ptr_factory_.GetWeakPtr()))); |
| +} |
| + |
| +void RequestCoordinator::HandleConnectedEventForStarting() { |
| + connection_notifier_.reset(nullptr); |
| + StartImmediatelyIfConnected(); |
| +} |
| + |
| void RequestCoordinator::TryNextRequest(bool is_start_of_processing) { |
| is_starting_ = true; |
| base::TimeDelta processing_time_budget; |
| @@ -604,6 +617,11 @@ void RequestCoordinator::TryNextRequest(bool is_start_of_processing) { |
| (base::Time::Now() - operation_start_time_) > processing_time_budget) { |
| is_starting_ = false; |
| + // If we were doing immediate processing, try to start it again |
| + // when we get connected. |
| + if (processing_state_ == ProcessingWindowState::IMMEDIATE_WINDOW) |
| + RequestConnectedEventForStarting(); |
| + |
| // Let the scheduler know we are done processing. |
| // TODO: Make sure the scheduler callback is valid before running it. |
| scheduler_callback_.Run(true); |