 Chromium Code Reviews
 Chromium Code Reviews Issue 294593002:
  ServiceWorker: Support longest-prefix-match for registration scope  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 294593002:
  ServiceWorker: Support longest-prefix-match for registration scope  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: content/browser/service_worker/service_worker_utils.cc | 
| diff --git a/content/browser/service_worker/service_worker_utils.cc b/content/browser/service_worker/service_worker_utils.cc | 
| index 165bcbec563e8226494083450aedad1f7a90c9c8..d5bfce73030f27cf0ca17b61a439f511442979b7 100644 | 
| --- a/content/browser/service_worker/service_worker_utils.cc | 
| +++ b/content/browser/service_worker/service_worker_utils.cc | 
| @@ -4,9 +4,12 @@ | 
| #include "content/browser/service_worker/service_worker_utils.h" | 
| +#include <string> | 
| + | 
| #include "base/command_line.h" | 
| #include "base/logging.h" | 
| #include "content/public/common/content_switches.h" | 
| +#include "url/gurl.h" | 
| namespace content { | 
| @@ -30,4 +33,17 @@ bool ServiceWorkerUtils::ScopeMatches(const GURL& scope, const GURL& url) { | 
| return scope_spec == url_spec; | 
| } | 
| +bool LongestScopeMatcher::MatchLongest(const GURL& scope) { | 
| + if (!ServiceWorkerUtils::ScopeMatches(scope, url_)) | 
| + return false; | 
| + // TODO(nhiroki): How should we prioritize scopes "/fo*" and "/foo" | 
| + // for a document "/foo"? | 
| 
jsbell
2014/06/03 18:48:30
Add link to github spec issue?
 
nhiroki
2014/06/05 11:00:35
Done.
 | 
| + if (match_.is_empty() || | 
| + match_.spec().size() < scope.spec().size()) { | 
| + match_ = scope; | 
| + return true; | 
| + } | 
| + return false; | 
| +} | 
| + | 
| } // namespace content |