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
3 // found in the LICENSE file.
5 #ifndef NET_PROXY_PROXY_SERVICE_V8_H_
6 #define NET_PROXY_PROXY_SERVICE_V8_H_
8 #include "base/basictypes.h"
9 #include "net/base/net_export.h"
13 class DhcpProxyScriptFetcher
;
16 class NetworkDelegate
;
17 class ProxyConfigService
;
18 class ProxyScriptFetcher
;
21 // Creates a proxy service that polls |proxy_config_service| to notice when
22 // the proxy settings change. We take ownership of |proxy_config_service|.
24 // |num_pac_threads| specifies the maximum number of threads to use for
25 // executing PAC scripts. Threads are created lazily on demand.
26 // If |0| is specified, then a default number of threads will be selected.
28 // Having more threads avoids stalling proxy resolve requests when the
29 // PAC script takes a while to run. This is particularly a problem when PAC
30 // scripts do synchronous DNS resolutions, since that can take on the order
33 // However, the disadvantages of using more than 1 thread are:
34 // (a) can cause compatibility issues for scripts that rely on side effects
35 // between runs (such scripts should not be common though).
36 // (b) increases the memory used by proxy resolving, as each thread will
37 // duplicate its own script context.
39 // |proxy_script_fetcher| specifies the dependency to use for downloading
40 // any PAC scripts. The resulting ProxyService will take ownership of it.
42 // |dhcp_proxy_script_fetcher| specifies the dependency to use for attempting
43 // to retrieve the most appropriate PAC script configured in DHCP. The
44 // resulting ProxyService will take ownership of it.
46 // |host_resolver| points to the host resolving dependency the PAC script
47 // should use for any DNS queries. It must remain valid throughout the
48 // lifetime of the ProxyService.
50 // ##########################################################################
51 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the
52 // # multi-threading model. In order for this to be safe to use, *ALL* the
53 // # other V8's running in the process must use v8::Locker.
54 // ##########################################################################
55 NET_EXPORT ProxyService
* CreateProxyServiceUsingV8ProxyResolver(
56 ProxyConfigService
* proxy_config_service
,
57 size_t num_pac_threads
,
58 ProxyScriptFetcher
* proxy_script_fetcher
,
59 DhcpProxyScriptFetcher
* dhcp_proxy_script_fetcher
,
60 HostResolver
* host_resolver
,
62 NetworkDelegate
* network_delegate
);
66 #endif // NET_PROXY_PROXY_SERVICE_V8_H_