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

Side by Side Diff: chrome/browser/extensions/api/declarative/url_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_URL_MATCHER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 URLMatcherCondition CreateURLSuffixCondition(const std::string& suffix); 141 URLMatcherCondition CreateURLSuffixCondition(const std::string& suffix);
142 URLMatcherCondition CreateURLContainsCondition(const std::string& str); 142 URLMatcherCondition CreateURLContainsCondition(const std::string& str);
143 URLMatcherCondition CreateURLEqualsCondition(const std::string& str); 143 URLMatcherCondition CreateURLEqualsCondition(const std::string& str);
144 144
145 // Removes all patterns from |pattern_singletons_| that are not listed in 145 // Removes all patterns from |pattern_singletons_| that are not listed in
146 // |used_patterns|. These patterns are not referenced any more and get 146 // |used_patterns|. These patterns are not referenced any more and get
147 // freed. 147 // freed.
148 void ForgetUnusedPatterns( 148 void ForgetUnusedPatterns(
149 const std::set<SubstringPattern::ID>& used_patterns); 149 const std::set<SubstringPattern::ID>& used_patterns);
150 150
151 // Returns true if this object retains no allocated data. Only for debugging.
152 bool IsEmpty() const;
153
151 private: 154 private:
152 // Creates a URLMatcherCondition according to the parameters passed. 155 // Creates a URLMatcherCondition according to the parameters passed.
153 // The URLMatcherCondition will refer to a SubstringPattern that is 156 // The URLMatcherCondition will refer to a SubstringPattern that is
154 // owned by |pattern_singletons_|. 157 // owned by |pattern_singletons_|.
155 URLMatcherCondition CreateCondition(URLMatcherCondition::Criterion criterion, 158 URLMatcherCondition CreateCondition(URLMatcherCondition::Criterion criterion,
156 const std::string& pattern); 159 const std::string& pattern);
157 160
158 // Prepends a "." to the hostname if it does not start with one. 161 // Prepends a "." to the hostname if it does not start with one.
159 std::string CanonicalizeHostname(const std::string& hostname) const; 162 std::string CanonicalizeHostname(const std::string& hostname) const;
160 163
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 229
227 // Returns the IDs of all URLMatcherConditionSet that match to this |url|. 230 // Returns the IDs of all URLMatcherConditionSet that match to this |url|.
228 std::set<URLMatcherConditionSet::ID> MatchURL(const GURL& url); 231 std::set<URLMatcherConditionSet::ID> MatchURL(const GURL& url);
229 232
230 // Returns the URLMatcherConditionFactory that must be used to create 233 // Returns the URLMatcherConditionFactory that must be used to create
231 // URLMatcherConditionSets for this URLMatcher. 234 // URLMatcherConditionSets for this URLMatcher.
232 URLMatcherConditionFactory* condition_factory() { 235 URLMatcherConditionFactory* condition_factory() {
233 return &condition_factory_; 236 return &condition_factory_;
234 } 237 }
235 238
239 // Returns true if this object retains no allocated data. Only for debugging.
240 bool IsEmpty() const;
241
236 private: 242 private:
237 void UpdateSubstringSetMatcher(bool full_url_conditions); 243 void UpdateSubstringSetMatcher(bool full_url_conditions);
238 void UpdateTriggers(); 244 void UpdateTriggers();
239 void UpdateConditionFactory(); 245 void UpdateConditionFactory();
240 void UpdateInternalDatastructures(); 246 void UpdateInternalDatastructures();
241 247
242 URLMatcherConditionFactory condition_factory_; 248 URLMatcherConditionFactory condition_factory_;
243 249
244 // Maps the ID of a URLMatcherConditionSet to the respective 250 // Maps the ID of a URLMatcherConditionSet to the respective
245 // URLMatcherConditionSet. 251 // URLMatcherConditionSet.
(...skipping 10 matching lines...) Expand all
256 SubstringSetMatcher url_component_matcher_; 262 SubstringSetMatcher url_component_matcher_;
257 std::set<const SubstringPattern*> registered_full_url_patterns_; 263 std::set<const SubstringPattern*> registered_full_url_patterns_;
258 std::set<const SubstringPattern*> registered_url_component_patterns_; 264 std::set<const SubstringPattern*> registered_url_component_patterns_;
259 265
260 DISALLOW_COPY_AND_ASSIGN(URLMatcher); 266 DISALLOW_COPY_AND_ASSIGN(URLMatcher);
261 }; 267 };
262 268
263 } // namespace extensions 269 } // namespace extensions
264 270
265 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_ 271 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698