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 <memory> | 10 #include <memory> |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // We use the three possible proxy access types in the following order, | 145 // We use the three possible proxy access types in the following order, |
146 // doing fallback if one doesn't work. See "pac_script_decider.h" | 146 // doing fallback if one doesn't work. See "pac_script_decider.h" |
147 // for the specifics. | 147 // for the specifics. |
148 // 1. WPAD auto-detection | 148 // 1. WPAD auto-detection |
149 // 2. PAC URL | 149 // 2. PAC URL |
150 // 3. named proxy | 150 // 3. named proxy |
151 // | 151 // |
152 // Profiling information for the request is saved to |net_log| if non-NULL. | 152 // Profiling information for the request is saved to |net_log| if non-NULL. |
153 int ResolveProxy(const GURL& url, | 153 int ResolveProxy(const GURL& url, |
154 const std::string& method, | 154 const std::string& method, |
155 int load_flags, | |
156 ProxyInfo* results, | 155 ProxyInfo* results, |
157 const CompletionCallback& callback, | 156 const CompletionCallback& callback, |
158 PacRequest** pac_request, | 157 PacRequest** pac_request, |
159 ProxyDelegate* proxy_delegate, | 158 ProxyDelegate* proxy_delegate, |
160 const BoundNetLog& net_log); | 159 const BoundNetLog& net_log); |
161 | 160 |
162 // Returns true if the proxy information could be determined without spawning | 161 // Returns true if the proxy information could be determined without spawning |
163 // an asynchronous task. Otherwise, |result| is unmodified. | 162 // an asynchronous task. Otherwise, |result| is unmodified. |
164 bool TryResolveProxySynchronously(const GURL& raw_url, | 163 bool TryResolveProxySynchronously(const GURL& raw_url, |
165 const std::string& method, | 164 const std::string& method, |
166 int load_flags, | |
167 ProxyInfo* result, | 165 ProxyInfo* result, |
168 ProxyDelegate* proxy_delegate, | 166 ProxyDelegate* proxy_delegate, |
169 const BoundNetLog& net_log); | 167 const BoundNetLog& net_log); |
170 | 168 |
171 // This method is called after a failure to connect or resolve a host name. | 169 // This method is called after a failure to connect or resolve a host name. |
172 // It gives the proxy service an opportunity to reconsider the proxy to use. | 170 // It gives the proxy service an opportunity to reconsider the proxy to use. |
173 // The |results| parameter contains the results returned by an earlier call | 171 // The |results| parameter contains the results returned by an earlier call |
174 // to ResolveProxy. The |net_error| parameter contains the network error | 172 // to ResolveProxy. The |net_error| parameter contains the network error |
175 // code associated with the failure. See "net/base/net_error_list.h" for a | 173 // code associated with the failure. See "net/base/net_error_list.h" for a |
176 // list of possible values. The semantics of this call are otherwise | 174 // list of possible values. The semantics of this call are otherwise |
177 // similar to ResolveProxy. | 175 // similar to ResolveProxy. |
178 // | 176 // |
179 // NULL can be passed for |pac_request| if the caller will not need to | 177 // NULL can be passed for |pac_request| if the caller will not need to |
180 // cancel the request. | 178 // cancel the request. |
181 // | 179 // |
182 // Returns ERR_FAILED if there is not another proxy config to try. | 180 // Returns ERR_FAILED if there is not another proxy config to try. |
183 // | 181 // |
184 // Profiling information for the request is saved to |net_log| if non-NULL. | 182 // Profiling information for the request is saved to |net_log| if non-NULL. |
185 int ReconsiderProxyAfterError(const GURL& url, | 183 int ReconsiderProxyAfterError(const GURL& url, |
186 const std::string& method, | 184 const std::string& method, |
187 int load_flags, | |
188 int net_error, | 185 int net_error, |
189 ProxyInfo* results, | 186 ProxyInfo* results, |
190 const CompletionCallback& callback, | 187 const CompletionCallback& callback, |
191 PacRequest** pac_request, | 188 PacRequest** pac_request, |
192 ProxyDelegate* proxy_delegate, | 189 ProxyDelegate* proxy_delegate, |
193 const BoundNetLog& net_log); | 190 const BoundNetLog& net_log); |
194 | 191 |
195 // Explicitly trigger proxy fallback for the given |results| by updating our | 192 // Explicitly trigger proxy fallback for the given |results| by updating our |
196 // list of bad proxies to include the first entry of |results|, and, | 193 // list of bad proxies to include the first entry of |results|, and, |
197 // additional bad proxies (can be none). Will retry after |retry_delay| if | 194 // additional bad proxies (can be none). Will retry after |retry_delay| if |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 void ApplyProxyConfigIfAvailable(); | 346 void ApplyProxyConfigIfAvailable(); |
350 | 347 |
351 // Callback for when the proxy resolver has been initialized with a | 348 // Callback for when the proxy resolver has been initialized with a |
352 // PAC script. | 349 // PAC script. |
353 void OnInitProxyResolverComplete(int result); | 350 void OnInitProxyResolverComplete(int result); |
354 | 351 |
355 // Returns ERR_IO_PENDING if the request cannot be completed synchronously. | 352 // Returns ERR_IO_PENDING if the request cannot be completed synchronously. |
356 // Otherwise it fills |result| with the proxy information for |url|. | 353 // Otherwise it fills |result| with the proxy information for |url|. |
357 // Completing synchronously means we don't need to query ProxyResolver. | 354 // Completing synchronously means we don't need to query ProxyResolver. |
358 int TryToCompleteSynchronously(const GURL& url, | 355 int TryToCompleteSynchronously(const GURL& url, |
359 int load_flags, | |
360 ProxyDelegate* proxy_delegate, | 356 ProxyDelegate* proxy_delegate, |
361 ProxyInfo* result); | 357 ProxyInfo* result); |
362 | 358 |
363 // Identical to ResolveProxy, except that |callback| is permitted to be null. | 359 // Identical to ResolveProxy, except that |callback| is permitted to be null. |
364 // if |callback.is_null()|, this function becomes a thin wrapper around | 360 // if |callback.is_null()|, this function becomes a thin wrapper around |
365 // |TryToCompleteSynchronously|. | 361 // |TryToCompleteSynchronously|. |
366 int ResolveProxyHelper(const GURL& url, | 362 int ResolveProxyHelper(const GURL& url, |
367 const std::string& method, | 363 const std::string& method, |
368 int load_flags, | |
369 ProxyInfo* results, | 364 ProxyInfo* results, |
370 const CompletionCallback& callback, | 365 const CompletionCallback& callback, |
371 PacRequest** pac_request, | 366 PacRequest** pac_request, |
372 ProxyDelegate* proxy_delegate, | 367 ProxyDelegate* proxy_delegate, |
373 const BoundNetLog& net_log); | 368 const BoundNetLog& net_log); |
374 | 369 |
375 // Cancels all of the requests sent to the ProxyResolver. These will be | 370 // Cancels all of the requests sent to the ProxyResolver. These will be |
376 // restarted when calling SetReady(). | 371 // restarted when calling SetReady(). |
377 void SuspendAllPendingRequests(); | 372 void SuspendAllPendingRequests(); |
378 | 373 |
379 // Advances the current state to |STATE_READY|, and resumes any pending | 374 // Advances the current state to |STATE_READY|, and resumes any pending |
380 // requests which had been stalled waiting for initialization to complete. | 375 // requests which had been stalled waiting for initialization to complete. |
381 void SetReady(); | 376 void SetReady(); |
382 | 377 |
383 // Returns true if |pending_requests_| contains |req|. | 378 // Returns true if |pending_requests_| contains |req|. |
384 bool ContainsPendingRequest(PacRequest* req); | 379 bool ContainsPendingRequest(PacRequest* req); |
385 | 380 |
386 // Removes |req| from the list of pending requests. | 381 // Removes |req| from the list of pending requests. |
387 void RemovePendingRequest(PacRequest* req); | 382 void RemovePendingRequest(PacRequest* req); |
388 | 383 |
389 // Called when proxy resolution has completed (either synchronously or | 384 // Called when proxy resolution has completed (either synchronously or |
390 // asynchronously). Handles logging the result, and cleaning out | 385 // asynchronously). Handles logging the result, and cleaning out |
391 // bad entries from the results list. | 386 // bad entries from the results list. |
392 int DidFinishResolvingProxy(const GURL& url, | 387 int DidFinishResolvingProxy(const GURL& url, |
393 const std::string& method, | 388 const std::string& method, |
394 int load_flags, | |
395 ProxyDelegate* proxy_delegate, | 389 ProxyDelegate* proxy_delegate, |
396 ProxyInfo* result, | 390 ProxyInfo* result, |
397 int result_code, | 391 int result_code, |
398 const BoundNetLog& net_log, | 392 const BoundNetLog& net_log, |
399 base::TimeTicks start_time, | 393 base::TimeTicks start_time, |
400 bool script_executed); | 394 bool script_executed); |
401 | 395 |
402 // Start initialization using |fetched_config_|. | 396 // Start initialization using |fetched_config_|. |
403 void InitializeUsingLastFetchedConfig(); | 397 void InitializeUsingLastFetchedConfig(); |
404 | 398 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 480 |
487 // The method to use for sanitizing URLs seen by the proxy resolver. | 481 // The method to use for sanitizing URLs seen by the proxy resolver. |
488 SanitizeUrlPolicy sanitize_url_policy_; | 482 SanitizeUrlPolicy sanitize_url_policy_; |
489 | 483 |
490 DISALLOW_COPY_AND_ASSIGN(ProxyService); | 484 DISALLOW_COPY_AND_ASSIGN(ProxyService); |
491 }; | 485 }; |
492 | 486 |
493 } // namespace net | 487 } // namespace net |
494 | 488 |
495 #endif // NET_PROXY_PROXY_SERVICE_H_ | 489 #endif // NET_PROXY_PROXY_SERVICE_H_ |
OLD | NEW |