Chromium Code Reviews| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 class ProxyScriptDecider; | 39 class ProxyScriptDecider; |
| 40 class ProxyScriptFetcher; | 40 class ProxyScriptFetcher; |
| 41 | 41 |
| 42 // This class can be used to resolve the proxy server to use when loading a | 42 // This class can be used to resolve the proxy server to use when loading a |
| 43 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy | 43 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy |
| 44 // resolution. See ProxyResolverV8 for example. | 44 // resolution. See ProxyResolverV8 for example. |
| 45 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, | 45 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, |
| 46 public ProxyConfigService::Observer, | 46 public ProxyConfigService::Observer, |
| 47 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 47 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 48 public: | 48 public: |
| 49 static const size_t kDefaultNumPacThreads; | |
| 50 | |
| 49 // This interface defines the set of policies for when to poll the PAC | 51 // This interface defines the set of policies for when to poll the PAC |
| 50 // script for changes. | 52 // script for changes. |
| 51 // | 53 // |
| 52 // The polling policy decides what the next poll delay should be in | 54 // The polling policy decides what the next poll delay should be in |
| 53 // milliseconds. It also decides how to wait for this delay -- either | 55 // milliseconds. It also decides how to wait for this delay -- either |
| 54 // by starting a timer to do the poll at exactly |next_delay_ms| | 56 // by starting a timer to do the poll at exactly |next_delay_ms| |
| 55 // (MODE_USE_TIMER) or by waiting for the first network request issued after | 57 // (MODE_USE_TIMER) or by waiting for the first network request issued after |
| 56 // |next_delay_ms| (MODE_START_AFTER_ACTIVITY). | 58 // |next_delay_ms| (MODE_START_AFTER_ACTIVITY). |
| 57 // | 59 // |
| 58 // The timer method is more precise and guarantees that polling happens when | 60 // The timer method is more precise and guarantees that polling happens when |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 // Clears the list of bad proxy servers that has been cached. | 193 // Clears the list of bad proxy servers that has been cached. |
| 192 void ClearBadProxiesCache() { | 194 void ClearBadProxiesCache() { |
| 193 proxy_retry_info_.clear(); | 195 proxy_retry_info_.clear(); |
| 194 } | 196 } |
| 195 | 197 |
| 196 // Forces refetching the proxy configuration, and applying it. | 198 // Forces refetching the proxy configuration, and applying it. |
| 197 // This re-does everything from fetching the system configuration, | 199 // This re-does everything from fetching the system configuration, |
| 198 // to downloading and testing the PAC files. | 200 // to downloading and testing the PAC files. |
| 199 void ForceReloadProxyConfig(); | 201 void ForceReloadProxyConfig(); |
| 200 | 202 |
| 201 // Creates a proxy service that polls |proxy_config_service| to notice when | |
| 202 // the proxy settings change. We take ownership of |proxy_config_service|. | |
| 203 // | |
| 204 // |num_pac_threads| specifies the maximum number of threads to use for | |
| 205 // executing PAC scripts. Threads are created lazily on demand. | |
| 206 // If |0| is specified, then a default number of threads will be selected. | |
| 207 // | |
| 208 // Having more threads avoids stalling proxy resolve requests when the | |
| 209 // PAC script takes a while to run. This is particularly a problem when PAC | |
| 210 // scripts do synchronous DNS resolutions, since that can take on the order | |
| 211 // of seconds. | |
| 212 // | |
| 213 // However, the disadvantages of using more than 1 thread are: | |
| 214 // (a) can cause compatibility issues for scripts that rely on side effects | |
| 215 // between runs (such scripts should not be common though). | |
| 216 // (b) increases the memory used by proxy resolving, as each thread will | |
| 217 // duplicate its own script context. | |
| 218 | |
| 219 // |proxy_script_fetcher| specifies the dependency to use for downloading | |
| 220 // any PAC scripts. The resulting ProxyService will take ownership of it. | |
| 221 // | |
| 222 // |dhcp_proxy_script_fetcher| specifies the dependency to use for attempting | |
| 223 // to retrieve the most appropriate PAC script configured in DHCP. The | |
| 224 // resulting ProxyService will take ownership of it. | |
| 225 // | |
| 226 // |host_resolver| points to the host resolving dependency the PAC script | |
| 227 // should use for any DNS queries. It must remain valid throughout the | |
| 228 // lifetime of the ProxyService. | |
| 229 // | |
| 230 // ########################################################################## | |
| 231 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the | |
| 232 // # multi-threading model. In order for this to be safe to use, *ALL* the | |
| 233 // # other V8's running in the process must use v8::Locker. | |
| 234 // ########################################################################## | |
| 235 static ProxyService* CreateUsingV8ProxyResolver( | |
| 236 ProxyConfigService* proxy_config_service, | |
| 237 size_t num_pac_threads, | |
| 238 ProxyScriptFetcher* proxy_script_fetcher, | |
| 239 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher, | |
| 240 HostResolver* host_resolver, | |
| 241 NetLog* net_log, | |
| 242 NetworkDelegate* network_delegate); | |
| 243 | |
| 244 // Same as CreateUsingV8ProxyResolver, except it uses system libraries | 203 // Same as CreateUsingV8ProxyResolver, except it uses system libraries |
|
eroman
2012/08/28 01:37:42
Please update this. At the very least update the n
tfarina
2012/08/30 02:45:52
Done.
| |
| 245 // for evaluating the PAC script if available, otherwise skips | 204 // for evaluating the PAC script if available, otherwise skips |
| 246 // proxy autoconfig. | 205 // proxy autoconfig. |
| 247 static ProxyService* CreateUsingSystemProxyResolver( | 206 static ProxyService* CreateUsingSystemProxyResolver( |
| 248 ProxyConfigService* proxy_config_service, | 207 ProxyConfigService* proxy_config_service, |
| 249 size_t num_pac_threads, | 208 size_t num_pac_threads, |
| 250 NetLog* net_log); | 209 NetLog* net_log); |
| 251 | 210 |
| 252 // Creates a ProxyService without support for proxy autoconfig. | 211 // Creates a ProxyService without support for proxy autoconfig. |
| 253 static ProxyService* CreateWithoutProxyResolver( | 212 static ProxyService* CreateWithoutProxyResolver( |
| 254 ProxyConfigService* proxy_config_service, | 213 ProxyConfigService* proxy_config_service, |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 | 421 |
| 463 base::WaitableEvent event_; | 422 base::WaitableEvent event_; |
| 464 CompletionCallback callback_; | 423 CompletionCallback callback_; |
| 465 ProxyInfo proxy_info_; | 424 ProxyInfo proxy_info_; |
| 466 int result_; | 425 int result_; |
| 467 }; | 426 }; |
| 468 | 427 |
| 469 } // namespace net | 428 } // namespace net |
| 470 | 429 |
| 471 #endif // NET_PROXY_PROXY_SERVICE_H_ | 430 #endif // NET_PROXY_PROXY_SERVICE_H_ |
| OLD | NEW |