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

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: rebase Created 5 years, 9 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 253
254 UpdateAndContinue(); 254 UpdateAndContinue();
255 } 255 }
256 256
257 // Creates a new ServiceWorkerRegistration. 257 // Creates a new ServiceWorkerRegistration.
258 void ServiceWorkerRegisterJob::RegisterAndContinue() { 258 void ServiceWorkerRegisterJob::RegisterAndContinue() {
259 SetPhase(REGISTER); 259 SetPhase(REGISTER);
260 260
261 set_registration(new ServiceWorkerRegistration( 261 set_registration(new ServiceWorkerRegistration(
262 pattern_, context_->storage()->NewRegistrationId(), context_)); 262 pattern_, context_->storage()->NewRegistrationId(), context_));
263 AssociateProviderHostsToRegistration(registration()); 263 AddRegistrationToMatchingProviderHosts(registration());
264 UpdateAndContinue(); 264 UpdateAndContinue();
265 } 265 }
266 266
267 void ServiceWorkerRegisterJob::ContinueWithUninstallingRegistration( 267 void ServiceWorkerRegisterJob::ContinueWithUninstallingRegistration(
268 const scoped_refptr<ServiceWorkerRegistration>& existing_registration, 268 const scoped_refptr<ServiceWorkerRegistration>& existing_registration,
269 ServiceWorkerStatusCode status) { 269 ServiceWorkerStatusCode status) {
270 if (status != SERVICE_WORKER_OK) { 270 if (status != SERVICE_WORKER_OK) {
271 Complete(status); 271 Complete(status);
272 return; 272 return;
273 } 273 }
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); 541 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration());
542 Complete(SERVICE_WORKER_ERROR_EXISTS); 542 Complete(SERVICE_WORKER_ERROR_EXISTS);
543 return; 543 return;
544 } 544 }
545 545
546 // Proceed with really starting the worker. 546 // Proceed with really starting the worker.
547 new_version()->embedded_worker()->ResumeAfterDownload(); 547 new_version()->embedded_worker()->ResumeAfterDownload();
548 new_version()->embedded_worker()->RemoveListener(this); 548 new_version()->embedded_worker()->RemoveListener(this);
549 } 549 }
550 550
551 void ServiceWorkerRegisterJob::AssociateProviderHostsToRegistration( 551 void ServiceWorkerRegisterJob::AddRegistrationToMatchingProviderHosts(
552 ServiceWorkerRegistration* registration) { 552 ServiceWorkerRegistration* registration) {
553 DCHECK(registration); 553 DCHECK(registration);
554 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = 554 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it =
555 context_->GetProviderHostIterator(); 555 context_->GetProviderHostIterator();
556 !it->IsAtEnd(); it->Advance()) { 556 !it->IsAtEnd(); it->Advance()) {
557 ServiceWorkerProviderHost* host = it->GetProviderHost(); 557 ServiceWorkerProviderHost* host = it->GetProviderHost();
558 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), 558 if (host->IsHostToRunningServiceWorker())
559 host->document_url())) { 559 continue;
560 if (host->CanAssociateRegistration(registration)) 560 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(),
561 host->AssociateRegistration(registration); 561 host->document_url()))
562 } 562 continue;
563 host->AddMatchingRegistration(registration);
563 } 564 }
564 } 565 }
565 566
566 } // namespace content 567 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698