Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: content/browser/service_worker/service_worker_register_job.cc

Issue 325173002: ServiceWorker: Confirm the liveness of the associated context before handling message (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix more Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_register_job.h" 5 #include "content/browser/service_worker/service_worker_register_job.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/browser/service_worker/service_worker_context_core.h" 10 #include "content/browser/service_worker/service_worker_context_core.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 base::WeakPtr<ServiceWorkerContextCore> context, 405 base::WeakPtr<ServiceWorkerContextCore> context,
406 ServiceWorkerVersion* version) { 406 ServiceWorkerVersion* version) {
407 DCHECK(context); 407 DCHECK(context);
408 DCHECK(version); 408 DCHECK(version);
409 409
410 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = 410 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it =
411 context->GetProviderHostIterator(); 411 context->GetProviderHostIterator();
412 !it->IsAtEnd(); 412 !it->IsAtEnd();
413 it->Advance()) { 413 it->Advance()) {
414 ServiceWorkerProviderHost* host = it->GetProviderHost(); 414 ServiceWorkerProviderHost* host = it->GetProviderHost();
415 if (!host->IsContextAlive())
416 continue;
415 if (ServiceWorkerUtils::ScopeMatches(version->scope(), 417 if (ServiceWorkerUtils::ScopeMatches(version->scope(),
416 host->document_url())) { 418 host->document_url())) {
417 // The spec's _Update algorithm says, "upgrades active version to a new 419 // The spec's _Update algorithm says, "upgrades active version to a new
418 // version for the same URL scope.", so skip if the scope (registration) 420 // version for the same URL scope.", so skip if the scope (registration)
419 // of |version| is different from that of the current active/waiting 421 // of |version| is different from that of the current active/waiting
420 // version. 422 // version.
421 if (!host->ValidateVersionForAssociation(version)) 423 if (!host->ValidateVersionForAssociation(version))
422 continue; 424 continue;
423 425
424 // TODO(nhiroki): Keep |host->waiting_version()| to be replaced and set 426 // TODO(nhiroki): Keep |host->waiting_version()| to be replaced and set
425 // status of them to 'redandunt' after breaking the loop. 427 // status of them to 'redandunt' after breaking the loop.
426 428
427 host->SetWaitingVersion(version); 429 host->SetWaitingVersion(version);
428 // TODO(nhiroki): Set |host|'s installing version to null. 430 // TODO(nhiroki): Set |host|'s installing version to null.
429 } 431 }
430 } 432 }
431 } 433 }
432 434
433 // static 435 // static
434 void ServiceWorkerRegisterJob::DisassociateWaitingVersionFromDocuments( 436 void ServiceWorkerRegisterJob::DisassociateWaitingVersionFromDocuments(
435 base::WeakPtr<ServiceWorkerContextCore> context, 437 base::WeakPtr<ServiceWorkerContextCore> context,
436 int64 version_id) { 438 int64 version_id) {
437 DCHECK(context); 439 DCHECK(context);
438 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = 440 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it =
439 context->GetProviderHostIterator(); 441 context->GetProviderHostIterator();
440 !it->IsAtEnd(); 442 !it->IsAtEnd();
441 it->Advance()) { 443 it->Advance()) {
442 ServiceWorkerProviderHost* host = it->GetProviderHost(); 444 ServiceWorkerProviderHost* host = it->GetProviderHost();
445 if (!host->IsContextAlive())
446 continue;
443 if (host->waiting_version() && 447 if (host->waiting_version() &&
444 host->waiting_version()->version_id() == version_id) { 448 host->waiting_version()->version_id() == version_id) {
445 host->SetWaitingVersion(NULL); 449 host->SetWaitingVersion(NULL);
446 } 450 }
447 } 451 }
448 } 452 }
449 453
450 } // namespace content 454 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698