| 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..529838669cf1cef2ae02f7fbea186cb2ed0292ff 100644
|
| --- a/components/offline_pages/background/request_coordinator.cc
|
| +++ b/components/offline_pages/background/request_coordinator.cc
|
| @@ -559,8 +559,14 @@ RequestCoordinator::TryImmediateStart() {
|
| }
|
|
|
| if (GetConnectionType() ==
|
| - net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE)
|
| + net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) {
|
| + RequestConnectedEventForStarting();
|
| return OfflinerImmediateStartStatus::NO_CONNECTION;
|
| + } else {
|
| + // Clear any pending connected event request since we have connection
|
| + // and will start processing.
|
| + ClearConnectedEventRequest();
|
| + }
|
|
|
| // Start processing with manufactured conservative battery conditions
|
| // (i.e., assume no battery).
|
| @@ -574,6 +580,21 @@ RequestCoordinator::TryImmediateStart() {
|
| return OfflinerImmediateStartStatus::NOT_ACCEPTED;
|
| }
|
|
|
| +void RequestCoordinator::RequestConnectedEventForStarting() {
|
| + connection_notifier_.reset(new ConnectionNotifier(
|
| + base::Bind(&RequestCoordinator::HandleConnectedEventForStarting,
|
| + weak_ptr_factory_.GetWeakPtr())));
|
| +}
|
| +
|
| +void RequestCoordinator::ClearConnectedEventRequest() {
|
| + connection_notifier_.reset(nullptr);
|
| +}
|
| +
|
| +void RequestCoordinator::HandleConnectedEventForStarting() {
|
| + ClearConnectedEventRequest();
|
| + StartImmediatelyIfConnected();
|
| +}
|
| +
|
| void RequestCoordinator::TryNextRequest(bool is_start_of_processing) {
|
| is_starting_ = true;
|
| base::TimeDelta processing_time_budget;
|
| @@ -604,6 +625,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);
|
|
|