| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 proxy_retry_info_.clear(); | 130 proxy_retry_info_.clear(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 // Forces refetching the proxy configuration, and applying it. | 133 // Forces refetching the proxy configuration, and applying it. |
| 134 // This re-does everything from fetching the system configuration, | 134 // This re-does everything from fetching the system configuration, |
| 135 // to downloading and testing the PAC files. | 135 // to downloading and testing the PAC files. |
| 136 void ForceReloadProxyConfig(); | 136 void ForceReloadProxyConfig(); |
| 137 | 137 |
| 138 // Creates a proxy service that polls |proxy_config_service| to notice when | 138 // Creates a proxy service that polls |proxy_config_service| to notice when |
| 139 // the proxy settings change. We take ownership of |proxy_config_service|. | 139 // the proxy settings change. We take ownership of |proxy_config_service|. |
| 140 // Iff |use_v8_resolver| is true, then the V8 implementation is | |
| 141 // used. | |
| 142 // | 140 // |
| 143 // |num_pac_threads| specifies the maximum number of threads to use for | 141 // |num_pac_threads| specifies the maximum number of threads to use for |
| 144 // executing PAC scripts. Threads are created lazily on demand. | 142 // executing PAC scripts. Threads are created lazily on demand. |
| 145 // If |0| is specified, then a default number of threads will be selected. | 143 // If |0| is specified, then a default number of threads will be selected. |
| 146 // | 144 // |
| 147 // Having more threads avoids stalling proxy resolve requests when the | 145 // Having more threads avoids stalling proxy resolve requests when the |
| 148 // PAC script takes a while to run. This is particularly a problem when PAC | 146 // PAC script takes a while to run. This is particularly a problem when PAC |
| 149 // scripts do synchronous DNS resolutions, since that can take on the order | 147 // scripts do synchronous DNS resolutions, since that can take on the order |
| 150 // of seconds. | 148 // of seconds. |
| 151 // | 149 // |
| 152 // However, the disadvantages of using more than 1 thread are: | 150 // However, the disadvantages of using more than 1 thread are: |
| 153 // (a) can cause compatibility issues for scripts that rely on side effects | 151 // (a) can cause compatibility issues for scripts that rely on side effects |
| 154 // between runs (such scripts should not be common though). | 152 // between runs (such scripts should not be common though). |
| 155 // (b) increases the memory used by proxy resolving, as each thread will | 153 // (b) increases the memory used by proxy resolving, as each thread will |
| 156 // duplicate its own script context. | 154 // duplicate its own script context. |
| 157 | 155 |
| 158 // |url_request_context| is only used when use_v8_resolver is true: | 156 // |url_request_context| specifies the URL request context that will |
| 159 // it specifies the URL request context that will be used if a PAC | 157 // be used if a PAC script needs to be fetched. |
| 160 // script needs to be fetched. | 158 // |io_loop| points to the IO thread's message loop. |
| 161 // |io_loop| points to the IO thread's message loop. It is only used | |
| 162 // when pc is NULL. | |
| 163 // ########################################################################## | 159 // ########################################################################## |
| 164 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the | 160 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the |
| 165 // # multi-threading model. In order for this to be safe to use, *ALL* the | 161 // # multi-threading model. In order for this to be safe to use, *ALL* the |
| 166 // # other V8's running in the process must use v8::Locker. | 162 // # other V8's running in the process must use v8::Locker. |
| 167 // ########################################################################## | 163 // ########################################################################## |
| 168 static ProxyService* Create( | 164 static ProxyService* CreateUsingV8ProxyResolver( |
| 169 ProxyConfigService* proxy_config_service, | 165 ProxyConfigService* proxy_config_service, |
| 170 bool use_v8_resolver, | |
| 171 size_t num_pac_threads, | 166 size_t num_pac_threads, |
| 172 URLRequestContext* url_request_context, | 167 URLRequestContext* url_request_context, |
| 173 NetLog* net_log, | 168 NetLog* net_log, |
| 174 MessageLoop* io_loop); | 169 MessageLoop* io_loop); |
| 175 | 170 |
| 171 // Same as CreateUsingV8ProxyResolver, except it uses system libraries |
| 172 // for evaluating the PAC script if available, otherwise skips |
| 173 // proxy autoconfig. |
| 174 static ProxyService* CreateUsingSystemProxyResolver( |
| 175 ProxyConfigService* proxy_config_service, |
| 176 size_t num_pac_threads, |
| 177 NetLog* net_log); |
| 178 |
| 179 // Creates a ProxyService without support for proxy autoconfig. |
| 180 static ProxyService* CreateWithoutProxyResolver( |
| 181 ProxyConfigService* proxy_config_service, |
| 182 NetLog* net_log); |
| 183 |
| 176 // Convenience method that creates a proxy service using the | 184 // Convenience method that creates a proxy service using the |
| 177 // specified fixed settings. |pc| must not be NULL. | 185 // specified fixed settings. |pc| must not be NULL. |
| 178 static ProxyService* CreateFixed(const ProxyConfig& pc); | 186 static ProxyService* CreateFixed(const ProxyConfig& pc); |
| 179 | 187 |
| 180 // Creates a proxy service that uses a DIRECT connection for all requests. | 188 // Creates a proxy service that uses a DIRECT connection for all requests. |
| 181 static ProxyService* CreateDirect(); | 189 static ProxyService* CreateDirect(); |
| 182 | 190 |
| 183 // This method is used by tests to create a ProxyService that returns a | 191 // This method is used by tests to create a ProxyService that returns a |
| 184 // hardcoded proxy fallback list (|pac_string|) for every URL. | 192 // hardcoded proxy fallback list (|pac_string|) for every URL. |
| 185 // | 193 // |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 361 |
| 354 base::WaitableEvent event_; | 362 base::WaitableEvent event_; |
| 355 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; | 363 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; |
| 356 ProxyInfo proxy_info_; | 364 ProxyInfo proxy_info_; |
| 357 int result_; | 365 int result_; |
| 358 }; | 366 }; |
| 359 | 367 |
| 360 } // namespace net | 368 } // namespace net |
| 361 | 369 |
| 362 #endif // NET_PROXY_PROXY_SERVICE_H_ | 370 #endif // NET_PROXY_PROXY_SERVICE_H_ |
| OLD | NEW |