| 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 9f2fdc2580ae550ce00dabe7dc79b76e66a84f10..82d39d9f0c3cf28709f303156ca6ff1fdf9fc280 100644
|
| --- a/components/offline_pages/background/request_coordinator.cc
|
| +++ b/components/offline_pages/background/request_coordinator.cc
|
| @@ -78,6 +78,7 @@ RequestCoordinator::RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy,
|
| std::unique_ptr<RequestQueue> queue,
|
| std::unique_ptr<Scheduler> scheduler)
|
| : is_busy_(false),
|
| + is_starting_(false),
|
| is_stopped_(false),
|
| use_test_connection_type_(false),
|
| test_connection_type_(),
|
| @@ -316,7 +317,9 @@ bool RequestCoordinator::StartProcessing(
|
| const DeviceConditions& device_conditions,
|
| const base::Callback<void(bool)>& callback) {
|
| current_conditions_.reset(new DeviceConditions(device_conditions));
|
| - if (is_busy_) return false;
|
| + if (is_starting_ || is_busy_)
|
| + return false;
|
| + is_starting_ = true;
|
|
|
| // Mark the time at which we started processing so we can check our time
|
| // budget.
|
| @@ -354,6 +357,8 @@ void RequestCoordinator::TryNextRequest() {
|
| if (base::Time::Now() - operation_start_time_ >
|
| base::TimeDelta::FromSeconds(
|
| policy_->GetBackgroundProcessingTimeBudgetSeconds())) {
|
| + is_starting_ = false;
|
| +
|
| // Let the scheduler know we are done processing.
|
| scheduler_callback_.Run(true);
|
|
|
| @@ -372,11 +377,18 @@ void RequestCoordinator::TryNextRequest() {
|
|
|
| // Called by the request picker when a request has been picked.
|
| void RequestCoordinator::RequestPicked(const SavePageRequest& request) {
|
| - // Send the request on to the offliner.
|
| - SendRequestToOffliner(request);
|
| + is_starting_ = false;
|
| +
|
| + // Make sure we were not stopped while picking.
|
| + if (!is_stopped_) {
|
| + // Send the request on to the offliner.
|
| + SendRequestToOffliner(request);
|
| + }
|
| }
|
|
|
| void RequestCoordinator::RequestQueueEmpty() {
|
| + is_starting_ = false;
|
| +
|
| // Clear the outstanding "safety" task in the scheduler.
|
| scheduler_->Unschedule();
|
| // Let the scheduler know we are done processing.
|
|
|