Commit 1cc1225e authored by petewil's avatar petewil Committed by Commit bot

Fix occasional crash in TryNextRequest

If chrome is shut down, then a user deletes a request from a
notification, the scheduler callback will not be set, and we could
crash trying to inform it.  To fix this, when we start, set an
empty scheduler callback to receive the call, so we don't try
to call through a nullptr.

BUG=64911

Review-Url: https://chromiumcodereview.appspot.com/2429213009
Cr-Commit-Position: refs/heads/master@{#426847}
parent 1409ac2e
...@@ -136,6 +136,7 @@ RequestCoordinator::RequestCoordinator( ...@@ -136,6 +136,7 @@ RequestCoordinator::RequestCoordinator(
network_quality_estimator_(network_quality_estimator), network_quality_estimator_(network_quality_estimator),
active_request_(nullptr), active_request_(nullptr),
last_offlining_status_(Offliner::RequestStatus::UNKNOWN), last_offlining_status_(Offliner::RequestStatus::UNKNOWN),
scheduler_callback_(base::Bind(&EmptySchedulerCallback)),
immediate_schedule_callback_(base::Bind(&EmptySchedulerCallback)), immediate_schedule_callback_(base::Bind(&EmptySchedulerCallback)),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
DCHECK(policy_ != nullptr); DCHECK(policy_ != nullptr);
...@@ -239,6 +240,7 @@ bool RequestCoordinator::CancelActiveRequestIfItMatches( ...@@ -239,6 +240,7 @@ bool RequestCoordinator::CancelActiveRequestIfItMatches(
if (request_ids.end() != std::find(request_ids.begin(), request_ids.end(), if (request_ids.end() != std::find(request_ids.begin(), request_ids.end(),
active_request_->request_id())) { active_request_->request_id())) {
StopPrerendering(Offliner::RequestStatus::REQUEST_COORDINATOR_CANCELED); StopPrerendering(Offliner::RequestStatus::REQUEST_COORDINATOR_CANCELED);
active_request_.reset(nullptr);
return true; return true;
} }
} }
...@@ -507,6 +509,7 @@ void RequestCoordinator::TryNextRequest() { ...@@ -507,6 +509,7 @@ void RequestCoordinator::TryNextRequest() {
is_starting_ = false; is_starting_ = false;
// Let the scheduler know we are done processing. // Let the scheduler know we are done processing.
// TODO: Make sure the scheduler callback is valid before running it.
scheduler_callback_.Run(true); scheduler_callback_.Run(true);
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment