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

Side by Side Diff: extensions/common/matcher/url_matcher.cc

Issue 13699007: Provide a mechanism to the decl. WebRequest API to match URLs without the query against a RegEx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 7 years, 8 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 | Annotate | Revision Log
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 "extensions/common/matcher/url_matcher.h" 5 #include "extensions/common/matcher/url_matcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // 139 //
140 // This class also supports matching regular expressions (RE2 syntax) 140 // This class also supports matching regular expressions (RE2 syntax)
141 // against full URLs, which are transformed as in case 2. 141 // against full URLs, which are transformed as in case 2.
142 142
143 namespace { 143 namespace {
144 144
145 bool IsRegexCriterion(URLMatcherCondition::Criterion criterion) { 145 bool IsRegexCriterion(URLMatcherCondition::Criterion criterion) {
146 return criterion == URLMatcherCondition::URL_MATCHES; 146 return criterion == URLMatcherCondition::URL_MATCHES;
147 } 147 }
148 148
149 bool IsOriginAndPathRegexCriterion(URLMatcherCondition::Criterion criterion) {
150 return criterion == URLMatcherCondition::ORIGIN_AND_PATH_MATCHES;
151 }
152
149 } // namespace 153 } // namespace
150 154
151 // 155 //
152 // URLMatcherCondition 156 // URLMatcherCondition
153 // 157 //
154 158
155 URLMatcherCondition::URLMatcherCondition() 159 URLMatcherCondition::URLMatcherCondition()
156 : criterion_(HOST_PREFIX), 160 : criterion_(HOST_PREFIX),
157 string_pattern_(NULL) {} 161 string_pattern_(NULL) {}
158 162
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 default: 206 default:
203 break; 207 break;
204 } 208 }
205 return false; 209 return false;
206 } 210 }
207 211
208 bool URLMatcherCondition::IsRegexCondition() const { 212 bool URLMatcherCondition::IsRegexCondition() const {
209 return IsRegexCriterion(criterion_); 213 return IsRegexCriterion(criterion_);
210 } 214 }
211 215
216 bool URLMatcherCondition::IsOriginAndPathRegexCondition() const {
217 return IsOriginAndPathRegexCriterion(criterion_);
218 }
219
212 bool URLMatcherCondition::IsMatch( 220 bool URLMatcherCondition::IsMatch(
213 const std::set<StringPattern::ID>& matching_patterns, 221 const std::set<StringPattern::ID>& matching_patterns,
214 const GURL& url) const { 222 const GURL& url) const {
215 DCHECK(string_pattern_); 223 DCHECK(string_pattern_);
216 if (!ContainsKey(matching_patterns, string_pattern_->id())) 224 if (!ContainsKey(matching_patterns, string_pattern_->id()))
217 return false; 225 return false;
218 // The criteria HOST_CONTAINS, PATH_CONTAINS, QUERY_CONTAINS are based on 226 // The criteria HOST_CONTAINS, PATH_CONTAINS, QUERY_CONTAINS are based on
219 // a substring match on the raw URL. In case of a match, we need to verify 227 // a substring match on the raw URL. In case of a match, we need to verify
220 // that the match was found in the correct component of the URL. 228 // that the match was found in the correct component of the URL.
221 switch (criterion_) { 229 switch (criterion_) {
(...skipping 22 matching lines...) Expand all
244 const char kEndOfDomain[] = {static_cast<char>(-2), 0}; 252 const char kEndOfDomain[] = {static_cast<char>(-2), 0};
245 const char kEndOfPath[] = {static_cast<char>(-3), 0}; 253 const char kEndOfPath[] = {static_cast<char>(-3), 0};
246 const char kEndOfURL[] = {static_cast<char>(-4), 0}; 254 const char kEndOfURL[] = {static_cast<char>(-4), 0};
247 } // namespace 255 } // namespace
248 256
249 URLMatcherConditionFactory::URLMatcherConditionFactory() : id_counter_(0) {} 257 URLMatcherConditionFactory::URLMatcherConditionFactory() : id_counter_(0) {}
250 258
251 URLMatcherConditionFactory::~URLMatcherConditionFactory() { 259 URLMatcherConditionFactory::~URLMatcherConditionFactory() {
252 STLDeleteElements(&substring_pattern_singletons_); 260 STLDeleteElements(&substring_pattern_singletons_);
253 STLDeleteElements(&regex_pattern_singletons_); 261 STLDeleteElements(&regex_pattern_singletons_);
262 STLDeleteElements(&origin_and_path_regex_pattern_singletons_);
254 } 263 }
255 264
256 std::string URLMatcherConditionFactory::CanonicalizeURLForComponentSearches( 265 std::string URLMatcherConditionFactory::CanonicalizeURLForComponentSearches(
257 const GURL& url) const { 266 const GURL& url) const {
258 return kBeginningOfURL + CanonicalizeHostname(url.host()) + kEndOfDomain + 267 return kBeginningOfURL + CanonicalizeHostname(url.host()) + kEndOfDomain +
259 url.path() + kEndOfPath + 268 url.path() + kEndOfPath +
260 (url.has_query() ? "?" + url.query() : std::string()) + kEndOfURL; 269 (url.has_query() ? "?" + url.query() : std::string()) + kEndOfURL;
261 } 270 }
262 271
263 URLMatcherCondition URLMatcherConditionFactory::CreateHostPrefixCondition( 272 URLMatcherCondition URLMatcherConditionFactory::CreateHostPrefixCondition(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 const std::string& port = url.scheme(); 382 const std::string& port = url.scheme();
374 if (url_canon::DefaultPortForScheme(port.c_str(), port.size()) == 383 if (url_canon::DefaultPortForScheme(port.c_str(), port.size()) ==
375 url.EffectiveIntPort()) { 384 url.EffectiveIntPort()) {
376 replacements.ClearPort(); 385 replacements.ClearPort();
377 } 386 }
378 } 387 }
379 return kBeginningOfURL + url.ReplaceComponents(replacements).spec() + 388 return kBeginningOfURL + url.ReplaceComponents(replacements).spec() +
380 kEndOfURL; 389 kEndOfURL;
381 } 390 }
382 391
383 std::string URLMatcherConditionFactory::CanonicalizeURLForRegexSearches( 392 static std::string CanonicalizeURLForRegexSearchesHelper(
384 const GURL& url) const { 393 const GURL& url,
394 bool clear_query) {
385 GURL::Replacements replacements; 395 GURL::Replacements replacements;
386 replacements.ClearPassword(); 396 replacements.ClearPassword();
387 replacements.ClearUsername(); 397 replacements.ClearUsername();
388 replacements.ClearRef(); 398 replacements.ClearRef();
399 if (clear_query)
400 replacements.ClearQuery();
389 // Clear port if it is implicit from scheme. 401 // Clear port if it is implicit from scheme.
390 if (url.has_port()) { 402 if (url.has_port()) {
391 const std::string& port = url.scheme(); 403 const std::string& port = url.scheme();
392 if (url_canon::DefaultPortForScheme(port.c_str(), port.size()) == 404 if (url_canon::DefaultPortForScheme(port.c_str(), port.size()) ==
393 url.EffectiveIntPort()) { 405 url.EffectiveIntPort()) {
394 replacements.ClearPort(); 406 replacements.ClearPort();
395 } 407 }
396 } 408 }
397 return url.ReplaceComponents(replacements).spec(); 409 return url.ReplaceComponents(replacements).spec();
398 } 410 }
399 411
412 std::string URLMatcherConditionFactory::CanonicalizeURLForRegexSearches(
413 const GURL& url) const {
414 return CanonicalizeURLForRegexSearchesHelper(url, false);
415 }
416
417 std::string
418 URLMatcherConditionFactory::CanonicalizeURLForOriginAndPathRegexSearches(
419 const GURL& url) const {
420 return CanonicalizeURLForRegexSearchesHelper(url, true);
421 }
422
400 URLMatcherCondition URLMatcherConditionFactory::CreateURLPrefixCondition( 423 URLMatcherCondition URLMatcherConditionFactory::CreateURLPrefixCondition(
401 const std::string& prefix) { 424 const std::string& prefix) {
402 return CreateCondition(URLMatcherCondition::URL_PREFIX, 425 return CreateCondition(URLMatcherCondition::URL_PREFIX,
403 kBeginningOfURL + prefix); 426 kBeginningOfURL + prefix);
404 } 427 }
405 428
406 URLMatcherCondition URLMatcherConditionFactory::CreateURLSuffixCondition( 429 URLMatcherCondition URLMatcherConditionFactory::CreateURLSuffixCondition(
407 const std::string& suffix) { 430 const std::string& suffix) {
408 return CreateCondition(URLMatcherCondition::URL_SUFFIX, suffix + kEndOfURL); 431 return CreateCondition(URLMatcherCondition::URL_SUFFIX, suffix + kEndOfURL);
409 } 432 }
410 433
411 URLMatcherCondition URLMatcherConditionFactory::CreateURLContainsCondition( 434 URLMatcherCondition URLMatcherConditionFactory::CreateURLContainsCondition(
412 const std::string& str) { 435 const std::string& str) {
413 return CreateCondition(URLMatcherCondition::URL_CONTAINS, str); 436 return CreateCondition(URLMatcherCondition::URL_CONTAINS, str);
414 } 437 }
415 438
416 URLMatcherCondition URLMatcherConditionFactory::CreateURLEqualsCondition( 439 URLMatcherCondition URLMatcherConditionFactory::CreateURLEqualsCondition(
417 const std::string& str) { 440 const std::string& str) {
418 return CreateCondition(URLMatcherCondition::URL_EQUALS, 441 return CreateCondition(URLMatcherCondition::URL_EQUALS,
419 kBeginningOfURL + str + kEndOfURL); 442 kBeginningOfURL + str + kEndOfURL);
420 } 443 }
421 444
422 URLMatcherCondition URLMatcherConditionFactory::CreateURLMatchesCondition( 445 URLMatcherCondition URLMatcherConditionFactory::CreateURLMatchesCondition(
423 const std::string& regex) { 446 const std::string& regex) {
424 return CreateCondition(URLMatcherCondition::URL_MATCHES, regex); 447 return CreateCondition(URLMatcherCondition::URL_MATCHES, regex);
425 } 448 }
426 449
450 URLMatcherCondition
451 URLMatcherConditionFactory::CreateOriginAndPathMatchesCondition(
452 const std::string& regex) {
453 return CreateCondition(URLMatcherCondition::ORIGIN_AND_PATH_MATCHES, regex);
454 }
455
427 void URLMatcherConditionFactory::ForgetUnusedPatterns( 456 void URLMatcherConditionFactory::ForgetUnusedPatterns(
428 const std::set<StringPattern::ID>& used_patterns) { 457 const std::set<StringPattern::ID>& used_patterns) {
429 PatternSingletons::iterator i = substring_pattern_singletons_.begin(); 458 PatternSingletons::iterator i = substring_pattern_singletons_.begin();
430 while (i != substring_pattern_singletons_.end()) { 459 while (i != substring_pattern_singletons_.end()) {
431 if (used_patterns.find((*i)->id()) != used_patterns.end()) { 460 if (ContainsKey(used_patterns, (*i)->id())) {
432 ++i; 461 ++i;
433 } else { 462 } else {
434 delete *i; 463 delete *i;
435 substring_pattern_singletons_.erase(i++); 464 substring_pattern_singletons_.erase(i++);
436 } 465 }
437 } 466 }
438 i = regex_pattern_singletons_.begin(); 467 i = regex_pattern_singletons_.begin();
439 while (i != regex_pattern_singletons_.end()) { 468 while (i != regex_pattern_singletons_.end()) {
440 if (used_patterns.find((*i)->id()) != used_patterns.end()) { 469 if (ContainsKey(used_patterns, (*i)->id())) {
441 ++i; 470 ++i;
442 } else { 471 } else {
443 delete *i; 472 delete *i;
444 regex_pattern_singletons_.erase(i++); 473 regex_pattern_singletons_.erase(i++);
445 } 474 }
446 } 475 }
476 i = origin_and_path_regex_pattern_singletons_.begin();
477 while (i != origin_and_path_regex_pattern_singletons_.end()) {
478 if (ContainsKey(used_patterns, (*i)->id())) {
479 ++i;
480 } else {
481 delete *i;
482 origin_and_path_regex_pattern_singletons_.erase(i++);
483 }
484 }
447 } 485 }
448 486
449 bool URLMatcherConditionFactory::IsEmpty() const { 487 bool URLMatcherConditionFactory::IsEmpty() const {
450 return substring_pattern_singletons_.empty() && 488 return substring_pattern_singletons_.empty() &&
451 regex_pattern_singletons_.empty(); 489 regex_pattern_singletons_.empty() &&
490 origin_and_path_regex_pattern_singletons_.empty();
452 } 491 }
453 492
454 URLMatcherCondition URLMatcherConditionFactory::CreateCondition( 493 URLMatcherCondition URLMatcherConditionFactory::CreateCondition(
455 URLMatcherCondition::Criterion criterion, 494 URLMatcherCondition::Criterion criterion,
456 const std::string& pattern) { 495 const std::string& pattern) {
457 StringPattern search_pattern(pattern, 0); 496 StringPattern search_pattern(pattern, 0);
458 PatternSingletons* pattern_singletons = 497 PatternSingletons* pattern_singletons = NULL;
459 IsRegexCriterion(criterion) ? &regex_pattern_singletons_ 498 if (IsRegexCriterion(criterion))
460 : &substring_pattern_singletons_; 499 pattern_singletons = &regex_pattern_singletons_;
500 else if (IsOriginAndPathRegexCriterion(criterion))
501 pattern_singletons = &origin_and_path_regex_pattern_singletons_;
502 else
503 pattern_singletons = &substring_pattern_singletons_;
461 504
462 PatternSingletons::const_iterator iter = 505 PatternSingletons::const_iterator iter =
463 pattern_singletons->find(&search_pattern); 506 pattern_singletons->find(&search_pattern);
464 507
465 if (iter != pattern_singletons->end()) { 508 if (iter != pattern_singletons->end()) {
466 return URLMatcherCondition(criterion, *iter); 509 return URLMatcherCondition(criterion, *iter);
467 } else { 510 } else {
468 StringPattern* new_pattern = 511 StringPattern* new_pattern =
469 new StringPattern(pattern, id_counter_++); 512 new StringPattern(pattern, id_counter_++);
470 pattern_singletons->insert(new_pattern); 513 pattern_singletons->insert(new_pattern);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 void URLMatcher::ClearUnusedConditionSets() { 654 void URLMatcher::ClearUnusedConditionSets() {
612 UpdateConditionFactory(); 655 UpdateConditionFactory();
613 } 656 }
614 657
615 std::set<URLMatcherConditionSet::ID> URLMatcher::MatchURL( 658 std::set<URLMatcherConditionSet::ID> URLMatcher::MatchURL(
616 const GURL& url) const { 659 const GURL& url) const {
617 // Find all IDs of StringPatterns that match |url|. 660 // Find all IDs of StringPatterns that match |url|.
618 // See URLMatcherConditionFactory for the canonicalization of URLs and the 661 // See URLMatcherConditionFactory for the canonicalization of URLs and the
619 // distinction between full url searches and url component searches. 662 // distinction between full url searches and url component searches.
620 std::set<StringPattern::ID> matches; 663 std::set<StringPattern::ID> matches;
621 full_url_matcher_.Match( 664 if (!full_url_matcher_.IsEmpty()) {
622 condition_factory_.CanonicalizeURLForFullSearches(url), &matches); 665 full_url_matcher_.Match(
623 url_component_matcher_.Match( 666 condition_factory_.CanonicalizeURLForFullSearches(url), &matches);
624 condition_factory_.CanonicalizeURLForComponentSearches(url), &matches); 667 }
625 regex_set_matcher_.Match( 668 if (!url_component_matcher_.IsEmpty()) {
626 condition_factory_.CanonicalizeURLForRegexSearches(url), &matches); 669 url_component_matcher_.Match(
670 condition_factory_.CanonicalizeURLForComponentSearches(url), &matches);
671 }
672 if (!regex_set_matcher_.IsEmpty()) {
673 regex_set_matcher_.Match(
674 condition_factory_.CanonicalizeURLForRegexSearches(url), &matches);
675 }
676 if (!origin_and_path_regex_set_matcher_.IsEmpty()) {
677 origin_and_path_regex_set_matcher_.Match(
678 condition_factory_.CanonicalizeURLForOriginAndPathRegexSearches(url),
679 &matches);
680 }
627 681
628 // Calculate all URLMatcherConditionSets for which all URLMatcherConditions 682 // Calculate all URLMatcherConditionSets for which all URLMatcherConditions
629 // were fulfilled. 683 // were fulfilled.
630 std::set<URLMatcherConditionSet::ID> result; 684 std::set<URLMatcherConditionSet::ID> result;
631 for (std::set<StringPattern::ID>::const_iterator i = matches.begin(); 685 for (std::set<StringPattern::ID>::const_iterator i = matches.begin();
632 i != matches.end(); ++i) { 686 i != matches.end(); ++i) {
633 // For each URLMatcherConditionSet there is exactly one condition 687 // For each URLMatcherConditionSet there is exactly one condition
634 // registered in substring_match_triggers_. This means that the following 688 // registered in substring_match_triggers_. This means that the following
635 // logic tests each URLMatcherConditionSet exactly once if it can be 689 // logic tests each URLMatcherConditionSet exactly once if it can be
636 // completely fulfilled. 690 // completely fulfilled.
(...skipping 15 matching lines...) Expand all
652 706
653 return result; 707 return result;
654 } 708 }
655 709
656 bool URLMatcher::IsEmpty() const { 710 bool URLMatcher::IsEmpty() const {
657 return condition_factory_.IsEmpty() && 711 return condition_factory_.IsEmpty() &&
658 url_matcher_condition_sets_.empty() && 712 url_matcher_condition_sets_.empty() &&
659 substring_match_triggers_.empty() && 713 substring_match_triggers_.empty() &&
660 full_url_matcher_.IsEmpty() && 714 full_url_matcher_.IsEmpty() &&
661 url_component_matcher_.IsEmpty() && 715 url_component_matcher_.IsEmpty() &&
716 regex_set_matcher_.IsEmpty() &&
717 origin_and_path_regex_set_matcher_.IsEmpty() &&
662 registered_full_url_patterns_.empty() && 718 registered_full_url_patterns_.empty() &&
663 registered_url_component_patterns_.empty(); 719 registered_url_component_patterns_.empty();
664 } 720 }
665 721
666 void URLMatcher::UpdateSubstringSetMatcher(bool full_url_conditions) { 722 void URLMatcher::UpdateSubstringSetMatcher(bool full_url_conditions) {
667 // The purpose of |full_url_conditions| is just that we need to execute 723 // The purpose of |full_url_conditions| is just that we need to execute
668 // the same logic once for Full URL searches and once for URL Component 724 // the same logic once for Full URL searches and once for URL Component
669 // searches (see URLMatcherConditionFactory). 725 // searches (see URLMatcherConditionFactory).
670 726
671 // Determine which patterns need to be registered when this function 727 // Determine which patterns need to be registered when this function
672 // terminates. 728 // terminates.
673 std::set<const StringPattern*> new_patterns; 729 std::set<const StringPattern*> new_patterns;
674 for (URLMatcherConditionSets::const_iterator condition_set_iter = 730 for (URLMatcherConditionSets::const_iterator condition_set_iter =
675 url_matcher_condition_sets_.begin(); 731 url_matcher_condition_sets_.begin();
676 condition_set_iter != url_matcher_condition_sets_.end(); 732 condition_set_iter != url_matcher_condition_sets_.end();
677 ++condition_set_iter) { 733 ++condition_set_iter) {
678 const URLMatcherConditionSet::Conditions& conditions = 734 const URLMatcherConditionSet::Conditions& conditions =
679 condition_set_iter->second->conditions(); 735 condition_set_iter->second->conditions();
680 for (URLMatcherConditionSet::Conditions::const_iterator condition_iter = 736 for (URLMatcherConditionSet::Conditions::const_iterator condition_iter =
681 conditions.begin(); condition_iter != conditions.end(); 737 conditions.begin(); condition_iter != conditions.end();
682 ++condition_iter) { 738 ++condition_iter) {
683 // If we are called to process Full URL searches, ignore others, and 739 // If we are called to process Full URL searches, ignore others, and
684 // vice versa. (Regex conditions are updated in UpdateRegexSetMatcher.) 740 // vice versa. (Regex conditions are updated in UpdateRegexSetMatcher.)
685 if (!condition_iter->IsRegexCondition() && 741 if (!condition_iter->IsRegexCondition() &&
742 !condition_iter->IsOriginAndPathRegexCondition() &&
686 full_url_conditions == condition_iter->IsFullURLCondition()) 743 full_url_conditions == condition_iter->IsFullURLCondition())
687 new_patterns.insert(condition_iter->string_pattern()); 744 new_patterns.insert(condition_iter->string_pattern());
688 } 745 }
689 } 746 }
690 747
691 // This is the set of patterns that were registered before this function 748 // This is the set of patterns that were registered before this function
692 // is called. 749 // is called.
693 std::set<const StringPattern*>& registered_patterns = 750 std::set<const StringPattern*>& registered_patterns =
694 full_url_conditions ? registered_full_url_patterns_ 751 full_url_conditions ? registered_full_url_patterns_
695 : registered_url_component_patterns_; 752 : registered_url_component_patterns_;
(...skipping 19 matching lines...) Expand all
715 url_matcher.RegisterAndUnregisterPatterns(patterns_to_register, 772 url_matcher.RegisterAndUnregisterPatterns(patterns_to_register,
716 patterns_to_unregister); 773 patterns_to_unregister);
717 774
718 // Update the set of registered_patterns for the next time this function 775 // Update the set of registered_patterns for the next time this function
719 // is being called. 776 // is being called.
720 registered_patterns.swap(new_patterns); 777 registered_patterns.swap(new_patterns);
721 } 778 }
722 779
723 void URLMatcher::UpdateRegexSetMatcher() { 780 void URLMatcher::UpdateRegexSetMatcher() {
724 std::vector<const StringPattern*> new_patterns; 781 std::vector<const StringPattern*> new_patterns;
782 std::vector<const StringPattern*> new_origin_and_path_patterns;
725 783
726 for (URLMatcherConditionSets::const_iterator condition_set_iter = 784 for (URLMatcherConditionSets::const_iterator condition_set_iter =
727 url_matcher_condition_sets_.begin(); 785 url_matcher_condition_sets_.begin();
728 condition_set_iter != url_matcher_condition_sets_.end(); 786 condition_set_iter != url_matcher_condition_sets_.end();
729 ++condition_set_iter) { 787 ++condition_set_iter) {
730 const URLMatcherConditionSet::Conditions& conditions = 788 const URLMatcherConditionSet::Conditions& conditions =
731 condition_set_iter->second->conditions(); 789 condition_set_iter->second->conditions();
732 for (URLMatcherConditionSet::Conditions::const_iterator condition_iter = 790 for (URLMatcherConditionSet::Conditions::const_iterator condition_iter =
733 conditions.begin(); condition_iter != conditions.end(); 791 conditions.begin(); condition_iter != conditions.end();
734 ++condition_iter) { 792 ++condition_iter) {
735 if (condition_iter->IsRegexCondition()) 793 if (condition_iter->IsRegexCondition()) {
736 new_patterns.push_back(condition_iter->string_pattern()); 794 new_patterns.push_back(condition_iter->string_pattern());
795 } else if (condition_iter->IsOriginAndPathRegexCondition()) {
796 new_origin_and_path_patterns.push_back(
797 condition_iter->string_pattern());
798 }
737 } 799 }
738 } 800 }
739 801
740 // Start over from scratch. We can't really do better than this, since the 802 // Start over from scratch. We can't really do better than this, since the
741 // FilteredRE2 backend doesn't support incremental updates. 803 // FilteredRE2 backend doesn't support incremental updates.
742 regex_set_matcher_.ClearPatterns(); 804 regex_set_matcher_.ClearPatterns();
743 regex_set_matcher_.AddPatterns(new_patterns); 805 regex_set_matcher_.AddPatterns(new_patterns);
806 origin_and_path_regex_set_matcher_.ClearPatterns();
807 origin_and_path_regex_set_matcher_.AddPatterns(new_origin_and_path_patterns);
744 } 808 }
745 809
746 void URLMatcher::UpdateTriggers() { 810 void URLMatcher::UpdateTriggers() {
747 // Count substring pattern frequencies. 811 // Count substring pattern frequencies.
748 std::map<StringPattern::ID, size_t> substring_pattern_frequencies; 812 std::map<StringPattern::ID, size_t> substring_pattern_frequencies;
749 for (URLMatcherConditionSets::const_iterator condition_set_iter = 813 for (URLMatcherConditionSets::const_iterator condition_set_iter =
750 url_matcher_condition_sets_.begin(); 814 url_matcher_condition_sets_.begin();
751 condition_set_iter != url_matcher_condition_sets_.end(); 815 condition_set_iter != url_matcher_condition_sets_.end();
752 ++condition_set_iter) { 816 ++condition_set_iter) {
753 const URLMatcherConditionSet::Conditions& conditions = 817 const URLMatcherConditionSet::Conditions& conditions =
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 876
813 void URLMatcher::UpdateInternalDatastructures() { 877 void URLMatcher::UpdateInternalDatastructures() {
814 UpdateSubstringSetMatcher(false); 878 UpdateSubstringSetMatcher(false);
815 UpdateSubstringSetMatcher(true); 879 UpdateSubstringSetMatcher(true);
816 UpdateRegexSetMatcher(); 880 UpdateRegexSetMatcher();
817 UpdateTriggers(); 881 UpdateTriggers();
818 UpdateConditionFactory(); 882 UpdateConditionFactory();
819 } 883 }
820 884
821 } // namespace extensions 885 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/matcher/url_matcher.h ('k') | extensions/common/matcher/url_matcher_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698