Skip to content

Commit

Permalink
Guard some context_ dereferences in ServiceWorkerVersion.
Browse files Browse the repository at this point in the history
As a WeakPtr, context_ may be null.

BUG=566935

Review URL: https://codereview.chromium.org/1508573002

Cr-Commit-Position: refs/heads/master@{#363428}
(cherry picked from commit aefd501)

Review URL: https://codereview.chromium.org/1515013003 .

Cr-Commit-Position: refs/branch-heads/2564@{crosswalk-project#325}
Cr-Branched-From: 1283eca-refs/heads/master@{#359700}
  • Loading branch information
mfalken committed Dec 11, 2015
1 parent 01e33c0 commit f57face
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions content/browser/service_worker/service_worker_version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ void ServiceWorkerVersion::DidNavigateClient(int request_id,
int render_frame_id) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);

if (running_status() != RUNNING)
if (!context_ || running_status() != RUNNING)
return;

if (render_process_id == ChildProcessHost::kInvalidUniqueID &&
Expand Down Expand Up @@ -1961,7 +1961,7 @@ void ServiceWorkerVersion::GetWindowClients(
if (!options.include_uncontrolled) {
for (auto& controllee : controllee_map_)
AddWindowClient(controllee.second, &clients_info);
} else {
} else if (context_) {
for (auto it =
context_->GetClientProviderHostIterator(script_url_.GetOrigin());
!it->IsAtEnd(); it->Advance()) {
Expand Down Expand Up @@ -2000,7 +2000,7 @@ void ServiceWorkerVersion::GetNonWindowClients(
for (auto& controllee : controllee_map_) {
AddNonWindowClient(controllee.second, options, clients);
}
} else {
} else if (context_) {
for (auto it =
context_->GetClientProviderHostIterator(script_url_.GetOrigin());
!it->IsAtEnd(); it->Advance()) {
Expand Down Expand Up @@ -2049,6 +2049,9 @@ void ServiceWorkerVersion::OnTimeoutTimer() {
running_status() == STOPPING)
<< running_status();

if (!context_)
return;

MarkIfStale();

// Stopping the worker hasn't finished within a certain period.
Expand Down

0 comments on commit f57face

Please sign in to comment.