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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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|. | 94 // The instance takes ownership of |config_service| and |resolver|. |
| 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(ProxyConfigService* config_service, |
| 98 ProxyResolver* resolver, | 98 ProxyResolver* resolver, |
| 99 NetworkDelegate* network_delegate, | |
|
mmenke
2014/06/27 18:59:35
Suggest making this an argument to ResolveProxy in
rcs
2014/06/28 03:53:38
Done.
| |
| 99 NetLog* net_log); | 100 NetLog* net_log); |
| 100 | 101 |
| 101 virtual ~ProxyService(); | 102 virtual ~ProxyService(); |
| 102 | 103 |
| 103 // Used internally to handle PAC queries. | 104 // Used internally to handle PAC queries. |
| 104 // TODO(eroman): consider naming this simply "Request". | 105 // TODO(eroman): consider naming this simply "Request". |
| 105 class PacRequest; | 106 class PacRequest; |
| 106 | 107 |
| 107 // 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 |
| 108 // synchronously, to indicate that the result will be available when the | 109 // synchronously, to indicate that the result will be available when the |
| 109 // callback is run. The callback is run on the thread that calls | 110 // callback is run. The callback is run on the thread that calls |
| 110 // ResolveProxy. | 111 // ResolveProxy. |
| 111 // | 112 // |
| 112 // The caller is responsible for ensuring that |results| and |callback| | 113 // The caller is responsible for ensuring that |results| and |callback| |
| 113 // remain valid until the callback is run or until |pac_request| is cancelled | 114 // remain valid until the callback is run or until |pac_request| is cancelled |
| 114 // via CancelPacRequest. |pac_request| is only valid while the completion | 115 // via CancelPacRequest. |pac_request| is only valid while the completion |
| 115 // callback is still pending. NULL can be passed for |pac_request| if | 116 // callback is still pending. NULL can be passed for |pac_request| if |
| 116 // the caller will not need to cancel the request. | 117 // the caller will not need to cancel the request. |
| 117 // | 118 // |
| 118 // We use the three possible proxy access types in the following order, | 119 // We use the three possible proxy access types in the following order, |
| 119 // doing fallback if one doesn't work. See "pac_script_decider.h" | 120 // doing fallback if one doesn't work. See "pac_script_decider.h" |
| 120 // for the specifics. | 121 // for the specifics. |
| 121 // 1. WPAD auto-detection | 122 // 1. WPAD auto-detection |
| 122 // 2. PAC URL | 123 // 2. PAC URL |
| 123 // 3. named proxy | 124 // 3. named proxy |
| 124 // | 125 // |
| 125 // Profiling information for the request is saved to |net_log| if non-NULL. | 126 // Profiling information for the request is saved to |net_log| if non-NULL. |
| 126 int ResolveProxy(const GURL& url, | 127 int ResolveProxy(const GURL& url, |
| 128 int load_flags, | |
| 127 ProxyInfo* results, | 129 ProxyInfo* results, |
| 128 const net::CompletionCallback& callback, | 130 const net::CompletionCallback& callback, |
| 129 PacRequest** pac_request, | 131 PacRequest** pac_request, |
| 130 const BoundNetLog& net_log); | 132 const BoundNetLog& net_log); |
| 131 | 133 |
| 132 // This method is called after a failure to connect or resolve a host name. | 134 // This method is called after a failure to connect or resolve a host name. |
| 133 // It gives the proxy service an opportunity to reconsider the proxy to use. | 135 // It gives the proxy service an opportunity to reconsider the proxy to use. |
| 134 // The |results| parameter contains the results returned by an earlier call | 136 // The |results| parameter contains the results returned by an earlier call |
| 135 // to ResolveProxy. The |net_error| parameter contains the network error | 137 // to ResolveProxy. The |net_error| parameter contains the network error |
| 136 // code associated with the failure. See "net/base/net_error_list.h" for a | 138 // code associated with the failure. See "net/base/net_error_list.h" for a |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 // starts initializing for it. | 346 // starts initializing for it. |
| 345 void ApplyProxyConfigIfAvailable(); | 347 void ApplyProxyConfigIfAvailable(); |
| 346 | 348 |
| 347 // Callback for when the proxy resolver has been initialized with a | 349 // Callback for when the proxy resolver has been initialized with a |
| 348 // PAC script. | 350 // PAC script. |
| 349 void OnInitProxyResolverComplete(int result); | 351 void OnInitProxyResolverComplete(int result); |
| 350 | 352 |
| 351 // Returns ERR_IO_PENDING if the request cannot be completed synchronously. | 353 // Returns ERR_IO_PENDING if the request cannot be completed synchronously. |
| 352 // Otherwise it fills |result| with the proxy information for |url|. | 354 // Otherwise it fills |result| with the proxy information for |url|. |
| 353 // Completing synchronously means we don't need to query ProxyResolver. | 355 // Completing synchronously means we don't need to query ProxyResolver. |
| 354 int TryToCompleteSynchronously(const GURL& url, ProxyInfo* result); | 356 int TryToCompleteSynchronously(const GURL& url, int load_flags, |
| 357 ProxyInfo* result); | |
| 355 | 358 |
| 356 // Cancels all of the requests sent to the ProxyResolver. These will be | 359 // Cancels all of the requests sent to the ProxyResolver. These will be |
| 357 // restarted when calling SetReady(). | 360 // restarted when calling SetReady(). |
| 358 void SuspendAllPendingRequests(); | 361 void SuspendAllPendingRequests(); |
| 359 | 362 |
| 360 // Advances the current state to |STATE_READY|, and resumes any pending | 363 // Advances the current state to |STATE_READY|, and resumes any pending |
| 361 // requests which had been stalled waiting for initialization to complete. | 364 // requests which had been stalled waiting for initialization to complete. |
| 362 void SetReady(); | 365 void SetReady(); |
| 363 | 366 |
| 364 // Returns true if |pending_requests_| contains |req|. | 367 // Returns true if |pending_requests_| contains |req|. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 | 440 |
| 438 // Helper to poll the PAC script for changes. | 441 // Helper to poll the PAC script for changes. |
| 439 scoped_ptr<ProxyScriptDeciderPoller> script_poller_; | 442 scoped_ptr<ProxyScriptDeciderPoller> script_poller_; |
| 440 | 443 |
| 441 State current_state_; | 444 State current_state_; |
| 442 | 445 |
| 443 // Either OK or an ERR_* value indicating that a permanent error (e.g. | 446 // Either OK or an ERR_* value indicating that a permanent error (e.g. |
| 444 // failed to fetch the PAC script) prevents proxy resolution. | 447 // failed to fetch the PAC script) prevents proxy resolution. |
| 445 int permanent_error_; | 448 int permanent_error_; |
| 446 | 449 |
| 450 // Network Delegate manages callbacks to be invoked for upon Proxy Resolution. | |
|
mmenke
2014/06/27 18:59:35
nit: "NetworkDelegate", "proxy resolution"
rcs
2014/06/28 03:53:38
Done.
| |
| 451 NetworkDelegate* network_delegate_; | |
| 452 | |
| 447 // This is the log where any events generated by |init_proxy_resolver_| are | 453 // This is the log where any events generated by |init_proxy_resolver_| are |
| 448 // sent to. | 454 // sent to. |
| 449 NetLog* net_log_; | 455 NetLog* net_log_; |
| 450 | 456 |
| 451 // The earliest time at which we should run any proxy auto-config. (Used to | 457 // The earliest time at which we should run any proxy auto-config. (Used to |
| 452 // stall re-configuration following an IP address change). | 458 // stall re-configuration following an IP address change). |
| 453 base::TimeTicks stall_proxy_autoconfig_until_; | 459 base::TimeTicks stall_proxy_autoconfig_until_; |
| 454 | 460 |
| 455 // The amount of time to stall requests following IP address changes. | 461 // The amount of time to stall requests following IP address changes. |
| 456 base::TimeDelta stall_proxy_auto_config_delay_; | 462 base::TimeDelta stall_proxy_auto_config_delay_; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 | 499 |
| 494 base::WaitableEvent event_; | 500 base::WaitableEvent event_; |
| 495 CompletionCallback callback_; | 501 CompletionCallback callback_; |
| 496 ProxyInfo proxy_info_; | 502 ProxyInfo proxy_info_; |
| 497 int result_; | 503 int result_; |
| 498 }; | 504 }; |
| 499 | 505 |
| 500 } // namespace net | 506 } // namespace net |
| 501 | 507 |
| 502 #endif // NET_PROXY_PROXY_SERVICE_H_ | 508 #endif // NET_PROXY_PROXY_SERVICE_H_ |
| OLD | NEW |