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

Side by Side Diff: content/common/appcache_interfaces.cc

Issue 1242023005: Remove legacy StartsWithASCII function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: y Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « content/child/simple_webmimeregistry_impl.cc ('k') | content/public/test/browser_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/appcache_interfaces.h" 5 #include "content/common/appcache_interfaces.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/strings/pattern.h" 9 #include "base/strings/pattern.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 bool AppCacheNamespace::IsMatch(const GURL& url) const { 102 bool AppCacheNamespace::IsMatch(const GURL& url) const {
103 if (is_pattern) { 103 if (is_pattern) {
104 // We have to escape '?' characters since MatchPattern also treats those 104 // We have to escape '?' characters since MatchPattern also treats those
105 // as wildcards which we don't want here, we only do '*'s. 105 // as wildcards which we don't want here, we only do '*'s.
106 std::string pattern = namespace_url.spec(); 106 std::string pattern = namespace_url.spec();
107 if (namespace_url.has_query()) 107 if (namespace_url.has_query())
108 base::ReplaceSubstringsAfterOffset(&pattern, 0, "?", "\\?"); 108 base::ReplaceSubstringsAfterOffset(&pattern, 0, "?", "\\?");
109 return base::MatchPattern(url.spec(), pattern); 109 return base::MatchPattern(url.spec(), pattern);
110 } 110 }
111 return base::StartsWithASCII(url.spec(), namespace_url.spec(), true); 111 return base::StartsWith(url.spec(), namespace_url.spec(),
112 base::CompareCase::SENSITIVE);
112 } 113 }
113 114
114 bool IsSchemeSupportedForAppCache(const GURL& url) { 115 bool IsSchemeSupportedForAppCache(const GURL& url) {
115 bool supported = url.SchemeIs(url::kHttpScheme) || 116 bool supported = url.SchemeIs(url::kHttpScheme) ||
116 url.SchemeIs(url::kHttpsScheme) || 117 url.SchemeIs(url::kHttpsScheme) ||
117 url.SchemeIs(kChromeDevToolsScheme); 118 url.SchemeIs(kChromeDevToolsScheme);
118 119
119 #ifndef NDEBUG 120 #ifndef NDEBUG
120 // TODO(michaeln): It would be really nice if this could optionally work for 121 // TODO(michaeln): It would be really nice if this could optionally work for
121 // file and filesystem urls too to help web developers experiment and test 122 // file and filesystem urls too to help web developers experiment and test
122 // their apps, perhaps enabled via a cmd line flag or some other developer 123 // their apps, perhaps enabled via a cmd line flag or some other developer
123 // tool setting. Unfortunately file scheme net::URLRequests don't produce the 124 // tool setting. Unfortunately file scheme net::URLRequests don't produce the
124 // same signalling (200 response codes, headers) as http URLRequests, so this 125 // same signalling (200 response codes, headers) as http URLRequests, so this
125 // doesn't work just yet. 126 // doesn't work just yet.
126 // supported |= url.SchemeIsFile(); 127 // supported |= url.SchemeIsFile();
127 #endif 128 #endif
128 return supported; 129 return supported;
129 } 130 }
130 131
131 bool IsMethodSupportedForAppCache(const std::string& method) { 132 bool IsMethodSupportedForAppCache(const std::string& method) {
132 return (method == kHttpGETMethod) || (method == kHttpHEADMethod); 133 return (method == kHttpGETMethod) || (method == kHttpHEADMethod);
133 } 134 }
134 135
135 bool IsSchemeAndMethodSupportedForAppCache(const net::URLRequest* request) { 136 bool IsSchemeAndMethodSupportedForAppCache(const net::URLRequest* request) {
136 return IsSchemeSupportedForAppCache(request->url()) && 137 return IsSchemeSupportedForAppCache(request->url()) &&
137 IsMethodSupportedForAppCache(request->method()); 138 IsMethodSupportedForAppCache(request->method());
138 } 139 }
139 140
140 } // namespace content 141 } // namespace content
OLDNEW
« no previous file with comments | « content/child/simple_webmimeregistry_impl.cc ('k') | content/public/test/browser_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698