| 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" |
| 11 #include "content/browser/service_worker/service_worker_job_coordinator.h" | 11 #include "content/browser/service_worker/service_worker_job_coordinator.h" |
| 12 #include "content/browser/service_worker/service_worker_provider_host_registry.h
" |
| 12 #include "content/browser/service_worker/service_worker_registration.h" | 13 #include "content/browser/service_worker/service_worker_registration.h" |
| 13 #include "content/browser/service_worker/service_worker_storage.h" | 14 #include "content/browser/service_worker/service_worker_storage.h" |
| 14 #include "content/browser/service_worker/service_worker_utils.h" | 15 #include "content/browser/service_worker/service_worker_utils.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 void RunSoon(const base::Closure& closure) { | 21 void RunSoon(const base::Closure& closure) { |
| 21 base::MessageLoop::current()->PostTask(FROM_HERE, closure); | 22 base::MessageLoop::current()->PostTask(FROM_HERE, closure); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 // static | 404 // static |
| 404 void ServiceWorkerRegisterJob::AssociateWaitingVersionToDocuments( | 405 void ServiceWorkerRegisterJob::AssociateWaitingVersionToDocuments( |
| 405 base::WeakPtr<ServiceWorkerContextCore> context, | 406 base::WeakPtr<ServiceWorkerContextCore> context, |
| 406 ServiceWorkerVersion* version) { | 407 ServiceWorkerVersion* version) { |
| 407 DCHECK(context); | 408 DCHECK(context); |
| 408 DCHECK(version); | 409 DCHECK(version); |
| 409 | 410 |
| 410 // TODO(michaeln): This needs to respect the longest prefix wins | 411 // TODO(michaeln): This needs to respect the longest prefix wins |
| 411 // when it comes to finding a registration for a document url. | 412 // when it comes to finding a registration for a document url. |
| 412 // This should utilize storage->FindRegistrationForDocument(). | 413 // This should utilize storage->FindRegistrationForDocument(). |
| 413 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = | 414 for (scoped_ptr<ServiceWorkerProviderHostRegistry::Iterator> it = |
| 414 context->GetProviderHostIterator(); | 415 context->provider_registry()->GetProviderHostIterator(); |
| 415 !it->IsAtEnd(); | 416 !it->IsAtEnd(); |
| 416 it->Advance()) { | 417 it->Advance()) { |
| 417 ServiceWorkerProviderHost* host = it->GetProviderHost(); | 418 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| 418 if (ServiceWorkerUtils::ScopeMatches(version->scope(), | 419 if (ServiceWorkerUtils::ScopeMatches(version->scope(), |
| 419 host->document_url())) | 420 host->document_url())) |
| 420 host->SetWaitingVersion(version); | 421 host->SetWaitingVersion(version); |
| 421 // TODO(nhiroki): Take care of 'installing' version when it's supported. | 422 // TODO(nhiroki): Take care of 'installing' version when it's supported. |
| 422 } | 423 } |
| 423 } | 424 } |
| 424 | 425 |
| 425 // static | 426 // static |
| 426 void ServiceWorkerRegisterJob::DisassociateWaitingVersionFromDocuments( | 427 void ServiceWorkerRegisterJob::DisassociateWaitingVersionFromDocuments( |
| 427 base::WeakPtr<ServiceWorkerContextCore> context, | 428 base::WeakPtr<ServiceWorkerContextCore> context, |
| 428 int64 version_id) { | 429 int64 version_id) { |
| 429 DCHECK(context); | 430 DCHECK(context); |
| 430 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = | 431 for (scoped_ptr<ServiceWorkerProviderHostRegistry::Iterator> it = |
| 431 context->GetProviderHostIterator(); | 432 context->provider_registry()->GetProviderHostIterator(); |
| 432 !it->IsAtEnd(); | 433 !it->IsAtEnd(); |
| 433 it->Advance()) { | 434 it->Advance()) { |
| 434 ServiceWorkerProviderHost* host = it->GetProviderHost(); | 435 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| 435 if (host->waiting_version() && | 436 if (host->waiting_version() && |
| 436 host->waiting_version()->version_id() == version_id) { | 437 host->waiting_version()->version_id() == version_id) { |
| 437 host->SetWaitingVersion(NULL); | 438 host->SetWaitingVersion(NULL); |
| 438 } | 439 } |
| 439 } | 440 } |
| 440 } | 441 } |
| 441 | 442 |
| 442 } // namespace content | 443 } // namespace content |
| OLD | NEW |