Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_utils.h" | 5 #include "content/browser/service_worker/service_worker_utils.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 DCHECK(!url.has_ref()); | 23 DCHECK(!url.has_ref()); |
| 24 const std::string& scope_spec = scope.spec(); | 24 const std::string& scope_spec = scope.spec(); |
| 25 const std::string& url_spec = url.spec(); | 25 const std::string& url_spec = url.spec(); |
| 26 | 26 |
| 27 size_t len = scope_spec.size(); | 27 size_t len = scope_spec.size(); |
| 28 if (len > 0 && scope_spec[len - 1] == '*') | 28 if (len > 0 && scope_spec[len - 1] == '*') |
| 29 return scope_spec.compare(0, len - 1, url_spec, 0, len - 1) == 0; | 29 return scope_spec.compare(0, len - 1, url_spec, 0, len - 1) == 0; |
| 30 return scope_spec == url_spec; | 30 return scope_spec == url_spec; |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool ServiceWorkerUtils::FindLongestScopeMatch( | |
| 34 const std::vector<GURL>& scopes, const GURL& url, size_t* pos) { | |
| 35 DCHECK(!url.has_ref()); | |
| 36 DCHECK(pos); | |
| 37 | |
| 38 bool found = false; | |
| 39 for (size_t i = 0; i < scopes.size(); ++i) { | |
| 40 if (!ScopeMatches(scopes[i], url)) | |
| 41 continue; | |
| 42 if (!found || scopes.at(*pos) < scopes.at(i)) { | |
|
jsbell
2014/06/02 18:33:41
This use of < here is weird. Do you mean to be com
jsbell
2014/06/02 18:36:54
Uh, ignore this. My brain is on backwards today.
jsbell
2014/06/02 19:31:22
Ah, I did find a counterexample:
url......: "foo/
nhiroki
2014/06/03 18:05:03
You're right!
| |
| 43 *pos = i; | |
| 44 found = true; | |
| 45 } | |
| 46 } | |
| 47 return found; | |
| 48 } | |
| 49 | |
| 33 } // namespace content | 50 } // namespace content |
| OLD | NEW |