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