| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 namespace base { | 31 namespace base { |
| 32 class SingleThreadTaskRunner; | 32 class SingleThreadTaskRunner; |
| 33 class TimeDelta; | 33 class TimeDelta; |
| 34 } // namespace base | 34 } // namespace base |
| 35 | 35 |
| 36 namespace net { | 36 namespace net { |
| 37 | 37 |
| 38 class DhcpProxyScriptFetcher; | 38 class DhcpProxyScriptFetcher; |
| 39 class HostResolver; | 39 class HostResolver; |
| 40 class NetworkDelegate; | 40 class ProxyDelegate; |
| 41 class ProxyResolver; | 41 class ProxyResolver; |
| 42 class ProxyResolverFactory; | 42 class ProxyResolverFactory; |
| 43 class ProxyResolverScriptData; | 43 class ProxyResolverScriptData; |
| 44 class ProxyScriptDecider; | 44 class ProxyScriptDecider; |
| 45 class ProxyScriptFetcher; | 45 class ProxyScriptFetcher; |
| 46 | 46 |
| 47 // This class can be used to resolve the proxy server to use when loading a | 47 // This class can be used to resolve the proxy server to use when loading a |
| 48 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy | 48 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy |
| 49 // resolution. See ProxyResolverV8 for example. | 49 // resolution. See ProxyResolverV8 for example. |
| 50 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, | 50 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // 1. WPAD auto-detection | 124 // 1. WPAD auto-detection |
| 125 // 2. PAC URL | 125 // 2. PAC URL |
| 126 // 3. named proxy | 126 // 3. named proxy |
| 127 // | 127 // |
| 128 // Profiling information for the request is saved to |net_log| if non-NULL. | 128 // Profiling information for the request is saved to |net_log| if non-NULL. |
| 129 int ResolveProxy(const GURL& url, | 129 int ResolveProxy(const GURL& url, |
| 130 int load_flags, | 130 int load_flags, |
| 131 ProxyInfo* results, | 131 ProxyInfo* results, |
| 132 const CompletionCallback& callback, | 132 const CompletionCallback& callback, |
| 133 PacRequest** pac_request, | 133 PacRequest** pac_request, |
| 134 NetworkDelegate* network_delegate, | 134 ProxyDelegate* proxy_delegate, |
| 135 const BoundNetLog& net_log); | 135 const BoundNetLog& net_log); |
| 136 | 136 |
| 137 // Returns true if the proxy information could be determined without spawning | 137 // Returns true if the proxy information could be determined without spawning |
| 138 // an asynchronous task. Otherwise, |result| is unmodified. | 138 // an asynchronous task. Otherwise, |result| is unmodified. |
| 139 bool TryResolveProxySynchronously(const GURL& raw_url, | 139 bool TryResolveProxySynchronously(const GURL& raw_url, |
| 140 int load_flags, | 140 int load_flags, |
| 141 ProxyInfo* result, | 141 ProxyInfo* result, |
| 142 NetworkDelegate* network_delegate, | 142 ProxyDelegate* proxy_delegate, |
| 143 const BoundNetLog& net_log); | 143 const BoundNetLog& net_log); |
| 144 | 144 |
| 145 // This method is called after a failure to connect or resolve a host name. | 145 // This method is called after a failure to connect or resolve a host name. |
| 146 // It gives the proxy service an opportunity to reconsider the proxy to use. | 146 // It gives the proxy service an opportunity to reconsider the proxy to use. |
| 147 // The |results| parameter contains the results returned by an earlier call | 147 // The |results| parameter contains the results returned by an earlier call |
| 148 // to ResolveProxy. The |net_error| parameter contains the network error | 148 // to ResolveProxy. The |net_error| parameter contains the network error |
| 149 // code associated with the failure. See "net/base/net_error_list.h" for a | 149 // code associated with the failure. See "net/base/net_error_list.h" for a |
| 150 // list of possible values. The semantics of this call are otherwise | 150 // list of possible values. The semantics of this call are otherwise |
| 151 // similar to ResolveProxy. | 151 // similar to ResolveProxy. |
| 152 // | 152 // |
| 153 // NULL can be passed for |pac_request| if the caller will not need to | 153 // NULL can be passed for |pac_request| if the caller will not need to |
| 154 // cancel the request. | 154 // cancel the request. |
| 155 // | 155 // |
| 156 // Returns ERR_FAILED if there is not another proxy config to try. | 156 // Returns ERR_FAILED if there is not another proxy config to try. |
| 157 // | 157 // |
| 158 // Profiling information for the request is saved to |net_log| if non-NULL. | 158 // Profiling information for the request is saved to |net_log| if non-NULL. |
| 159 int ReconsiderProxyAfterError(const GURL& url, | 159 int ReconsiderProxyAfterError(const GURL& url, |
| 160 int load_flags, | 160 int load_flags, |
| 161 int net_error, | 161 int net_error, |
| 162 ProxyInfo* results, | 162 ProxyInfo* results, |
| 163 const CompletionCallback& callback, | 163 const CompletionCallback& callback, |
| 164 PacRequest** pac_request, | 164 PacRequest** pac_request, |
| 165 NetworkDelegate* network_delegate, | 165 ProxyDelegate* proxy_delegate, |
| 166 const BoundNetLog& net_log); | 166 const BoundNetLog& net_log); |
| 167 | 167 |
| 168 // Explicitly trigger proxy fallback for the given |results| by updating our | 168 // Explicitly trigger proxy fallback for the given |results| by updating our |
| 169 // list of bad proxies to include the first entry of |results|, and, | 169 // list of bad proxies to include the first entry of |results|, and, |
| 170 // additional bad proxies (can be none). Will retry after |retry_delay| if | 170 // additional bad proxies (can be none). Will retry after |retry_delay| if |
| 171 // positive, and will use the default proxy retry duration otherwise. Proxies | 171 // positive, and will use the default proxy retry duration otherwise. Proxies |
| 172 // marked as bad will not be retried until |retry_delay| has passed. Returns | 172 // marked as bad will not be retried until |retry_delay| has passed. Returns |
| 173 // true if there will be at least one proxy remaining in the list after | 173 // true if there will be at least one proxy remaining in the list after |
| 174 // fallback and false otherwise. This method should be used to add proxies to | 174 // fallback and false otherwise. This method should be used to add proxies to |
| 175 // the bad proxy list only for reasons other than a network error. If a proxy | 175 // the bad proxy list only for reasons other than a network error. If a proxy |
| 176 // needs to be added to the bad proxy list because a network error was | 176 // needs to be added to the bad proxy list because a network error was |
| 177 // encountered when trying to connect to it, use |ReconsiderProxyAfterError|. | 177 // encountered when trying to connect to it, use |ReconsiderProxyAfterError|. |
| 178 bool MarkProxiesAsBadUntil( | 178 bool MarkProxiesAsBadUntil( |
| 179 const ProxyInfo& results, | 179 const ProxyInfo& results, |
| 180 base::TimeDelta retry_delay, | 180 base::TimeDelta retry_delay, |
| 181 const std::vector<ProxyServer>& additional_bad_proxies, | 181 const std::vector<ProxyServer>& additional_bad_proxies, |
| 182 const BoundNetLog& net_log); | 182 const BoundNetLog& net_log); |
| 183 | 183 |
| 184 // Called to report that the last proxy connection succeeded. If |proxy_info| | 184 // Called to report that the last proxy connection succeeded. If |proxy_info| |
| 185 // has a non empty proxy_retry_info map, the proxies that have been tried (and | 185 // has a non empty proxy_retry_info map, the proxies that have been tried (and |
| 186 // failed) for this request will be marked as bad. |network_delegate| will | 186 // failed) for this request will be marked as bad. |proxy_delegate| will |
| 187 // be notified of any proxy fallbacks. | 187 // be notified of any proxy fallbacks. |
| 188 void ReportSuccess(const ProxyInfo& proxy_info, | 188 void ReportSuccess(const ProxyInfo& proxy_info, |
| 189 NetworkDelegate* network_delegate); | 189 ProxyDelegate* proxy_delegate); |
| 190 | 190 |
| 191 // Call this method with a non-null |pac_request| to cancel the PAC request. | 191 // Call this method with a non-null |pac_request| to cancel the PAC request. |
| 192 void CancelPacRequest(PacRequest* pac_request); | 192 void CancelPacRequest(PacRequest* pac_request); |
| 193 | 193 |
| 194 // Returns the LoadState for this |pac_request| which must be non-NULL. | 194 // Returns the LoadState for this |pac_request| which must be non-NULL. |
| 195 LoadState GetLoadState(const PacRequest* pac_request) const; | 195 LoadState GetLoadState(const PacRequest* pac_request) const; |
| 196 | 196 |
| 197 // Sets the ProxyScriptFetcher and DhcpProxyScriptFetcher dependencies. This | 197 // Sets the ProxyScriptFetcher and DhcpProxyScriptFetcher dependencies. This |
| 198 // is needed if the ProxyResolver is of type ProxyResolverWithoutFetch. | 198 // is needed if the ProxyResolver is of type ProxyResolverWithoutFetch. |
| 199 // ProxyService takes ownership of proxy_script_fetcher. | 199 // ProxyService takes ownership of proxy_script_fetcher. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 // Callback for when the proxy resolver has been initialized with a | 320 // Callback for when the proxy resolver has been initialized with a |
| 321 // PAC script. | 321 // PAC script. |
| 322 void OnInitProxyResolverComplete(int result); | 322 void OnInitProxyResolverComplete(int result); |
| 323 | 323 |
| 324 // Returns ERR_IO_PENDING if the request cannot be completed synchronously. | 324 // Returns ERR_IO_PENDING if the request cannot be completed synchronously. |
| 325 // Otherwise it fills |result| with the proxy information for |url|. | 325 // Otherwise it fills |result| with the proxy information for |url|. |
| 326 // Completing synchronously means we don't need to query ProxyResolver. | 326 // Completing synchronously means we don't need to query ProxyResolver. |
| 327 int TryToCompleteSynchronously(const GURL& url, | 327 int TryToCompleteSynchronously(const GURL& url, |
| 328 int load_flags, | 328 int load_flags, |
| 329 NetworkDelegate* network_delegate, | 329 ProxyDelegate* proxy_delegate, |
| 330 ProxyInfo* result); | 330 ProxyInfo* result); |
| 331 | 331 |
| 332 // Identical to ResolveProxy, except that |callback| is permitted to be null. | 332 // Identical to ResolveProxy, except that |callback| is permitted to be null. |
| 333 // if |callback.is_null()|, this function becomes a thin wrapper around | 333 // if |callback.is_null()|, this function becomes a thin wrapper around |
| 334 // |TryToCompleteSynchronously|. | 334 // |TryToCompleteSynchronously|. |
| 335 int ResolveProxyHelper(const GURL& url, | 335 int ResolveProxyHelper(const GURL& url, |
| 336 int load_flags, | 336 int load_flags, |
| 337 ProxyInfo* results, | 337 ProxyInfo* results, |
| 338 const CompletionCallback& callback, | 338 const CompletionCallback& callback, |
| 339 PacRequest** pac_request, | 339 PacRequest** pac_request, |
| 340 NetworkDelegate* network_delegate, | 340 ProxyDelegate* proxy_delegate, |
| 341 const BoundNetLog& net_log); | 341 const BoundNetLog& net_log); |
| 342 | 342 |
| 343 // Cancels all of the requests sent to the ProxyResolver. These will be | 343 // Cancels all of the requests sent to the ProxyResolver. These will be |
| 344 // restarted when calling SetReady(). | 344 // restarted when calling SetReady(). |
| 345 void SuspendAllPendingRequests(); | 345 void SuspendAllPendingRequests(); |
| 346 | 346 |
| 347 // Advances the current state to |STATE_READY|, and resumes any pending | 347 // Advances the current state to |STATE_READY|, and resumes any pending |
| 348 // requests which had been stalled waiting for initialization to complete. | 348 // requests which had been stalled waiting for initialization to complete. |
| 349 void SetReady(); | 349 void SetReady(); |
| 350 | 350 |
| 351 // Returns true if |pending_requests_| contains |req|. | 351 // Returns true if |pending_requests_| contains |req|. |
| 352 bool ContainsPendingRequest(PacRequest* req); | 352 bool ContainsPendingRequest(PacRequest* req); |
| 353 | 353 |
| 354 // Removes |req| from the list of pending requests. | 354 // Removes |req| from the list of pending requests. |
| 355 void RemovePendingRequest(PacRequest* req); | 355 void RemovePendingRequest(PacRequest* req); |
| 356 | 356 |
| 357 // Called when proxy resolution has completed (either synchronously or | 357 // Called when proxy resolution has completed (either synchronously or |
| 358 // asynchronously). Handles logging the result, and cleaning out | 358 // asynchronously). Handles logging the result, and cleaning out |
| 359 // bad entries from the results list. | 359 // bad entries from the results list. |
| 360 int DidFinishResolvingProxy(const GURL& url, | 360 int DidFinishResolvingProxy(const GURL& url, |
| 361 int load_flags, | 361 int load_flags, |
| 362 NetworkDelegate* network_delegate, | 362 ProxyDelegate* proxy_delegate, |
| 363 ProxyInfo* result, | 363 ProxyInfo* result, |
| 364 int result_code, | 364 int result_code, |
| 365 const BoundNetLog& net_log, | 365 const BoundNetLog& net_log, |
| 366 base::TimeTicks start_time, | 366 base::TimeTicks start_time, |
| 367 bool script_executed); | 367 bool script_executed); |
| 368 | 368 |
| 369 // Start initialization using |fetched_config_|. | 369 // Start initialization using |fetched_config_|. |
| 370 void InitializeUsingLastFetchedConfig(); | 370 void InitializeUsingLastFetchedConfig(); |
| 371 | 371 |
| 372 // Start the initialization skipping past the "decision" phase. | 372 // Start the initialization skipping past the "decision" phase. |
| (...skipping 77 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 |