OLD | NEW |
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 "chrome/browser/extensions/api/declarative/substring_set_matcher.h" | 5 #include "chrome/browser/extensions/api/declarative/substring_set_matcher.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 bool SubstringPattern::operator<(const SubstringPattern& rhs) const { | 24 bool SubstringPattern::operator<(const SubstringPattern& rhs) const { |
25 if (id_ < rhs.id_) return true; | 25 if (id_ < rhs.id_) return true; |
26 if (id_ > rhs.id_) return false; | 26 if (id_ > rhs.id_) return false; |
27 return pattern_ < rhs.pattern_; | 27 return pattern_ < rhs.pattern_; |
28 } | 28 } |
29 | 29 |
30 // | 30 // |
31 // SubstringSetMatcher | 31 // SubstringSetMatcher |
32 // | 32 // |
33 | 33 |
34 SubstringSetMatcher::SubstringSetMatcher() {} | 34 SubstringSetMatcher::SubstringSetMatcher() { |
| 35 RebuildAhoCorasickTree(); |
| 36 } |
35 | 37 |
36 SubstringSetMatcher::~SubstringSetMatcher() {} | 38 SubstringSetMatcher::~SubstringSetMatcher() {} |
37 | 39 |
38 void SubstringSetMatcher::RegisterPatterns( | 40 void SubstringSetMatcher::RegisterPatterns( |
39 const std::vector<const SubstringPattern*>& patterns) { | 41 const std::vector<const SubstringPattern*>& patterns) { |
40 RegisterAndUnregisterPatterns(patterns, | 42 RegisterAndUnregisterPatterns(patterns, |
41 std::vector<const SubstringPattern*>()); | 43 std::vector<const SubstringPattern*>()); |
42 } | 44 } |
43 | 45 |
44 void SubstringSetMatcher::UnregisterPatterns( | 46 void SubstringSetMatcher::UnregisterPatterns( |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 void SubstringSetMatcher::AhoCorasickNode::AddMatch(SubstringPattern::ID id) { | 210 void SubstringSetMatcher::AhoCorasickNode::AddMatch(SubstringPattern::ID id) { |
209 matches_.insert(id); | 211 matches_.insert(id); |
210 } | 212 } |
211 | 213 |
212 void SubstringSetMatcher::AhoCorasickNode::AddMatches( | 214 void SubstringSetMatcher::AhoCorasickNode::AddMatches( |
213 const SubstringSetMatcher::AhoCorasickNode::Matches& matches) { | 215 const SubstringSetMatcher::AhoCorasickNode::Matches& matches) { |
214 matches_.insert(matches.begin(), matches.end()); | 216 matches_.insert(matches.begin(), matches.end()); |
215 } | 217 } |
216 | 218 |
217 } // namespace extensions | 219 } // namespace extensions |
OLD | NEW |