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