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

Side by Side Diff: chrome/browser/extensions/api/declarative/substring_set_matcher.h

Issue 9844028: Implement rules removal for WebRequestRulesRegistry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 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 CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_SUBSTRING_SET_MATCHER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_SUBSTRING_SET_MATCHER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_SUBSTRING_SET_MATCHER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_SUBSTRING_SET_MATCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 void RegisterAndUnregisterPatterns( 61 void RegisterAndUnregisterPatterns(
62 const std::vector<const SubstringPattern*>& to_register, 62 const std::vector<const SubstringPattern*>& to_register,
63 const std::vector<const SubstringPattern*>& to_unregister); 63 const std::vector<const SubstringPattern*>& to_unregister);
64 64
65 // Matches |text| against all registered SubstringPatterns. Stores the IDs 65 // Matches |text| against all registered SubstringPatterns. Stores the IDs
66 // of matching patterns in |matches|. |matches| is not cleared before adding 66 // of matching patterns in |matches|. |matches| is not cleared before adding
67 // to it. 67 // to it.
68 bool Match(const std::string& text, 68 bool Match(const std::string& text,
69 std::set<SubstringPattern::ID>* matches) const; 69 std::set<SubstringPattern::ID>* matches) const;
70 70
71 // Returns true if this object retains no allocated data. Only for debugging.
72 bool IsEmpty() const;
73
71 private: 74 private:
72 // A node of an Aho Corasick Tree. This is implemented according to 75 // A node of an Aho Corasick Tree. This is implemented according to
73 // http://www.cs.uku.fi/~kilpelai/BSA05/lectures/slides04.pdf 76 // http://www.cs.uku.fi/~kilpelai/BSA05/lectures/slides04.pdf
74 // 77 //
75 // The algorithm is based on the idea of building a trie of all registered 78 // The algorithm is based on the idea of building a trie of all registered
76 // patterns. Each node of the tree is annotated with a set of pattern 79 // patterns. Each node of the tree is annotated with a set of pattern
77 // IDs that are used to report matches. 80 // IDs that are used to report matches.
78 // 81 //
79 // The root of the trie represents an empty match. If we were looking whether 82 // The root of the trie represents an empty match. If we were looking whether
80 // any registered pattern matches a text at the beginning of the text (i.e. 83 // any registered pattern matches a text at the beginning of the text (i.e.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 152
150 // The nodes of a Aho-Corasick tree. 153 // The nodes of a Aho-Corasick tree.
151 std::vector<AhoCorasickNode> tree_; 154 std::vector<AhoCorasickNode> tree_;
152 155
153 DISALLOW_COPY_AND_ASSIGN(SubstringSetMatcher); 156 DISALLOW_COPY_AND_ASSIGN(SubstringSetMatcher);
154 }; 157 };
155 158
156 } // namespace extensions 159 } // namespace extensions
157 160
158 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_SUBSTRING_SET_MATCHER_H_ 161 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_SUBSTRING_SET_MATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698