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