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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ProxyInfo* results, | 155 ProxyInfo* results, |
156 const CompletionCallback& callback, | 156 const CompletionCallback& callback, |
157 PacRequest** pac_request, | 157 PacRequest** pac_request, |
158 ProxyDelegate* proxy_delegate, | 158 ProxyDelegate* proxy_delegate, |
159 const BoundNetLog& net_log); | 159 const NetLogWithSource& net_log); |
160 | 160 |
161 // Returns true if the proxy information could be determined without spawning | 161 // Returns true if the proxy information could be determined without spawning |
162 // an asynchronous task. Otherwise, |result| is unmodified. | 162 // an asynchronous task. Otherwise, |result| is unmodified. |
163 bool TryResolveProxySynchronously(const GURL& raw_url, | 163 bool TryResolveProxySynchronously(const GURL& raw_url, |
164 const std::string& method, | 164 const std::string& method, |
165 ProxyInfo* result, | 165 ProxyInfo* result, |
166 ProxyDelegate* proxy_delegate, | 166 ProxyDelegate* proxy_delegate, |
167 const BoundNetLog& net_log); | 167 const NetLogWithSource& net_log); |
168 | 168 |
169 // 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. |
170 // 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. |
171 // The |results| parameter contains the results returned by an earlier call | 171 // The |results| parameter contains the results returned by an earlier call |
172 // to ResolveProxy. The |net_error| parameter contains the network error | 172 // to ResolveProxy. The |net_error| parameter contains the network error |
173 // 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 |
174 // list of possible values. The semantics of this call are otherwise | 174 // list of possible values. The semantics of this call are otherwise |
175 // similar to ResolveProxy. | 175 // similar to ResolveProxy. |
176 // | 176 // |
177 // 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 |
178 // cancel the request. | 178 // cancel the request. |
179 // | 179 // |
180 // 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. |
181 // | 181 // |
182 // 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. |
183 int ReconsiderProxyAfterError(const GURL& url, | 183 int ReconsiderProxyAfterError(const GURL& url, |
184 const std::string& method, | 184 const std::string& method, |
185 int net_error, | 185 int net_error, |
186 ProxyInfo* results, | 186 ProxyInfo* results, |
187 const CompletionCallback& callback, | 187 const CompletionCallback& callback, |
188 PacRequest** pac_request, | 188 PacRequest** pac_request, |
189 ProxyDelegate* proxy_delegate, | 189 ProxyDelegate* proxy_delegate, |
190 const BoundNetLog& net_log); | 190 const NetLogWithSource& net_log); |
191 | 191 |
192 // Explicitly trigger proxy fallback for the given |results| by updating our | 192 // Explicitly trigger proxy fallback for the given |results| by updating our |
193 // 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, |
194 // 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 |
195 // positive, and will use the default proxy retry duration otherwise. Proxies | 195 // positive, and will use the default proxy retry duration otherwise. Proxies |
196 // marked as bad will not be retried until |retry_delay| has passed. Returns | 196 // marked as bad will not be retried until |retry_delay| has passed. Returns |
197 // true if there will be at least one proxy remaining in the list after | 197 // true if there will be at least one proxy remaining in the list after |
198 // fallback and false otherwise. This method should be used to add proxies to | 198 // fallback and false otherwise. This method should be used to add proxies to |
199 // the bad proxy list only for reasons other than a network error. If a proxy | 199 // the bad proxy list only for reasons other than a network error. If a proxy |
200 // needs to be added to the bad proxy list because a network error was | 200 // needs to be added to the bad proxy list because a network error was |
201 // encountered when trying to connect to it, use |ReconsiderProxyAfterError|. | 201 // encountered when trying to connect to it, use |ReconsiderProxyAfterError|. |
202 bool MarkProxiesAsBadUntil( | 202 bool MarkProxiesAsBadUntil( |
203 const ProxyInfo& results, | 203 const ProxyInfo& results, |
204 base::TimeDelta retry_delay, | 204 base::TimeDelta retry_delay, |
205 const std::vector<ProxyServer>& additional_bad_proxies, | 205 const std::vector<ProxyServer>& additional_bad_proxies, |
206 const BoundNetLog& net_log); | 206 const NetLogWithSource& net_log); |
207 | 207 |
208 // Called to report that the last proxy connection succeeded. If |proxy_info| | 208 // Called to report that the last proxy connection succeeded. If |proxy_info| |
209 // has a non empty proxy_retry_info map, the proxies that have been tried (and | 209 // has a non empty proxy_retry_info map, the proxies that have been tried (and |
210 // failed) for this request will be marked as bad. |proxy_delegate| will | 210 // failed) for this request will be marked as bad. |proxy_delegate| will |
211 // be notified of any proxy fallbacks. | 211 // be notified of any proxy fallbacks. |
212 void ReportSuccess(const ProxyInfo& proxy_info, | 212 void ReportSuccess(const ProxyInfo& proxy_info, |
213 ProxyDelegate* proxy_delegate); | 213 ProxyDelegate* proxy_delegate); |
214 | 214 |
215 // Call this method with a non-null |pac_request| to cancel the PAC request. | 215 // Call this method with a non-null |pac_request| to cancel the PAC request. |
216 void CancelPacRequest(PacRequest* pac_request); | 216 void CancelPacRequest(PacRequest* pac_request); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 358 |
359 // Identical to ResolveProxy, except that |callback| is permitted to be null. | 359 // Identical to ResolveProxy, except that |callback| is permitted to be null. |
360 // if |callback.is_null()|, this function becomes a thin wrapper around | 360 // if |callback.is_null()|, this function becomes a thin wrapper around |
361 // |TryToCompleteSynchronously|. | 361 // |TryToCompleteSynchronously|. |
362 int ResolveProxyHelper(const GURL& url, | 362 int ResolveProxyHelper(const GURL& url, |
363 const std::string& method, | 363 const std::string& method, |
364 ProxyInfo* results, | 364 ProxyInfo* results, |
365 const CompletionCallback& callback, | 365 const CompletionCallback& callback, |
366 PacRequest** pac_request, | 366 PacRequest** pac_request, |
367 ProxyDelegate* proxy_delegate, | 367 ProxyDelegate* proxy_delegate, |
368 const BoundNetLog& net_log); | 368 const NetLogWithSource& net_log); |
369 | 369 |
370 // 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 |
371 // restarted when calling SetReady(). | 371 // restarted when calling SetReady(). |
372 void SuspendAllPendingRequests(); | 372 void SuspendAllPendingRequests(); |
373 | 373 |
374 // Advances the current state to |STATE_READY|, and resumes any pending | 374 // Advances the current state to |STATE_READY|, and resumes any pending |
375 // requests which had been stalled waiting for initialization to complete. | 375 // requests which had been stalled waiting for initialization to complete. |
376 void SetReady(); | 376 void SetReady(); |
377 | 377 |
378 // Returns true if |pending_requests_| contains |req|. | 378 // Returns true if |pending_requests_| contains |req|. |
379 bool ContainsPendingRequest(PacRequest* req); | 379 bool ContainsPendingRequest(PacRequest* req); |
380 | 380 |
381 // Removes |req| from the list of pending requests. | 381 // Removes |req| from the list of pending requests. |
382 void RemovePendingRequest(PacRequest* req); | 382 void RemovePendingRequest(PacRequest* req); |
383 | 383 |
384 // Called when proxy resolution has completed (either synchronously or | 384 // Called when proxy resolution has completed (either synchronously or |
385 // asynchronously). Handles logging the result, and cleaning out | 385 // asynchronously). Handles logging the result, and cleaning out |
386 // bad entries from the results list. | 386 // bad entries from the results list. |
387 int DidFinishResolvingProxy(const GURL& url, | 387 int DidFinishResolvingProxy(const GURL& url, |
388 const std::string& method, | 388 const std::string& method, |
389 ProxyDelegate* proxy_delegate, | 389 ProxyDelegate* proxy_delegate, |
390 ProxyInfo* result, | 390 ProxyInfo* result, |
391 int result_code, | 391 int result_code, |
392 const BoundNetLog& net_log, | 392 const NetLogWithSource& net_log, |
393 base::TimeTicks start_time, | 393 base::TimeTicks start_time, |
394 bool script_executed); | 394 bool script_executed); |
395 | 395 |
396 // Start initialization using |fetched_config_|. | 396 // Start initialization using |fetched_config_|. |
397 void InitializeUsingLastFetchedConfig(); | 397 void InitializeUsingLastFetchedConfig(); |
398 | 398 |
399 // Start the initialization skipping past the "decision" phase. | 399 // Start the initialization skipping past the "decision" phase. |
400 void InitializeUsingDecidedConfig( | 400 void InitializeUsingDecidedConfig( |
401 int decider_result, | 401 int decider_result, |
402 ProxyResolverScriptData* script_data, | 402 ProxyResolverScriptData* script_data, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 480 |
481 // 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. |
482 SanitizeUrlPolicy sanitize_url_policy_; | 482 SanitizeUrlPolicy sanitize_url_policy_; |
483 | 483 |
484 DISALLOW_COPY_AND_ASSIGN(ProxyService); | 484 DISALLOW_COPY_AND_ASSIGN(ProxyService); |
485 }; | 485 }; |
486 | 486 |
487 } // namespace net | 487 } // namespace net |
488 | 488 |
489 #endif // NET_PROXY_PROXY_SERVICE_H_ | 489 #endif // NET_PROXY_PROXY_SERVICE_H_ |
OLD | NEW |