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

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: #30 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); 540 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration());
541 Complete(SERVICE_WORKER_ERROR_EXISTS); 541 Complete(SERVICE_WORKER_ERROR_EXISTS);
542 return; 542 return;
543 } 543 }
544 544
545 // Proceed with really starting the worker. 545 // Proceed with really starting the worker.
546 new_version()->embedded_worker()->ResumeAfterDownload(); 546 new_version()->embedded_worker()->ResumeAfterDownload();
547 new_version()->embedded_worker()->RemoveListener(this); 547 new_version()->embedded_worker()->RemoveListener(this);
548 } 548 }
549 549
550 void ServiceWorkerRegisterJob::AssociateProviderHostsToRegistration( 550 void ServiceWorkerRegisterJob::AddRegistrationToMatchingProviderHosts(
551 ServiceWorkerRegistration* registration) { 551 ServiceWorkerRegistration* registration) {
552 DCHECK(registration); 552 DCHECK(registration);
553 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = 553 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it =
554 context_->GetProviderHostIterator(); 554 context_->GetProviderHostIterator();
555 !it->IsAtEnd(); it->Advance()) { 555 !it->IsAtEnd(); it->Advance()) {
556 ServiceWorkerProviderHost* host = it->GetProviderHost(); 556 ServiceWorkerProviderHost* host = it->GetProviderHost();
557 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), 557 if (host->IsHostToRunningServiceWorker())
558 host->document_url())) { 558 continue;
559 if (host->CanAssociateRegistration(registration)) 559 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(),
560 host->AssociateRegistration(registration); 560 host->document_url()))
561 } 561 continue;
562 host->AddMatchingRegistration(registration);
562 } 563 }
563 } 564 }
564 565
565 } // namespace content 566 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698