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

Side by Side Diff: components/url_matcher/url_matcher.cc

Issue 2481923002: [WIP] make GURL::path() return a StringPiece (Closed)
Patch Set: thanks asan Created 4 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/url_matcher/url_matcher.h" 5 #include "components/url_matcher/url_matcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 if (!base::ContainsKey(matching_patterns, string_pattern_->id())) 226 if (!base::ContainsKey(matching_patterns, string_pattern_->id()))
227 return false; 227 return false;
228 // The criteria HOST_CONTAINS, PATH_CONTAINS, QUERY_CONTAINS are based on 228 // The criteria HOST_CONTAINS, PATH_CONTAINS, QUERY_CONTAINS are based on
229 // a substring match on the raw URL. In case of a match, we need to verify 229 // a substring match on the raw URL. In case of a match, we need to verify
230 // that the match was found in the correct component of the URL. 230 // that the match was found in the correct component of the URL.
231 switch (criterion_) { 231 switch (criterion_) {
232 case HOST_CONTAINS: 232 case HOST_CONTAINS:
233 return url.host().find(string_pattern_->pattern()) != 233 return url.host().find(string_pattern_->pattern()) !=
234 std::string::npos; 234 std::string::npos;
235 case PATH_CONTAINS: 235 case PATH_CONTAINS:
236 return url.path().find(string_pattern_->pattern()) != 236 return url.path().as_string().find(string_pattern_->pattern()) !=
237 std::string::npos; 237 std::string::npos;
238 case QUERY_CONTAINS: 238 case QUERY_CONTAINS:
239 return url.query().find(string_pattern_->pattern()) != 239 return url.query().find(string_pattern_->pattern()) !=
240 std::string::npos; 240 std::string::npos;
241 default: 241 default:
242 break; 242 break;
243 } 243 }
244 return true; 244 return true;
245 } 245 }
246 246
247 // 247 //
(...skipping 13 matching lines...) Expand all
261 } // namespace 261 } // namespace
262 262
263 URLMatcherConditionFactory::URLMatcherConditionFactory() : id_counter_(0) {} 263 URLMatcherConditionFactory::URLMatcherConditionFactory() : id_counter_(0) {}
264 264
265 URLMatcherConditionFactory::~URLMatcherConditionFactory() { 265 URLMatcherConditionFactory::~URLMatcherConditionFactory() {
266 } 266 }
267 267
268 std::string URLMatcherConditionFactory::CanonicalizeURLForComponentSearches( 268 std::string URLMatcherConditionFactory::CanonicalizeURLForComponentSearches(
269 const GURL& url) const { 269 const GURL& url) const {
270 return kBeginningOfURL + CanonicalizeHostname(url.host()) + kEndOfDomain + 270 return kBeginningOfURL + CanonicalizeHostname(url.host()) + kEndOfDomain +
271 url.path() + kEndOfPath + 271 url.path().as_string() + kEndOfPath +
272 (url.has_query() ? CanonicalizeQuery(url.query(), true, true) 272 (url.has_query() ? CanonicalizeQuery(url.query(), true, true)
273 : std::string()) + 273 : std::string()) +
274 kEndOfURL; 274 kEndOfURL;
275 } 275 }
276 276
277 URLMatcherCondition URLMatcherConditionFactory::CreateHostPrefixCondition( 277 URLMatcherCondition URLMatcherConditionFactory::CreateHostPrefixCondition(
278 const std::string& prefix) { 278 const std::string& prefix) {
279 return CreateCondition(URLMatcherCondition::HOST_PREFIX, 279 return CreateCondition(URLMatcherCondition::HOST_PREFIX,
280 kBeginningOfURL + CanonicalizeHostPrefix(prefix)); 280 kBeginningOfURL + CanonicalizeHostPrefix(prefix));
281 } 281 }
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1089
1090 void URLMatcher::UpdateInternalDatastructures() { 1090 void URLMatcher::UpdateInternalDatastructures() {
1091 UpdateSubstringSetMatcher(false); 1091 UpdateSubstringSetMatcher(false);
1092 UpdateSubstringSetMatcher(true); 1092 UpdateSubstringSetMatcher(true);
1093 UpdateRegexSetMatcher(); 1093 UpdateRegexSetMatcher();
1094 UpdateTriggers(); 1094 UpdateTriggers();
1095 UpdateConditionFactory(); 1095 UpdateConditionFactory();
1096 } 1096 }
1097 1097
1098 } // namespace url_matcher 1098 } // namespace url_matcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698