| 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..917980514d559e5416baf4a969c66f3feec71918 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,21 @@ bool ServiceWorkerUtils::ScopeMatches(const GURL& scope, const GURL& url) {
|
| return scope_spec == url_spec;
|
| }
|
|
|
| +bool ServiceWorkerUtils::FindLongestScopeMatch(
|
| + const std::vector<GURL>& scopes, const GURL& url, size_t* pos) {
|
| + DCHECK(!url.has_ref());
|
| + DCHECK(pos);
|
| +
|
| + bool found = false;
|
| + for (size_t i = 0; i < scopes.size(); ++i) {
|
| + if (!ScopeMatches(scopes[i], url))
|
| + continue;
|
| + if (!found || scopes.at(*pos) < scopes.at(i)) {
|
| + *pos = i;
|
| + found = true;
|
| + }
|
| + }
|
| + return found;
|
| +}
|
| +
|
| } // namespace content
|
|
|