| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 // TODO(eroman): remove this unused header; other callers are depending on it! | 13 // TODO(eroman): remove this unused header; other callers are depending on it! |
| 14 #include "base/thread.h" | 14 #include "base/thread.h" |
| 15 #include "base/waitable_event.h" | 15 #include "base/waitable_event.h" |
| 16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
| 17 #include "net/proxy/proxy_server.h" | 17 #include "net/proxy/proxy_server.h" |
| 18 #include "net/proxy/proxy_info.h" | 18 #include "net/proxy/proxy_info.h" |
| 19 #include "testing/gtest/include/gtest/gtest_prod.h" | 19 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 20 | 20 |
| 21 class GURL; | 21 class GURL; |
| 22 class MessageLoop; | 22 class MessageLoop; |
| 23 class URLRequestContext; | 23 class URLRequestContext; |
| 24 | 24 |
| 25 namespace net { | 25 namespace net { |
| 26 | 26 |
| 27 class InitProxyResolver; | 27 class InitProxyResolver; |
| 28 class LoadLog; |
| 28 class ProxyConfigService; | 29 class ProxyConfigService; |
| 29 class ProxyResolver; | 30 class ProxyResolver; |
| 30 class ProxyScriptFetcher; | 31 class ProxyScriptFetcher; |
| 31 | 32 |
| 32 // This class can be used to resolve the proxy server to use when loading a | 33 // This class can be used to resolve the proxy server to use when loading a |
| 33 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy | 34 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy |
| 34 // resolution. See ProxyResolverV8 for example. | 35 // resolution. See ProxyResolverV8 for example. |
| 35 class ProxyService { | 36 class ProxyService { |
| 36 public: | 37 public: |
| 37 // The instance takes ownership of |config_service| and |resolver|. | 38 // The instance takes ownership of |config_service| and |resolver|. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 56 // the caller will not need to cancel the request. | 57 // the caller will not need to cancel the request. |
| 57 // | 58 // |
| 58 // We use the three possible proxy access types in the following order, and | 59 // We use the three possible proxy access types in the following order, and |
| 59 // we only use one of them (no falling back to other access types if the | 60 // we only use one of them (no falling back to other access types if the |
| 60 // chosen one doesn't work). | 61 // chosen one doesn't work). |
| 61 // 1. named proxy | 62 // 1. named proxy |
| 62 // 2. PAC URL | 63 // 2. PAC URL |
| 63 // 3. WPAD auto-detection | 64 // 3. WPAD auto-detection |
| 64 // | 65 // |
| 65 // TODO(eroman): see http://crbug.com/9985; the outline above is too simple. | 66 // TODO(eroman): see http://crbug.com/9985; the outline above is too simple. |
| 66 int ResolveProxy(const GURL& url, | 67 // |
| 68 // Profiling information for the request is saved to |load_log| if non-NULL. |
| 69 int ResolveProxy(LoadLog* load_log, |
| 70 const GURL& url, |
| 67 ProxyInfo* results, | 71 ProxyInfo* results, |
| 68 CompletionCallback* callback, | 72 CompletionCallback* callback, |
| 69 PacRequest** pac_request); | 73 PacRequest** pac_request); |
| 70 | 74 |
| 71 // This method is called after a failure to connect or resolve a host name. | 75 // This method is called after a failure to connect or resolve a host name. |
| 72 // It gives the proxy service an opportunity to reconsider the proxy to use. | 76 // It gives the proxy service an opportunity to reconsider the proxy to use. |
| 73 // The |results| parameter contains the results returned by an earlier call | 77 // The |results| parameter contains the results returned by an earlier call |
| 74 // to ResolveProxy. The semantics of this call are otherwise similar to | 78 // to ResolveProxy. The semantics of this call are otherwise similar to |
| 75 // ResolveProxy. | 79 // ResolveProxy. |
| 76 // | 80 // |
| 77 // NULL can be passed for |pac_request| if the caller will not need to | 81 // NULL can be passed for |pac_request| if the caller will not need to |
| 78 // cancel the request. | 82 // cancel the request. |
| 79 // | 83 // |
| 80 // Returns ERR_FAILED if there is not another proxy config to try. | 84 // Returns ERR_FAILED if there is not another proxy config to try. |
| 81 // | 85 // |
| 82 int ReconsiderProxyAfterError(const GURL& url, | 86 // Profiling information for the request is saved to |load_log| if non-NULL. |
| 87 int ReconsiderProxyAfterError(LoadLog* load_log, |
| 88 const GURL& url, |
| 83 ProxyInfo* results, | 89 ProxyInfo* results, |
| 84 CompletionCallback* callback, | 90 CompletionCallback* callback, |
| 85 PacRequest** pac_request); | 91 PacRequest** pac_request); |
| 86 | 92 |
| 87 // Call this method with a non-null |pac_request| to cancel the PAC request. | 93 // Call this method with a non-null |pac_request| to cancel the PAC request. |
| 88 void CancelPacRequest(PacRequest* pac_request); | 94 void CancelPacRequest(PacRequest* pac_request); |
| 89 | 95 |
| 90 // Sets the ProxyScriptFetcher dependency. This is needed if the ProxyResolver | 96 // Sets the ProxyScriptFetcher dependency. This is needed if the ProxyResolver |
| 91 // is of type ProxyResolverWithoutFetch. ProxyService takes ownership of | 97 // is of type ProxyResolverWithoutFetch. ProxyService takes ownership of |
| 92 // |proxy_script_fetcher|. | 98 // |proxy_script_fetcher|. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 DISALLOW_COPY_AND_ASSIGN(ProxyService); | 261 DISALLOW_COPY_AND_ASSIGN(ProxyService); |
| 256 }; | 262 }; |
| 257 | 263 |
| 258 // Wrapper for invoking methods on a ProxyService synchronously. | 264 // Wrapper for invoking methods on a ProxyService synchronously. |
| 259 class SyncProxyServiceHelper | 265 class SyncProxyServiceHelper |
| 260 : public base::RefCountedThreadSafe<SyncProxyServiceHelper> { | 266 : public base::RefCountedThreadSafe<SyncProxyServiceHelper> { |
| 261 public: | 267 public: |
| 262 SyncProxyServiceHelper(MessageLoop* io_message_loop, | 268 SyncProxyServiceHelper(MessageLoop* io_message_loop, |
| 263 ProxyService* proxy_service); | 269 ProxyService* proxy_service); |
| 264 | 270 |
| 265 int ResolveProxy(const GURL& url, ProxyInfo* proxy_info); | 271 int ResolveProxy(LoadLog* load_log, const GURL& url, ProxyInfo* proxy_info); |
| 266 int ReconsiderProxyAfterError(const GURL& url, ProxyInfo* proxy_info); | 272 int ReconsiderProxyAfterError(LoadLog* load_log, |
| 273 const GURL& url, |
| 274 ProxyInfo* proxy_info); |
| 267 | 275 |
| 268 private: | 276 private: |
| 269 void StartAsyncResolve(const GURL& url); | 277 void StartAsyncResolve(LoadLog* load_log, const GURL& url); |
| 270 void StartAsyncReconsider(const GURL& url); | 278 void StartAsyncReconsider(LoadLog* load_log, const GURL& url); |
| 271 | 279 |
| 272 void OnCompletion(int result); | 280 void OnCompletion(int result); |
| 273 | 281 |
| 274 MessageLoop* io_message_loop_; | 282 MessageLoop* io_message_loop_; |
| 275 ProxyService* proxy_service_; | 283 ProxyService* proxy_service_; |
| 276 | 284 |
| 277 base::WaitableEvent event_; | 285 base::WaitableEvent event_; |
| 278 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; | 286 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; |
| 279 ProxyInfo proxy_info_; | 287 ProxyInfo proxy_info_; |
| 280 int result_; | 288 int result_; |
| 281 }; | 289 }; |
| 282 | 290 |
| 283 } // namespace net | 291 } // namespace net |
| 284 | 292 |
| 285 #endif // NET_PROXY_PROXY_SERVICE_H_ | 293 #endif // NET_PROXY_PROXY_SERVICE_H_ |
| OLD | NEW |