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

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h

Issue 49693003: Refactor RulesRegistryWithCache to RulesRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits Created 7 years, 1 month 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
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_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>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "chrome/browser/extensions/api/declarative/declarative_rule.h" 19 #include "chrome/browser/extensions/api/declarative/declarative_rule.h"
20 #include "chrome/browser/extensions/api/declarative/rules_registry_with_cache.h" 20 #include "chrome/browser/extensions/api/declarative/rules_registry.h"
21 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h" 21 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h"
22 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action .h" 22 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action .h"
23 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit ion.h" 23 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit ion.h"
24 #include "chrome/browser/extensions/extension_info_map.h" 24 #include "chrome/browser/extensions/extension_info_map.h"
25 #include "extensions/common/matcher/url_matcher.h" 25 #include "extensions/common/matcher/url_matcher.h"
26 26
27 class Profile; 27 class Profile;
28 class WebRequestPermissions; 28 class WebRequestPermissions;
29 29
30 namespace extension_web_request_api_helpers { 30 namespace extension_web_request_api_helpers {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // is delegated to a URLMatcher, because this is capable of evaluating many 64 // is delegated to a URLMatcher, because this is capable of evaluating many
65 // of such URL related condition attributes in parallel. 65 // of such URL related condition attributes in parallel.
66 // 66 //
67 // For this, the URLRequestCondition has a URLMatcherConditionSet, which 67 // For this, the URLRequestCondition has a URLMatcherConditionSet, which
68 // represents the {'host_suffix': 'example.com', 'path_prefix': '/query'} part. 68 // represents the {'host_suffix': 'example.com', 'path_prefix': '/query'} part.
69 // We will then ask the URLMatcher, whether a given URL 69 // We will then ask the URLMatcher, whether a given URL
70 // "http://www.example.com/query/" has any matches, and the URLMatcher 70 // "http://www.example.com/query/" has any matches, and the URLMatcher
71 // will respond with the URLMatcherConditionSet::ID. We can map this 71 // will respond with the URLMatcherConditionSet::ID. We can map this
72 // to the WebRequestRule and check whether also the other conditions (in this 72 // to the WebRequestRule and check whether also the other conditions (in this
73 // example 'scheme': 'http') are fulfilled. 73 // example 'scheme': 'http') are fulfilled.
74 class WebRequestRulesRegistry : public RulesRegistryWithCache { 74 class WebRequestRulesRegistry : public RulesRegistry {
75 public: 75 public:
76 // For testing, |ui_part| can be NULL. In that case it constructs the 76 // |cache_delegate| can be NULL. In that case it constructs the registry with
77 // registry with storage functionality suspended. 77 // storage functionality suspended.
78 WebRequestRulesRegistry( 78 WebRequestRulesRegistry(Profile* profile,
79 Profile* profile, 79 scoped_ptr<RulesCacheDelegate>* cache_delegate);
80 scoped_ptr<RulesRegistryWithCache::RuleStorageOnUI>* ui_part);
81 80
82 // TODO(battre): This will become an implementation detail, because we need 81 // TODO(battre): This will become an implementation detail, because we need
83 // a way to also execute the actions of the rules. 82 // a way to also execute the actions of the rules.
84 std::set<const WebRequestRule*> GetMatches( 83 std::set<const WebRequestRule*> GetMatches(
85 const WebRequestData& request_data_without_ids) const; 84 const WebRequestData& request_data_without_ids) const;
86 85
87 // Returns which modifications should be executed on the network request 86 // Returns which modifications should be executed on the network request
88 // according to the rules registered in this registry. 87 // according to the rules registered in this registry.
89 std::list<LinkedPtrEventResponseDelta> CreateDeltas( 88 std::list<LinkedPtrEventResponseDelta> CreateDeltas(
90 const ExtensionInfoMap* extension_info_map, 89 const ExtensionInfoMap* extension_info_map,
91 const WebRequestData& request_data, 90 const WebRequestData& request_data,
92 bool crosses_incognito); 91 bool crosses_incognito);
93 92
94 // Implementation of RulesRegistryWithCache: 93 // Implementation of RulesRegistry:
95 virtual std::string AddRulesImpl( 94 virtual std::string AddRulesImpl(
96 const std::string& extension_id, 95 const std::string& extension_id,
97 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE; 96 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE;
98 virtual std::string RemoveRulesImpl( 97 virtual std::string RemoveRulesImpl(
99 const std::string& extension_id, 98 const std::string& extension_id,
100 const std::vector<std::string>& rule_identifiers) OVERRIDE; 99 const std::vector<std::string>& rule_identifiers) OVERRIDE;
101 virtual std::string RemoveAllRulesImpl( 100 virtual std::string RemoveAllRulesImpl(
102 const std::string& extension_id) OVERRIDE; 101 const std::string& extension_id) OVERRIDE;
103 102
104 // Returns true if this object retains no allocated data. Only for debugging. 103 // Returns true if this object retains no allocated data. Only for debugging.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 183
185 void* profile_id_; 184 void* profile_id_;
186 scoped_refptr<ExtensionInfoMap> extension_info_map_; 185 scoped_refptr<ExtensionInfoMap> extension_info_map_;
187 186
188 DISALLOW_COPY_AND_ASSIGN(WebRequestRulesRegistry); 187 DISALLOW_COPY_AND_ASSIGN(WebRequestRulesRegistry);
189 }; 188 };
190 189
191 } // namespace extensions 190 } // namespace extensions
192 191
193 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES _REGISTRY_H_ 192 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES _REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698