Chromium Code Reviews| 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|. | 95 // The instance takes ownership of |config_service| and |resolver_factory|. | 
| 
 
Randy Smith (Not in Mondays)
2015/09/18 20:14:55
I think this comment is no longer needed; the same
 
Charlie Harrison
2015/09/21 16:47:05
Done.
 
 | |
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 // is needed if the ProxyResolver is of type ProxyResolverWithoutFetch. | 196 // is needed if the ProxyResolver is of type ProxyResolverWithoutFetch. | 
| 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. | 
| 207 // |new_proxy_config_service|. | 207 void ResetConfigService( | 
| 208 void ResetConfigService(ProxyConfigService* new_proxy_config_service); | 208 scoped_ptr<ProxyConfigService> new_proxy_config_service); | 
| 209 | 209 | 
| 210 // Returns the last configuration fetched from ProxyConfigService. | 210 // Returns the last configuration fetched from ProxyConfigService. | 
| 211 const ProxyConfig& fetched_config() { | 211 const ProxyConfig& fetched_config() { | 
| 212 return fetched_config_; | 212 return fetched_config_; | 
| 213 } | 213 } | 
| 214 | 214 | 
| 215 // Returns the current configuration being used by ProxyConfigService. | 215 // Returns the current configuration being used by ProxyConfigService. | 
| 216 const ProxyConfig& config() const { | 216 const ProxyConfig& config() const { | 
| 217 return config_; | 217 return config_; | 
| 218 } | 218 } | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 229 | 229 | 
| 230 // Forces refetching the proxy configuration, and applying it. | 230 // Forces refetching the proxy configuration, and applying it. | 
| 231 // This re-does everything from fetching the system configuration, | 231 // This re-does everything from fetching the system configuration, | 
| 232 // to downloading and testing the PAC files. | 232 // to downloading and testing the PAC files. | 
| 233 void ForceReloadProxyConfig(); | 233 void ForceReloadProxyConfig(); | 
| 234 | 234 | 
| 235 // Same as CreateProxyServiceUsingV8ProxyResolver, except it uses system | 235 // Same as CreateProxyServiceUsingV8ProxyResolver, except it uses system | 
| 236 // libraries for evaluating the PAC script if available, otherwise skips | 236 // libraries for evaluating the PAC script if available, otherwise skips | 
| 237 // proxy autoconfig. | 237 // proxy autoconfig. | 
| 238 static scoped_ptr<ProxyService> CreateUsingSystemProxyResolver( | 238 static scoped_ptr<ProxyService> CreateUsingSystemProxyResolver( | 
| 239 ProxyConfigService* proxy_config_service, | 239 scoped_ptr<ProxyConfigService> proxy_config_service, | 
| 240 size_t num_pac_threads, | 240 size_t num_pac_threads, | 
| 241 NetLog* net_log); | 241 NetLog* net_log); | 
| 242 | 242 | 
| 243 // Creates a ProxyService without support for proxy autoconfig. | 243 // Creates a ProxyService without support for proxy autoconfig. | 
| 244 static scoped_ptr<ProxyService> CreateWithoutProxyResolver( | 244 static scoped_ptr<ProxyService> CreateWithoutProxyResolver( | 
| 245 ProxyConfigService* proxy_config_service, | 245 scoped_ptr<ProxyConfigService> proxy_config_service, | 
| 246 NetLog* net_log); | 246 NetLog* net_log); | 
| 247 | 247 | 
| 248 // Convenience methods that creates a proxy service using the | 248 // Convenience methods that creates a proxy service using the | 
| 249 // specified fixed settings. | 249 // specified fixed settings. | 
| 250 static scoped_ptr<ProxyService> CreateFixed(const ProxyConfig& pc); | 250 static scoped_ptr<ProxyService> CreateFixed(const ProxyConfig& pc); | 
| 251 static scoped_ptr<ProxyService> CreateFixed(const std::string& proxy); | 251 static scoped_ptr<ProxyService> CreateFixed(const std::string& proxy); | 
| 252 | 252 | 
| 253 // 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. | 
| 254 static scoped_ptr<ProxyService> CreateDirect(); | 254 static scoped_ptr<ProxyService> CreateDirect(); | 
| 255 // |net_log|'s lifetime must exceed ProxyService. | 255 // |net_log|'s lifetime must exceed ProxyService. | 
| 256 static scoped_ptr<ProxyService> CreateDirectWithNetLog(NetLog* net_log); | 256 static scoped_ptr<ProxyService> CreateDirectWithNetLog(NetLog* net_log); | 
| 257 | 257 | 
| 258 // 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 | 
| 259 // hardcoded proxy fallback list (|pac_string|) for every URL. | 259 // hardcoded proxy fallback list (|pac_string|) for every URL. | 
| 260 // | 260 // | 
| 261 // |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 | 
| 262 // 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" | 
| 263 static scoped_ptr<ProxyService> CreateFixedFromPacResult( | 263 static scoped_ptr<ProxyService> CreateFixedFromPacResult( | 
| 264 const std::string& pac_string); | 264 const std::string& pac_string); | 
| 265 | 265 | 
| 266 // Creates a config service appropriate for this platform that fetches the | 266 // Creates a config service appropriate for this platform that fetches the | 
| 267 // system proxy settings. | 267 // system proxy settings. | 
| 268 static ProxyConfigService* CreateSystemProxyConfigService( | 268 static scoped_ptr<ProxyConfigService> CreateSystemProxyConfigService( | 
| 269 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 269 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 
| 270 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); | 270 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); | 
| 271 | 271 | 
| 272 // This method should only be used by unit tests. | 272 // This method should only be used by unit tests. | 
| 273 void set_stall_proxy_auto_config_delay(base::TimeDelta delay) { | 273 void set_stall_proxy_auto_config_delay(base::TimeDelta delay) { | 
| 274 stall_proxy_auto_config_delay_ = delay; | 274 stall_proxy_auto_config_delay_ = delay; | 
| 275 } | 275 } | 
| 276 | 276 | 
| 277 // 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 | 
| 278 // active policy. | 278 // active policy. | 
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 | 450 | 
| 451 // Whether child ProxyScriptDeciders should use QuickCheck | 451 // Whether child ProxyScriptDeciders should use QuickCheck | 
| 452 bool quick_check_enabled_; | 452 bool quick_check_enabled_; | 
| 453 | 453 | 
| 454 DISALLOW_COPY_AND_ASSIGN(ProxyService); | 454 DISALLOW_COPY_AND_ASSIGN(ProxyService); | 
| 455 }; | 455 }; | 
| 456 | 456 | 
| 457 } // namespace net | 457 } // namespace net | 
| 458 | 458 | 
| 459 #endif // NET_PROXY_PROXY_SERVICE_H_ | 459 #endif // NET_PROXY_PROXY_SERVICE_H_ | 
| OLD | NEW |