Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: content/browser/service_worker/service_worker_register_job.cc

Issue 294593002: ServiceWorker: Support longest-prefix-match for registration scope (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_register_job.cc
diff --git a/content/browser/service_worker/service_worker_register_job.cc b/content/browser/service_worker/service_worker_register_job.cc
index 4ddd57bf2b52fd0c0567148ddf4571bdbb7e9988..fc196619cd9e0d14c28614bbd6ad5e9ae12d8a28 100644
--- a/content/browser/service_worker/service_worker_register_job.cc
+++ b/content/browser/service_worker/service_worker_register_job.cc
@@ -399,17 +399,26 @@ void ServiceWorkerRegisterJob::ResolvePromise(
void ServiceWorkerRegisterJob::AssociatePendingVersionToDocuments(
ServiceWorkerVersion* version) {
michaeln 2014/05/22 00:56:29 when the input is NULL, this method should only af
- // TODO(michaeln): This needs to respect the longest prefix wins
- // when it comes to finding a registration for a document url.
- // This should utilize storage->FindRegistrationForDocument().
for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it =
context_->GetProviderHostIterator();
!it->IsAtEnd();
it->Advance()) {
- ServiceWorkerProviderHost* provider_host = it->GetProviderHost();
- if (ServiceWorkerUtils::ScopeMatches(pattern_,
- provider_host->document_url()))
- provider_host->SetPendingVersion(version);
+ ServiceWorkerProviderHost* host = it->GetProviderHost();
+ ServiceWorkerUtils::MatchResult result =
+ ServiceWorkerUtils::ScopeMatches(pattern_, host->document_url());
+ if (result == ServiceWorkerUtils::SCOPE_NO_MATCH)
+ continue;
+ 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
+ !host->pending_version()) {
+ 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
+ continue;
+ }
+
+ DCHECK_EQ(ServiceWorkerUtils::SCOPE_WILDCARD_MATCH, result);
+ if (ServiceWorkerUtils::CompareScopePriorities(
+ 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
+ host->SetPendingVersion(version);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698