| 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_registration.h" | 5 #include "content/browser/service_worker/service_worker_registration.h" |
| 6 | 6 |
| 7 #include "content/browser/service_worker/service_worker_context_core.h" | 7 #include "content/browser/service_worker/service_worker_context_core.h" |
| 8 #include "content/browser/service_worker/service_worker_info.h" | 8 #include "content/browser/service_worker/service_worker_info.h" |
| 9 #include "content/browser/service_worker/service_worker_register_job.h" | 9 #include "content/browser/service_worker/service_worker_register_job.h" |
| 10 #include "content/browser/service_worker/service_worker_utils.h" | 10 #include "content/browser/service_worker/service_worker_utils.h" |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 ServiceWorkerProviderHost* host = it->GetProviderHost(); | 389 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| 390 if (ShouldClaim(host, registrations)) | 390 if (ShouldClaim(host, registrations)) |
| 391 host->ClaimedByRegistration(this); | 391 host->ClaimedByRegistration(this); |
| 392 } | 392 } |
| 393 callback.Run(SERVICE_WORKER_OK); | 393 callback.Run(SERVICE_WORKER_OK); |
| 394 } | 394 } |
| 395 | 395 |
| 396 bool ServiceWorkerRegistration::ShouldClaim( | 396 bool ServiceWorkerRegistration::ShouldClaim( |
| 397 ServiceWorkerProviderHost* provider_host, | 397 ServiceWorkerProviderHost* provider_host, |
| 398 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { | 398 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { |
| 399 if (provider_host->IsHostToRunningServiceWorker()) |
| 400 return false; |
| 399 if (provider_host->controlling_version() == active_version()) | 401 if (provider_host->controlling_version() == active_version()) |
| 400 return false; | 402 return false; |
| 401 | 403 |
| 402 LongestScopeMatcher matcher(provider_host->document_url()); | 404 LongestScopeMatcher matcher(provider_host->document_url()); |
| 403 if (!matcher.MatchLongest(pattern_)) | 405 if (!matcher.MatchLongest(pattern_)) |
| 404 return false; | 406 return false; |
| 405 for (const ServiceWorkerRegistrationInfo& info : registrations) { | 407 for (const ServiceWorkerRegistrationInfo& info : registrations) { |
| 406 ServiceWorkerRegistration* registration = | 408 ServiceWorkerRegistration* registration = |
| 407 context_->GetLiveRegistration(info.registration_id); | 409 context_->GetLiveRegistration(info.registration_id); |
| 408 if (registration && | 410 if (registration && |
| 409 (registration->is_uninstalling() || registration->is_uninstalled())) | 411 (registration->is_uninstalling() || registration->is_uninstalled())) |
| 410 continue; | 412 continue; |
| 411 if (matcher.MatchLongest(info.pattern)) | 413 if (matcher.MatchLongest(info.pattern)) |
| 412 return false; | 414 return false; |
| 413 } | 415 } |
| 414 return true; | 416 return true; |
| 415 } | 417 } |
| 416 | 418 |
| 417 } // namespace content | 419 } // namespace content |
| OLD | NEW |