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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_RE GISTRY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_RE GISTRY_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_RE GISTRY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_RE GISTRY_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 // Virtual for testing: | 98 // Virtual for testing: |
99 virtual base::Time GetExtensionInstallationTime( | 99 virtual base::Time GetExtensionInstallationTime( |
100 const std::string& extension_id) const; | 100 const std::string& extension_id) const; |
101 virtual void ClearCacheOnNavigation(); | 101 virtual void ClearCacheOnNavigation(); |
102 | 102 |
103 private: | 103 private: |
104 typedef std::map<URLMatcherConditionSet::ID, WebRequestRule*> RuleTriggers; | 104 typedef std::map<URLMatcherConditionSet::ID, WebRequestRule*> RuleTriggers; |
105 typedef std::map<WebRequestRule::GlobalRuleId, linked_ptr<WebRequestRule> > | 105 typedef std::map<WebRequestRule::GlobalRuleId, linked_ptr<WebRequestRule> > |
106 RulesMap; | 106 RulesMap; |
107 | 107 |
108 // This wraps |rule_triggers_| into an operator usable with std::transform. | |
109 class RuleTriggersOperator { | |
battre
2012/12/06 19:53:26
If it does something then the name should be verba
Jeffrey Yasskin
2012/12/18 03:09:58
Generally I'd put a helper class like this into th
vabr (Chromium)
2013/01/21 10:57:48
Thankfully I got rid of this sub-class completely.
| |
110 public: | |
111 explicit RuleTriggersOperator(const RuleTriggers& triggers); | |
112 ~RuleTriggersOperator(); | |
113 const WebRequestRule* operator()(URLMatcherConditionSet::ID id) { | |
114 RuleTriggers::const_iterator rule_trigger = triggers_.find(id); | |
115 CHECK(rule_trigger != triggers_.end()); | |
116 return rule_trigger->second; | |
117 } | |
118 private: | |
119 RuleTriggers triggers_; | |
battre
2012/12/06 19:53:26
Instantiating this operator is somewhat expensive
Jeffrey Yasskin
2012/12/18 03:09:58
That is, make the member into a pointer, and const
vabr (Chromium)
2013/01/21 10:57:48
Oh, that was a stupid mistake of mine. However, al
| |
120 }; | |
121 | |
108 // Map that tells us which WebRequestRule may match under the condition that | 122 // Map that tells us which WebRequestRule may match under the condition that |
109 // the URLMatcherConditionSet::ID was returned by the |url_matcher_|. | 123 // the URLMatcherConditionSet::ID was returned by the |url_matcher_| and |
Jeffrey Yasskin
2012/12/18 03:09:58
That is, URLMatcherConditionSet::ID must be return
vabr (Chromium)
2013/01/21 10:57:48
One matcher matching is enough. Corrected the "and
| |
124 // |first_party_url_matcher_|. | |
110 RuleTriggers rule_triggers_; | 125 RuleTriggers rule_triggers_; |
111 | 126 |
112 RulesMap webrequest_rules_; | 127 RulesMap webrequest_rules_; |
113 | 128 |
114 URLMatcher url_matcher_; | 129 URLMatcher url_matcher_; |
130 URLMatcher first_party_url_matcher_; | |
115 | 131 |
116 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 132 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
117 }; | 133 }; |
118 | 134 |
119 } // namespace extensions | 135 } // namespace extensions |
120 | 136 |
121 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES _REGISTRY_H_ | 137 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES _REGISTRY_H_ |
OLD | NEW |