Chromium Code Reviews| 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 promise_resolved_version_ = version; | 391 promise_resolved_version_ = version; |
| 392 for (std::vector<RegistrationCallback>::iterator it = callbacks_.begin(); | 392 for (std::vector<RegistrationCallback>::iterator it = callbacks_.begin(); |
| 393 it != callbacks_.end(); | 393 it != callbacks_.end(); |
| 394 ++it) { | 394 ++it) { |
| 395 it->Run(status, registration, version); | 395 it->Run(status, registration, version); |
| 396 } | 396 } |
| 397 callbacks_.clear(); | 397 callbacks_.clear(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 void ServiceWorkerRegisterJob::AssociatePendingVersionToDocuments( | 400 void ServiceWorkerRegisterJob::AssociatePendingVersionToDocuments( |
| 401 ServiceWorkerVersion* version) { | 401 ServiceWorkerVersion* version) { |
|
michaeln
2014/05/22 00:56:29
when the input is NULL, this method should only af
| |
| 402 // TODO(michaeln): This needs to respect the longest prefix wins | |
| 403 // when it comes to finding a registration for a document url. | |
| 404 // This should utilize storage->FindRegistrationForDocument(). | |
| 405 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = | 402 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = |
| 406 context_->GetProviderHostIterator(); | 403 context_->GetProviderHostIterator(); |
| 407 !it->IsAtEnd(); | 404 !it->IsAtEnd(); |
| 408 it->Advance()) { | 405 it->Advance()) { |
| 409 ServiceWorkerProviderHost* provider_host = it->GetProviderHost(); | 406 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| 410 if (ServiceWorkerUtils::ScopeMatches(pattern_, | 407 ServiceWorkerUtils::MatchResult result = |
| 411 provider_host->document_url())) | 408 ServiceWorkerUtils::ScopeMatches(pattern_, host->document_url()); |
| 412 provider_host->SetPendingVersion(version); | 409 if (result == ServiceWorkerUtils::SCOPE_NO_MATCH) |
| 410 continue; | |
| 411 if (result == ServiceWorkerUtils::SCOPE_EXACT_MATCH || | |
|
jsbell
2014/05/21 19:20:03
The spec doesn't call out an exact match as a spec
nhiroki
2014/05/22 00:02:18
Filed a spec bug: https://github.com/slightlyoff/S
| |
| 412 !host->pending_version()) { | |
| 413 host->SetPendingVersion(version); | |
|
michaeln
2014/05/22 00:56:29
What if active_version is from an entirely differe
dominicc (has gone to gerrit)
2014/05/22 05:03:31
FWIW there are some related comments on the spec b
michaeln
2014/05/23 01:23:27
I think its the intent of the spec to not mix-n-ma
| |
| 414 continue; | |
| 415 } | |
| 416 | |
| 417 DCHECK_EQ(ServiceWorkerUtils::SCOPE_WILDCARD_MATCH, result); | |
| 418 if (ServiceWorkerUtils::CompareScopePriorities( | |
| 419 pattern_, host->pending_version()->scope()) >= 0) { | |
|
jsbell
2014/05/21 19:20:03
If result here == 0 that would mean the scopes wer
michaeln
2014/05/22 00:56:29
per above, once there is some association on place
| |
| 420 host->SetPendingVersion(version); | |
| 421 } | |
| 413 } | 422 } |
| 414 } | 423 } |
| 415 | 424 |
| 416 } // namespace content | 425 } // namespace content |
| OLD | NEW |