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

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

Issue 894973003: ServiceWorker: Make "ready" fetches registration from browser process(2/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 10 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
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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 void ServiceWorkerRegisterJob::RegisterAndContinue( 274 void ServiceWorkerRegisterJob::RegisterAndContinue(
275 ServiceWorkerStatusCode status) { 275 ServiceWorkerStatusCode status) {
276 SetPhase(REGISTER); 276 SetPhase(REGISTER);
277 if (status != SERVICE_WORKER_OK) { 277 if (status != SERVICE_WORKER_OK) {
278 Complete(status); 278 Complete(status);
279 return; 279 return;
280 } 280 }
281 281
282 set_registration(new ServiceWorkerRegistration( 282 set_registration(new ServiceWorkerRegistration(
283 pattern_, context_->storage()->NewRegistrationId(), context_)); 283 pattern_, context_->storage()->NewRegistrationId(), context_));
284 AssociateProviderHostsToRegistration(registration()); 284 NotifyProviderHostsForRegistration(registration());
285 UpdateAndContinue(); 285 UpdateAndContinue();
286 } 286 }
287 287
288 void ServiceWorkerRegisterJob::WaitForUninstall( 288 void ServiceWorkerRegisterJob::WaitForUninstall(
289 const scoped_refptr<ServiceWorkerRegistration>& existing_registration) { 289 const scoped_refptr<ServiceWorkerRegistration>& existing_registration) {
290 SetPhase(WAIT_FOR_UNINSTALL); 290 SetPhase(WAIT_FOR_UNINSTALL);
291 set_uninstalling_registration(existing_registration); 291 set_uninstalling_registration(existing_registration);
292 uninstalling_registration()->AddListener(this); 292 uninstalling_registration()->AddListener(this);
293 } 293 }
294 294
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); 563 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration());
564 Complete(SERVICE_WORKER_ERROR_EXISTS); 564 Complete(SERVICE_WORKER_ERROR_EXISTS);
565 return; 565 return;
566 } 566 }
567 567
568 // Proceed with really starting the worker. 568 // Proceed with really starting the worker.
569 new_version()->embedded_worker()->ResumeAfterDownload(); 569 new_version()->embedded_worker()->ResumeAfterDownload();
570 new_version()->embedded_worker()->RemoveListener(this); 570 new_version()->embedded_worker()->RemoveListener(this);
571 } 571 }
572 572
573 void ServiceWorkerRegisterJob::AssociateProviderHostsToRegistration( 573 void ServiceWorkerRegisterJob::NotifyProviderHostsForRegistration(
574 ServiceWorkerRegistration* registration) { 574 ServiceWorkerRegistration* registration) {
575 DCHECK(registration); 575 DCHECK(registration);
576 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = 576 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it =
577 context_->GetProviderHostIterator(); 577 context_->GetProviderHostIterator();
578 !it->IsAtEnd(); it->Advance()) { 578 !it->IsAtEnd(); it->Advance()) {
579 ServiceWorkerProviderHost* host = it->GetProviderHost(); 579 ServiceWorkerProviderHost* host = it->GetProviderHost();
580 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), 580 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(),
581 host->document_url())) { 581 host->document_url()))
582 if (host->CanAssociateRegistration(registration)) 582 continue;
583 host->AssociateRegistration(registration); 583 host->AddPotentialRegistration(registration);
584 }
585 } 584 }
586 } 585 }
587 586
588 } // namespace content 587 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698