| OLD | NEW |
| 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 Loading... |
| 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 NotifyProviderHostsForRegistration(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 Loading... |
| 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::NotifyProviderHostsForRegistration( |
| 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 (!ServiceWorkerUtils::ScopeMatches(registration->pattern(), |
| 558 host->document_url())) { | 558 host->document_url())) |
| 559 if (host->CanAssociateRegistration(registration)) | 559 continue; |
| 560 host->AssociateRegistration(registration); | 560 host->AddMatchingRegistration(registration); |
| 561 } | |
| 562 } | 561 } |
| 563 } | 562 } |
| 564 | 563 |
| 565 } // namespace content | 564 } // namespace content |
| OLD | NEW |