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

Side by Side Diff: extensions/common/matcher/regex_set_matcher.h

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 #ifndef EXTENSIONS_COMMON_MATCHER_REGEX_SET_MATCHER_H_ 5 #ifndef EXTENSIONS_COMMON_MATCHER_REGEX_SET_MATCHER_H_
6 #define EXTENSIONS_COMMON_MATCHER_REGEX_SET_MATCHER_H_ 6 #define EXTENSIONS_COMMON_MATCHER_REGEX_SET_MATCHER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 25 matching lines...) Expand all
36 void AddPatterns(const std::vector<const StringPattern*>& regex_list); 36 void AddPatterns(const std::vector<const StringPattern*>& regex_list);
37 37
38 // Removes all regex patterns. 38 // Removes all regex patterns.
39 void ClearPatterns(); 39 void ClearPatterns();
40 40
41 // Appends the IDs of regular expressions in our set that match the |text| 41 // Appends the IDs of regular expressions in our set that match the |text|
42 // to |matches|. 42 // to |matches|.
43 bool Match(const std::string& text, 43 bool Match(const std::string& text,
44 std::set<StringPattern::ID>* matches) const; 44 std::set<StringPattern::ID>* matches) const;
45 45
46 bool IsEmpty() const;
47
46 private: 48 private:
47 typedef int RE2ID; 49 typedef int RE2ID;
48 typedef std::map<StringPattern::ID, const StringPattern*> RegexMap; 50 typedef std::map<StringPattern::ID, const StringPattern*> RegexMap;
49 typedef std::vector<StringPattern::ID> RE2IDMap; 51 typedef std::vector<StringPattern::ID> RE2IDMap;
50 52
51 // Use Aho-Corasick SubstringSetMatcher to find which literal patterns 53 // Use Aho-Corasick SubstringSetMatcher to find which literal patterns
52 // match the |text|. 54 // match the |text|.
53 std::vector<RE2ID> FindSubstringMatches(const std::string& text) const; 55 std::vector<RE2ID> FindSubstringMatches(const std::string& text) const;
54 56
55 // Rebuild FilteredRE2 from scratch. Needs to be called whenever 57 // Rebuild FilteredRE2 from scratch. Needs to be called whenever
(...skipping 15 matching lines...) Expand all
71 scoped_ptr<SubstringSetMatcher> substring_matcher_; 73 scoped_ptr<SubstringSetMatcher> substring_matcher_;
72 74
73 // The substring patterns from FilteredRE2, which are used in 75 // The substring patterns from FilteredRE2, which are used in
74 // |substring_matcher_| but whose lifetime is managed here. 76 // |substring_matcher_| but whose lifetime is managed here.
75 std::vector<const StringPattern*> substring_patterns_; 77 std::vector<const StringPattern*> substring_patterns_;
76 }; 78 };
77 79
78 } // namespace extensions 80 } // namespace extensions
79 81
80 #endif // EXTENSIONS_COMMON_MATCHER_REGEX_SET_MATCHER_H_ 82 #endif // EXTENSIONS_COMMON_MATCHER_REGEX_SET_MATCHER_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/events.json ('k') | extensions/common/matcher/regex_set_matcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698