| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
| 16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
| 17 #include "net/base/net_log.h" | 17 #include "net/base/net_log.h" |
| 18 #include "net/base/network_change_notifier.h" | 18 #include "net/base/network_change_notifier.h" |
| 19 #include "net/proxy/proxy_config_service.h" | 19 #include "net/proxy/proxy_config_service.h" |
| 20 #include "net/proxy/proxy_info.h" | 20 #include "net/proxy/proxy_info.h" |
| 21 #include "net/proxy/proxy_server.h" | 21 #include "net/proxy/proxy_server.h" |
| 22 | 22 |
| 23 class GURL; | 23 class GURL; |
| 24 class MessageLoop; | 24 class MessageLoop; |
| 25 | 25 |
| 26 namespace net { | 26 namespace net { |
| 27 | 27 |
| 28 class DhcpProxyScriptFetcher; |
| 28 class HostResolver; | 29 class HostResolver; |
| 29 class InitProxyResolver; | 30 class InitProxyResolver; |
| 30 class NetworkDelegate; | 31 class NetworkDelegate; |
| 31 class ProxyResolver; | 32 class ProxyResolver; |
| 32 class ProxyScriptFetcher; | 33 class ProxyScriptFetcher; |
| 33 class URLRequestContext; | 34 class URLRequestContext; |
| 34 | 35 |
| 35 // This class can be used to resolve the proxy server to use when loading a | 36 // This class can be used to resolve the proxy server to use when loading a |
| 36 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy | 37 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy |
| 37 // resolution. See ProxyResolverV8 for example. | 38 // resolution. See ProxyResolverV8 for example. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // Profiling information for the request is saved to |net_log| if non-NULL. | 92 // Profiling information for the request is saved to |net_log| if non-NULL. |
| 92 int ReconsiderProxyAfterError(const GURL& url, | 93 int ReconsiderProxyAfterError(const GURL& url, |
| 93 ProxyInfo* results, | 94 ProxyInfo* results, |
| 94 CompletionCallback* callback, | 95 CompletionCallback* callback, |
| 95 PacRequest** pac_request, | 96 PacRequest** pac_request, |
| 96 const BoundNetLog& net_log); | 97 const BoundNetLog& net_log); |
| 97 | 98 |
| 98 // Call this method with a non-null |pac_request| to cancel the PAC request. | 99 // Call this method with a non-null |pac_request| to cancel the PAC request. |
| 99 void CancelPacRequest(PacRequest* pac_request); | 100 void CancelPacRequest(PacRequest* pac_request); |
| 100 | 101 |
| 101 // Sets the ProxyScriptFetcher dependency. This is needed if the ProxyResolver | 102 // Sets the ProxyScriptFetcher and DhcpProxyScriptFetcher dependencies. This |
| 102 // is of type ProxyResolverWithoutFetch. ProxyService takes ownership of | 103 // is needed if the ProxyResolver is of type ProxyResolverWithoutFetch. |
| 103 // |proxy_script_fetcher|. | 104 // ProxyService takes ownership of both objects. |
| 104 void SetProxyScriptFetcher(ProxyScriptFetcher* proxy_script_fetcher); | 105 void SetProxyScriptFetchers( |
| 106 ProxyScriptFetcher* proxy_script_fetcher, |
| 107 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher); |
| 105 ProxyScriptFetcher* GetProxyScriptFetcher() const; | 108 ProxyScriptFetcher* GetProxyScriptFetcher() const; |
| 106 | 109 |
| 107 // Tells this ProxyService to start using a new ProxyConfigService to | 110 // Tells this ProxyService to start using a new ProxyConfigService to |
| 108 // retrieve its ProxyConfig from. The new ProxyConfigService will immediately | 111 // retrieve its ProxyConfig from. The new ProxyConfigService will immediately |
| 109 // be queried for new config info which will be used for all subsequent | 112 // be queried for new config info which will be used for all subsequent |
| 110 // ResolveProxy calls. ProxyService takes ownership of | 113 // ResolveProxy calls. ProxyService takes ownership of |
| 111 // |new_proxy_config_service|. | 114 // |new_proxy_config_service|. |
| 112 void ResetConfigService(ProxyConfigService* new_proxy_config_service); | 115 void ResetConfigService(ProxyConfigService* new_proxy_config_service); |
| 113 | 116 |
| 114 // Tells the resolver to purge any memory it does not need. | 117 // Tells the resolver to purge any memory it does not need. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // | 157 // |
| 155 // However, the disadvantages of using more than 1 thread are: | 158 // However, the disadvantages of using more than 1 thread are: |
| 156 // (a) can cause compatibility issues for scripts that rely on side effects | 159 // (a) can cause compatibility issues for scripts that rely on side effects |
| 157 // between runs (such scripts should not be common though). | 160 // between runs (such scripts should not be common though). |
| 158 // (b) increases the memory used by proxy resolving, as each thread will | 161 // (b) increases the memory used by proxy resolving, as each thread will |
| 159 // duplicate its own script context. | 162 // duplicate its own script context. |
| 160 | 163 |
| 161 // |proxy_script_fetcher| specifies the dependency to use for downloading | 164 // |proxy_script_fetcher| specifies the dependency to use for downloading |
| 162 // any PAC scripts. The resulting ProxyService will take ownership of it. | 165 // any PAC scripts. The resulting ProxyService will take ownership of it. |
| 163 // | 166 // |
| 167 // |dhcp_proxy_script_fetcher| specifies the dependency to use for attempting |
| 168 // to retrieve the most appropriate PAC script configured in DHCP. The |
| 169 // resulting ProxyService will take ownership of it. |
| 170 // |
| 164 // |host_resolver| points to the host resolving dependency the PAC script | 171 // |host_resolver| points to the host resolving dependency the PAC script |
| 165 // should use for any DNS queries. It must remain valid throughout the | 172 // should use for any DNS queries. It must remain valid throughout the |
| 166 // lifetime of the ProxyService. | 173 // lifetime of the ProxyService. |
| 167 // | 174 // |
| 168 // ########################################################################## | 175 // ########################################################################## |
| 169 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the | 176 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the |
| 170 // # multi-threading model. In order for this to be safe to use, *ALL* the | 177 // # multi-threading model. In order for this to be safe to use, *ALL* the |
| 171 // # other V8's running in the process must use v8::Locker. | 178 // # other V8's running in the process must use v8::Locker. |
| 172 // ########################################################################## | 179 // ########################################################################## |
| 173 static ProxyService* CreateUsingV8ProxyResolver( | 180 static ProxyService* CreateUsingV8ProxyResolver( |
| 174 ProxyConfigService* proxy_config_service, | 181 ProxyConfigService* proxy_config_service, |
| 175 size_t num_pac_threads, | 182 size_t num_pac_threads, |
| 176 ProxyScriptFetcher* proxy_script_fetcher, | 183 ProxyScriptFetcher* proxy_script_fetcher, |
| 184 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher, |
| 177 HostResolver* host_resolver, | 185 HostResolver* host_resolver, |
| 178 NetLog* net_log, | 186 NetLog* net_log, |
| 179 NetworkDelegate* network_delegate); | 187 NetworkDelegate* network_delegate); |
| 180 | 188 |
| 181 // Same as CreateUsingV8ProxyResolver, except it uses system libraries | 189 // Same as CreateUsingV8ProxyResolver, except it uses system libraries |
| 182 // for evaluating the PAC script if available, otherwise skips | 190 // for evaluating the PAC script if available, otherwise skips |
| 183 // proxy autoconfig. | 191 // proxy autoconfig. |
| 184 static ProxyService* CreateUsingSystemProxyResolver( | 192 static ProxyService* CreateUsingSystemProxyResolver( |
| 185 ProxyConfigService* proxy_config_service, | 193 ProxyConfigService* proxy_config_service, |
| 186 size_t num_pac_threads, | 194 size_t num_pac_threads, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 ProxyRetryInfoMap proxy_retry_info_; | 320 ProxyRetryInfoMap proxy_retry_info_; |
| 313 | 321 |
| 314 // Set of pending/inprogress requests. | 322 // Set of pending/inprogress requests. |
| 315 PendingRequests pending_requests_; | 323 PendingRequests pending_requests_; |
| 316 | 324 |
| 317 // The fetcher to use when downloading PAC scripts for the ProxyResolver. | 325 // The fetcher to use when downloading PAC scripts for the ProxyResolver. |
| 318 // This dependency can be NULL if our ProxyResolver has no need for | 326 // This dependency can be NULL if our ProxyResolver has no need for |
| 319 // external PAC script fetching. | 327 // external PAC script fetching. |
| 320 scoped_ptr<ProxyScriptFetcher> proxy_script_fetcher_; | 328 scoped_ptr<ProxyScriptFetcher> proxy_script_fetcher_; |
| 321 | 329 |
| 330 // The fetcher to use when attempting to download the most appropriate PAC |
| 331 // script configured in DHCP, if any. Can be NULL if the ProxyResolver has |
| 332 // no need for DHCP PAC script fetching. |
| 333 scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher_; |
| 334 |
| 322 // Callback for when |init_proxy_resolver_| is done. | 335 // Callback for when |init_proxy_resolver_| is done. |
| 323 CompletionCallbackImpl<ProxyService> init_proxy_resolver_callback_; | 336 CompletionCallbackImpl<ProxyService> init_proxy_resolver_callback_; |
| 324 | 337 |
| 325 // Helper to download the PAC script (wpad + custom) and apply fallback rules. | 338 // Helper to download the PAC script (wpad + custom) and apply fallback rules. |
| 326 // | 339 // |
| 327 // Note that the declaration is important here: |proxy_script_fetcher_| and | 340 // Note that the declaration is important here: |proxy_script_fetcher_| and |
| 328 // |proxy_resolver_| must outlive |init_proxy_resolver_|. | 341 // |proxy_resolver_| must outlive |init_proxy_resolver_|. |
| 329 scoped_ptr<InitProxyResolver> init_proxy_resolver_; | 342 scoped_ptr<InitProxyResolver> init_proxy_resolver_; |
| 330 | 343 |
| 331 State current_state_; | 344 State current_state_; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 390 |
| 378 base::WaitableEvent event_; | 391 base::WaitableEvent event_; |
| 379 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; | 392 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; |
| 380 ProxyInfo proxy_info_; | 393 ProxyInfo proxy_info_; |
| 381 int result_; | 394 int result_; |
| 382 }; | 395 }; |
| 383 | 396 |
| 384 } // namespace net | 397 } // namespace net |
| 385 | 398 |
| 386 #endif // NET_PROXY_PROXY_SERVICE_H_ | 399 #endif // NET_PROXY_PROXY_SERVICE_H_ |
| OLD | NEW |