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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 ProxyService(scoped_ptr<ProxyConfigService> config_service, | 100 ProxyService(scoped_ptr<ProxyConfigService> config_service, |
101 scoped_ptr<ProxyResolverFactory> resolver_factory, | 101 scoped_ptr<ProxyResolverFactory> resolver_factory, |
102 NetLog* net_log); | 102 NetLog* net_log); |
103 | 103 |
104 ~ProxyService() override; | 104 ~ProxyService() override; |
105 | 105 |
106 // Used internally to handle PAC queries. | 106 // Used internally to handle PAC queries. |
107 // TODO(eroman): consider naming this simply "Request". | 107 // TODO(eroman): consider naming this simply "Request". |
108 class PacRequest; | 108 class PacRequest; |
109 | 109 |
| 110 // Determines the appropriate proxy for |url| for a |method| request and |
| 111 // stores the result in |results|. If |method| is empty, the caller can expect |
| 112 // method independent resolution. |
| 113 // |
110 // Returns ERR_IO_PENDING if the proxy information could not be provided | 114 // Returns ERR_IO_PENDING if the proxy information could not be provided |
111 // synchronously, to indicate that the result will be available when the | 115 // synchronously, to indicate that the result will be available when the |
112 // callback is run. The callback is run on the thread that calls | 116 // callback is run. The callback is run on the thread that calls |
113 // ResolveProxy. | 117 // ResolveProxy. |
114 // | 118 // |
115 // The caller is responsible for ensuring that |results| and |callback| | 119 // The caller is responsible for ensuring that |results| and |callback| |
116 // remain valid until the callback is run or until |pac_request| is cancelled | 120 // remain valid until the callback is run or until |pac_request| is cancelled |
117 // via CancelPacRequest. |pac_request| is only valid while the completion | 121 // via CancelPacRequest. |pac_request| is only valid while the completion |
118 // callback is still pending. NULL can be passed for |pac_request| if | 122 // callback is still pending. NULL can be passed for |pac_request| if |
119 // the caller will not need to cancel the request. | 123 // the caller will not need to cancel the request. |
120 // | 124 // |
121 // We use the three possible proxy access types in the following order, | 125 // We use the three possible proxy access types in the following order, |
122 // doing fallback if one doesn't work. See "pac_script_decider.h" | 126 // doing fallback if one doesn't work. See "pac_script_decider.h" |
123 // for the specifics. | 127 // for the specifics. |
124 // 1. WPAD auto-detection | 128 // 1. WPAD auto-detection |
125 // 2. PAC URL | 129 // 2. PAC URL |
126 // 3. named proxy | 130 // 3. named proxy |
127 // | 131 // |
128 // Profiling information for the request is saved to |net_log| if non-NULL. | 132 // Profiling information for the request is saved to |net_log| if non-NULL. |
129 int ResolveProxy(const GURL& url, | 133 int ResolveProxy(const GURL& url, |
| 134 const std::string& method, |
130 int load_flags, | 135 int load_flags, |
131 ProxyInfo* results, | 136 ProxyInfo* results, |
132 const CompletionCallback& callback, | 137 const CompletionCallback& callback, |
133 PacRequest** pac_request, | 138 PacRequest** pac_request, |
134 ProxyDelegate* proxy_delegate, | 139 ProxyDelegate* proxy_delegate, |
135 const BoundNetLog& net_log); | 140 const BoundNetLog& net_log); |
136 | 141 |
137 // Returns true if the proxy information could be determined without spawning | 142 // Returns true if the proxy information could be determined without spawning |
138 // an asynchronous task. Otherwise, |result| is unmodified. | 143 // an asynchronous task. Otherwise, |result| is unmodified. |
139 bool TryResolveProxySynchronously(const GURL& raw_url, | 144 bool TryResolveProxySynchronously(const GURL& raw_url, |
| 145 const std::string& method, |
140 int load_flags, | 146 int load_flags, |
141 ProxyInfo* result, | 147 ProxyInfo* result, |
142 ProxyDelegate* proxy_delegate, | 148 ProxyDelegate* proxy_delegate, |
143 const BoundNetLog& net_log); | 149 const BoundNetLog& net_log); |
144 | 150 |
145 // This method is called after a failure to connect or resolve a host name. | 151 // 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. | 152 // 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 | 153 // The |results| parameter contains the results returned by an earlier call |
148 // to ResolveProxy. The |net_error| parameter contains the network error | 154 // 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 | 155 // 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 | 156 // list of possible values. The semantics of this call are otherwise |
151 // similar to ResolveProxy. | 157 // similar to ResolveProxy. |
152 // | 158 // |
153 // NULL can be passed for |pac_request| if the caller will not need to | 159 // NULL can be passed for |pac_request| if the caller will not need to |
154 // cancel the request. | 160 // cancel the request. |
155 // | 161 // |
156 // Returns ERR_FAILED if there is not another proxy config to try. | 162 // Returns ERR_FAILED if there is not another proxy config to try. |
157 // | 163 // |
158 // Profiling information for the request is saved to |net_log| if non-NULL. | 164 // Profiling information for the request is saved to |net_log| if non-NULL. |
159 int ReconsiderProxyAfterError(const GURL& url, | 165 int ReconsiderProxyAfterError(const GURL& url, |
| 166 const std::string& method, |
160 int load_flags, | 167 int load_flags, |
161 int net_error, | 168 int net_error, |
162 ProxyInfo* results, | 169 ProxyInfo* results, |
163 const CompletionCallback& callback, | 170 const CompletionCallback& callback, |
164 PacRequest** pac_request, | 171 PacRequest** pac_request, |
165 ProxyDelegate* proxy_delegate, | 172 ProxyDelegate* proxy_delegate, |
166 const BoundNetLog& net_log); | 173 const BoundNetLog& net_log); |
167 | 174 |
168 // Explicitly trigger proxy fallback for the given |results| by updating our | 175 // Explicitly trigger proxy fallback for the given |results| by updating our |
169 // list of bad proxies to include the first entry of |results|, and, | 176 // list of bad proxies to include the first entry of |results|, and, |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 // Completing synchronously means we don't need to query ProxyResolver. | 333 // Completing synchronously means we don't need to query ProxyResolver. |
327 int TryToCompleteSynchronously(const GURL& url, | 334 int TryToCompleteSynchronously(const GURL& url, |
328 int load_flags, | 335 int load_flags, |
329 ProxyDelegate* proxy_delegate, | 336 ProxyDelegate* proxy_delegate, |
330 ProxyInfo* result); | 337 ProxyInfo* result); |
331 | 338 |
332 // Identical to ResolveProxy, except that |callback| is permitted to be null. | 339 // Identical to ResolveProxy, except that |callback| is permitted to be null. |
333 // if |callback.is_null()|, this function becomes a thin wrapper around | 340 // if |callback.is_null()|, this function becomes a thin wrapper around |
334 // |TryToCompleteSynchronously|. | 341 // |TryToCompleteSynchronously|. |
335 int ResolveProxyHelper(const GURL& url, | 342 int ResolveProxyHelper(const GURL& url, |
| 343 const std::string& method, |
336 int load_flags, | 344 int load_flags, |
337 ProxyInfo* results, | 345 ProxyInfo* results, |
338 const CompletionCallback& callback, | 346 const CompletionCallback& callback, |
339 PacRequest** pac_request, | 347 PacRequest** pac_request, |
340 ProxyDelegate* proxy_delegate, | 348 ProxyDelegate* proxy_delegate, |
341 const BoundNetLog& net_log); | 349 const BoundNetLog& net_log); |
342 | 350 |
343 // Cancels all of the requests sent to the ProxyResolver. These will be | 351 // Cancels all of the requests sent to the ProxyResolver. These will be |
344 // restarted when calling SetReady(). | 352 // restarted when calling SetReady(). |
345 void SuspendAllPendingRequests(); | 353 void SuspendAllPendingRequests(); |
346 | 354 |
347 // Advances the current state to |STATE_READY|, and resumes any pending | 355 // Advances the current state to |STATE_READY|, and resumes any pending |
348 // requests which had been stalled waiting for initialization to complete. | 356 // requests which had been stalled waiting for initialization to complete. |
349 void SetReady(); | 357 void SetReady(); |
350 | 358 |
351 // Returns true if |pending_requests_| contains |req|. | 359 // Returns true if |pending_requests_| contains |req|. |
352 bool ContainsPendingRequest(PacRequest* req); | 360 bool ContainsPendingRequest(PacRequest* req); |
353 | 361 |
354 // Removes |req| from the list of pending requests. | 362 // Removes |req| from the list of pending requests. |
355 void RemovePendingRequest(PacRequest* req); | 363 void RemovePendingRequest(PacRequest* req); |
356 | 364 |
357 // Called when proxy resolution has completed (either synchronously or | 365 // Called when proxy resolution has completed (either synchronously or |
358 // asynchronously). Handles logging the result, and cleaning out | 366 // asynchronously). Handles logging the result, and cleaning out |
359 // bad entries from the results list. | 367 // bad entries from the results list. |
360 int DidFinishResolvingProxy(const GURL& url, | 368 int DidFinishResolvingProxy(const GURL& url, |
| 369 const std::string& method, |
361 int load_flags, | 370 int load_flags, |
362 ProxyDelegate* proxy_delegate, | 371 ProxyDelegate* proxy_delegate, |
363 ProxyInfo* result, | 372 ProxyInfo* result, |
364 int result_code, | 373 int result_code, |
365 const BoundNetLog& net_log, | 374 const BoundNetLog& net_log, |
366 base::TimeTicks start_time, | 375 base::TimeTicks start_time, |
367 bool script_executed); | 376 bool script_executed); |
368 | 377 |
369 // Start initialization using |fetched_config_|. | 378 // Start initialization using |fetched_config_|. |
370 void InitializeUsingLastFetchedConfig(); | 379 void InitializeUsingLastFetchedConfig(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 459 |
451 // Whether child ProxyScriptDeciders should use QuickCheck | 460 // Whether child ProxyScriptDeciders should use QuickCheck |
452 bool quick_check_enabled_; | 461 bool quick_check_enabled_; |
453 | 462 |
454 DISALLOW_COPY_AND_ASSIGN(ProxyService); | 463 DISALLOW_COPY_AND_ASSIGN(ProxyService); |
455 }; | 464 }; |
456 | 465 |
457 } // namespace net | 466 } // namespace net |
458 | 467 |
459 #endif // NET_PROXY_PROXY_SERVICE_H_ | 468 #endif // NET_PROXY_PROXY_SERVICE_H_ |
OLD | NEW |