| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 243 |
| 244 UpdateAndContinue(); | 244 UpdateAndContinue(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 // Creates a new ServiceWorkerRegistration. | 247 // Creates a new ServiceWorkerRegistration. |
| 248 void ServiceWorkerRegisterJob::RegisterAndContinue() { | 248 void ServiceWorkerRegisterJob::RegisterAndContinue() { |
| 249 SetPhase(REGISTER); | 249 SetPhase(REGISTER); |
| 250 | 250 |
| 251 set_registration(new ServiceWorkerRegistration( | 251 set_registration(new ServiceWorkerRegistration( |
| 252 pattern_, context_->storage()->NewRegistrationId(), context_)); | 252 pattern_, context_->storage()->NewRegistrationId(), context_)); |
| 253 AssociateProviderHostsToRegistration(registration()); | 253 NotifyProviderHostsForRegistration(registration()); |
| 254 UpdateAndContinue(); | 254 UpdateAndContinue(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void ServiceWorkerRegisterJob::ContinueWithRegistrationForSameScriptUrl( | 257 void ServiceWorkerRegisterJob::ContinueWithRegistrationForSameScriptUrl( |
| 258 const scoped_refptr<ServiceWorkerRegistration>& existing_registration, | 258 const scoped_refptr<ServiceWorkerRegistration>& existing_registration, |
| 259 ServiceWorkerStatusCode status) { | 259 ServiceWorkerStatusCode status) { |
| 260 if (status != SERVICE_WORKER_OK) { | 260 if (status != SERVICE_WORKER_OK) { |
| 261 Complete(status); | 261 Complete(status); |
| 262 return; | 262 return; |
| 263 } | 263 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); | 516 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); |
| 517 Complete(SERVICE_WORKER_ERROR_EXISTS); | 517 Complete(SERVICE_WORKER_ERROR_EXISTS); |
| 518 return; | 518 return; |
| 519 } | 519 } |
| 520 | 520 |
| 521 // Proceed with really starting the worker. | 521 // Proceed with really starting the worker. |
| 522 new_version()->embedded_worker()->ResumeAfterDownload(); | 522 new_version()->embedded_worker()->ResumeAfterDownload(); |
| 523 new_version()->embedded_worker()->RemoveListener(this); | 523 new_version()->embedded_worker()->RemoveListener(this); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void ServiceWorkerRegisterJob::AssociateProviderHostsToRegistration( | 526 void ServiceWorkerRegisterJob::NotifyProviderHostsForRegistration( |
| 527 ServiceWorkerRegistration* registration) { | 527 ServiceWorkerRegistration* registration) { |
| 528 DCHECK(registration); | 528 DCHECK(registration); |
| 529 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = | 529 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = |
| 530 context_->GetProviderHostIterator(); | 530 context_->GetProviderHostIterator(); |
| 531 !it->IsAtEnd(); it->Advance()) { | 531 !it->IsAtEnd(); it->Advance()) { |
| 532 ServiceWorkerProviderHost* host = it->GetProviderHost(); | 532 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| 533 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), | 533 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(), |
| 534 host->document_url())) { | 534 host->document_url())) |
| 535 if (host->CanAssociateRegistration(registration)) | 535 continue; |
| 536 host->AssociateRegistration(registration); | 536 host->AddMatchingRegistration(registration); |
| 537 } | |
| 538 } | 537 } |
| 539 } | 538 } |
| 540 | 539 |
| 541 } // namespace content | 540 } // namespace content |
| OLD | NEW |