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 NET_PROXY_PROXY_SERVICE_H_ | 5 #ifndef NET_PROXY_PROXY_SERVICE_H_ |
6 #define NET_PROXY_PROXY_SERVICE_H_ | 6 #define NET_PROXY_PROXY_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 // or OK if it completed successfully. Implementations must set | 88 // or OK if it completed successfully. Implementations must set |
89 // |next_delay| to a non-negative value. | 89 // |next_delay| to a non-negative value. |
90 virtual Mode GetNextDelay(int initial_error, | 90 virtual Mode GetNextDelay(int initial_error, |
91 base::TimeDelta current_delay, | 91 base::TimeDelta current_delay, |
92 base::TimeDelta* next_delay) const = 0; | 92 base::TimeDelta* next_delay) const = 0; |
93 }; | 93 }; |
94 | 94 |
95 // The instance takes ownership of |config_service| and |resolver_factory|. | 95 // The instance takes ownership of |config_service| and |resolver_factory|. |
96 // |net_log| is a possibly NULL destination to send log events to. It must | 96 // |net_log| is a possibly NULL destination to send log events to. It must |
97 // remain alive for the lifetime of this ProxyService. | 97 // remain alive for the lifetime of this ProxyService. |
98 ProxyService(ProxyConfigService* config_service, | 98 ProxyService(scoped_ptr<ProxyConfigService> config_service, |
99 scoped_ptr<ProxyResolverFactory> resolver_factory, | 99 scoped_ptr<ProxyResolverFactory> resolver_factory, |
100 NetLog* net_log); | 100 NetLog* net_log); |
101 | 101 |
102 ~ProxyService() override; | 102 ~ProxyService() override; |
103 | 103 |
104 // Used internally to handle PAC queries. | 104 // Used internally to handle PAC queries. |
105 // TODO(eroman): consider naming this simply "Request". | 105 // TODO(eroman): consider naming this simply "Request". |
106 class PacRequest; | 106 class PacRequest; |
107 | 107 |
108 // Returns ERR_IO_PENDING if the proxy information could not be provided | 108 // Returns ERR_IO_PENDING if the proxy information could not be provided |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 // ProxyService takes ownership of proxy_script_fetcher. | 197 // ProxyService takes ownership of proxy_script_fetcher. |
198 void SetProxyScriptFetchers( | 198 void SetProxyScriptFetchers( |
199 ProxyScriptFetcher* proxy_script_fetcher, | 199 ProxyScriptFetcher* proxy_script_fetcher, |
200 scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher); | 200 scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher); |
201 ProxyScriptFetcher* GetProxyScriptFetcher() const; | 201 ProxyScriptFetcher* GetProxyScriptFetcher() const; |
202 | 202 |
203 // Tells this ProxyService to start using a new ProxyConfigService to | 203 // Tells this ProxyService to start using a new ProxyConfigService to |
204 // retrieve its ProxyConfig from. The new ProxyConfigService will immediately | 204 // retrieve its ProxyConfig from. The new ProxyConfigService will immediately |
205 // be queried for new config info which will be used for all subsequent | 205 // be queried for new config info which will be used for all subsequent |
206 // ResolveProxy calls. ProxyService takes ownership of | 206 // ResolveProxy calls. ProxyService takes ownership of |
207 // |new_proxy_config_service|. | 207 // |new_proxy_config_service|. |
mmenke
2015/09/18 18:58:54
nit: No longer need the last sentence.
Charlie Harrison
2015/09/18 19:56:06
Done.
| |
208 void ResetConfigService(ProxyConfigService* new_proxy_config_service); | 208 void ResetConfigService( |
209 scoped_ptr<ProxyConfigService> new_proxy_config_service); | |
209 | 210 |
210 // Returns the last configuration fetched from ProxyConfigService. | 211 // Returns the last configuration fetched from ProxyConfigService. |
211 const ProxyConfig& fetched_config() { | 212 const ProxyConfig& fetched_config() { |
212 return fetched_config_; | 213 return fetched_config_; |
213 } | 214 } |
214 | 215 |
215 // Returns the current configuration being used by ProxyConfigService. | 216 // Returns the current configuration being used by ProxyConfigService. |
216 const ProxyConfig& config() const { | 217 const ProxyConfig& config() const { |
217 return config_; | 218 return config_; |
218 } | 219 } |
(...skipping 10 matching lines...) Expand all Loading... | |
229 | 230 |
230 // Forces refetching the proxy configuration, and applying it. | 231 // Forces refetching the proxy configuration, and applying it. |
231 // This re-does everything from fetching the system configuration, | 232 // This re-does everything from fetching the system configuration, |
232 // to downloading and testing the PAC files. | 233 // to downloading and testing the PAC files. |
233 void ForceReloadProxyConfig(); | 234 void ForceReloadProxyConfig(); |
234 | 235 |
235 // Same as CreateProxyServiceUsingV8ProxyResolver, except it uses system | 236 // Same as CreateProxyServiceUsingV8ProxyResolver, except it uses system |
236 // libraries for evaluating the PAC script if available, otherwise skips | 237 // libraries for evaluating the PAC script if available, otherwise skips |
237 // proxy autoconfig. | 238 // proxy autoconfig. |
238 static scoped_ptr<ProxyService> CreateUsingSystemProxyResolver( | 239 static scoped_ptr<ProxyService> CreateUsingSystemProxyResolver( |
239 ProxyConfigService* proxy_config_service, | 240 scoped_ptr<ProxyConfigService> proxy_config_service, |
240 size_t num_pac_threads, | 241 size_t num_pac_threads, |
241 NetLog* net_log); | 242 NetLog* net_log); |
242 | 243 |
243 // Creates a ProxyService without support for proxy autoconfig. | 244 // Creates a ProxyService without support for proxy autoconfig. |
244 static scoped_ptr<ProxyService> CreateWithoutProxyResolver( | 245 static scoped_ptr<ProxyService> CreateWithoutProxyResolver( |
245 ProxyConfigService* proxy_config_service, | 246 scoped_ptr<ProxyConfigService> proxy_config_service, |
246 NetLog* net_log); | 247 NetLog* net_log); |
247 | 248 |
248 // Convenience methods that creates a proxy service using the | 249 // Convenience methods that creates a proxy service using the |
249 // specified fixed settings. | 250 // specified fixed settings. |
250 static scoped_ptr<ProxyService> CreateFixed(const ProxyConfig& pc); | 251 static scoped_ptr<ProxyService> CreateFixed(const ProxyConfig& pc); |
251 static scoped_ptr<ProxyService> CreateFixed(const std::string& proxy); | 252 static scoped_ptr<ProxyService> CreateFixed(const std::string& proxy); |
252 | 253 |
253 // Creates a proxy service that uses a DIRECT connection for all requests. | 254 // Creates a proxy service that uses a DIRECT connection for all requests. |
254 static scoped_ptr<ProxyService> CreateDirect(); | 255 static scoped_ptr<ProxyService> CreateDirect(); |
255 // |net_log|'s lifetime must exceed ProxyService. | 256 // |net_log|'s lifetime must exceed ProxyService. |
256 static scoped_ptr<ProxyService> CreateDirectWithNetLog(NetLog* net_log); | 257 static scoped_ptr<ProxyService> CreateDirectWithNetLog(NetLog* net_log); |
257 | 258 |
258 // This method is used by tests to create a ProxyService that returns a | 259 // This method is used by tests to create a ProxyService that returns a |
259 // hardcoded proxy fallback list (|pac_string|) for every URL. | 260 // hardcoded proxy fallback list (|pac_string|) for every URL. |
260 // | 261 // |
261 // |pac_string| is a list of proxy servers, in the format that a PAC script | 262 // |pac_string| is a list of proxy servers, in the format that a PAC script |
262 // would return it. For example, "PROXY foobar:99; SOCKS fml:2; DIRECT" | 263 // would return it. For example, "PROXY foobar:99; SOCKS fml:2; DIRECT" |
263 static scoped_ptr<ProxyService> CreateFixedFromPacResult( | 264 static scoped_ptr<ProxyService> CreateFixedFromPacResult( |
264 const std::string& pac_string); | 265 const std::string& pac_string); |
265 | 266 |
266 // Creates a config service appropriate for this platform that fetches the | 267 // Creates a config service appropriate for this platform that fetches the |
267 // system proxy settings. | 268 // system proxy settings. |
268 static ProxyConfigService* CreateSystemProxyConfigService( | 269 static scoped_ptr<ProxyConfigService> CreateSystemProxyConfigService( |
269 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 270 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
270 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); | 271 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); |
271 | 272 |
272 // This method should only be used by unit tests. | 273 // This method should only be used by unit tests. |
273 void set_stall_proxy_auto_config_delay(base::TimeDelta delay) { | 274 void set_stall_proxy_auto_config_delay(base::TimeDelta delay) { |
274 stall_proxy_auto_config_delay_ = delay; | 275 stall_proxy_auto_config_delay_ = delay; |
275 } | 276 } |
276 | 277 |
277 // This method should only be used by unit tests. Returns the previously | 278 // This method should only be used by unit tests. Returns the previously |
278 // active policy. | 279 // active policy. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 | 451 |
451 // Whether child ProxyScriptDeciders should use QuickCheck | 452 // Whether child ProxyScriptDeciders should use QuickCheck |
452 bool quick_check_enabled_; | 453 bool quick_check_enabled_; |
453 | 454 |
454 DISALLOW_COPY_AND_ASSIGN(ProxyService); | 455 DISALLOW_COPY_AND_ASSIGN(ProxyService); |
455 }; | 456 }; |
456 | 457 |
457 } // namespace net | 458 } // namespace net |
458 | 459 |
459 #endif // NET_PROXY_PROXY_SERVICE_H_ | 460 #endif // NET_PROXY_PROXY_SERVICE_H_ |
OLD | NEW |