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

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

Issue 1226673003: Move MatchPattern to its own header and the base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/string_util.h" 10 #include "base/strings/string_util.h"
10 #include "content/public/common/url_constants.h" 11 #include "content/public/common/url_constants.h"
11 #include "net/url_request/url_request.h" 12 #include "net/url_request/url_request.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 #include "url/url_constants.h" 14 #include "url/url_constants.h"
14 15
15 namespace content { 16 namespace content {
16 17
17 const char kHttpGETMethod[] = "GET"; 18 const char kHttpGETMethod[] = "GET";
18 const char kHttpHEADMethod[] = "HEAD"; 19 const char kHttpHEADMethod[] = "HEAD";
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 AppCacheNamespace::~AppCacheNamespace() { 99 AppCacheNamespace::~AppCacheNamespace() {
99 } 100 }
100 101
101 bool AppCacheNamespace::IsMatch(const GURL& url) const { 102 bool AppCacheNamespace::IsMatch(const GURL& url) const {
102 if (is_pattern) { 103 if (is_pattern) {
103 // We have to escape '?' characters since MatchPattern also treats those 104 // We have to escape '?' characters since MatchPattern also treats those
104 // 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.
105 std::string pattern = namespace_url.spec(); 106 std::string pattern = namespace_url.spec();
106 if (namespace_url.has_query()) 107 if (namespace_url.has_query())
107 base::ReplaceSubstringsAfterOffset(&pattern, 0, "?", "\\?"); 108 base::ReplaceSubstringsAfterOffset(&pattern, 0, "?", "\\?");
108 return MatchPattern(url.spec(), pattern); 109 return base::MatchPattern(url.spec(), pattern);
109 } 110 }
110 return base::StartsWithASCII(url.spec(), namespace_url.spec(), true); 111 return base::StartsWithASCII(url.spec(), namespace_url.spec(), true);
111 } 112 }
112 113
113 bool IsSchemeSupportedForAppCache(const GURL& url) { 114 bool IsSchemeSupportedForAppCache(const GURL& url) {
114 bool supported = url.SchemeIs(url::kHttpScheme) || 115 bool supported = url.SchemeIs(url::kHttpScheme) ||
115 url.SchemeIs(url::kHttpsScheme) || 116 url.SchemeIs(url::kHttpsScheme) ||
116 url.SchemeIs(kChromeDevToolsScheme); 117 url.SchemeIs(kChromeDevToolsScheme);
117 118
118 #ifndef NDEBUG 119 #ifndef NDEBUG
(...skipping 11 matching lines...) Expand all
130 bool IsMethodSupportedForAppCache(const std::string& method) { 131 bool IsMethodSupportedForAppCache(const std::string& method) {
131 return (method == kHttpGETMethod) || (method == kHttpHEADMethod); 132 return (method == kHttpGETMethod) || (method == kHttpHEADMethod);
132 } 133 }
133 134
134 bool IsSchemeAndMethodSupportedForAppCache(const net::URLRequest* request) { 135 bool IsSchemeAndMethodSupportedForAppCache(const net::URLRequest* request) {
135 return IsSchemeSupportedForAppCache(request->url()) && 136 return IsSchemeSupportedForAppCache(request->url()) &&
136 IsMethodSupportedForAppCache(request->method()); 137 IsMethodSupportedForAppCache(request->method());
137 } 138 }
138 139
139 } // namespace content 140 } // namespace content
OLDNEW
« no previous file with comments | « content/child/site_isolation_stats_gatherer_browsertest.cc ('k') | content/test/image_decoder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698