Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_utils.cc
blobedbe9f97b227726057c5ce85c0ef4bb5322d138f
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/service_worker/service_worker_utils.h"
7 #include <string>
9 #include "base/logging.h"
10 #include "base/strings/string_util.h"
12 namespace content {
14 // static
15 bool ServiceWorkerUtils::ScopeMatches(const GURL& scope, const GURL& url) {
16 DCHECK(!scope.has_ref());
17 DCHECK(!url.has_ref());
18 return StartsWithASCII(url.spec(), scope.spec(), true);
21 bool LongestScopeMatcher::MatchLongest(const GURL& scope) {
22 if (!ServiceWorkerUtils::ScopeMatches(scope, url_))
23 return false;
24 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) {
25 match_ = scope;
26 return true;
28 return false;
31 } // namespace content