1 // Copyright 2015 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 #include "net/proxy/proxy_service_mojo.h"
7 #include "base/logging.h"
8 #include "net/dns/host_resolver_mojo.h"
9 #include "net/interfaces/proxy_resolver_service.mojom.h"
10 #include "net/proxy/in_process_mojo_proxy_resolver_factory.h"
11 #include "net/proxy/mojo_proxy_resolver_impl.h"
12 #include "net/proxy/proxy_resolver_factory.h"
13 #include "net/proxy/proxy_resolver_mojo.h"
14 #include "net/proxy/proxy_resolver_v8_tracing.h"
15 #include "net/proxy/proxy_service.h"
20 class ProxyResolverFactoryForMojoResolver
: public LegacyProxyResolverFactory
{
22 ProxyResolverFactoryForMojoResolver(
23 MojoProxyResolverFactory
* mojo_proxy_factory
,
24 HostResolver
* host_resolver
)
25 : LegacyProxyResolverFactory(true),
26 mojo_proxy_factory_(mojo_proxy_factory
),
27 host_resolver_(host_resolver
) {}
29 // LegacyProxyResolverFactory override.
30 scoped_ptr
<ProxyResolver
> CreateProxyResolver() override
{
31 return make_scoped_ptr(
32 new ProxyResolverMojo(mojo_proxy_factory_
, host_resolver_
));
36 MojoProxyResolverFactory
* const mojo_proxy_factory_
;
37 HostResolver
* const host_resolver_
;
39 DISALLOW_COPY_AND_ASSIGN(ProxyResolverFactoryForMojoResolver
);
44 ProxyService
* CreateProxyServiceUsingMojoFactory(
45 MojoProxyResolverFactory
* mojo_proxy_factory
,
46 ProxyConfigService
* proxy_config_service
,
47 ProxyScriptFetcher
* proxy_script_fetcher
,
48 DhcpProxyScriptFetcher
* dhcp_proxy_script_fetcher
,
49 HostResolver
* host_resolver
,
51 NetworkDelegate
* network_delegate
) {
52 DCHECK(proxy_config_service
);
53 DCHECK(proxy_script_fetcher
);
54 DCHECK(dhcp_proxy_script_fetcher
);
55 DCHECK(host_resolver
);
57 ProxyService
* proxy_service
=
58 new ProxyService(proxy_config_service
,
59 make_scoped_ptr(new ProxyResolverFactoryForMojoResolver(
60 mojo_proxy_factory
, host_resolver
)),
63 // Configure fetchers to use for PAC script downloads and auto-detect.
64 proxy_service
->SetProxyScriptFetchers(proxy_script_fetcher
,
65 dhcp_proxy_script_fetcher
);
70 ProxyService
* CreateProxyServiceUsingMojoInProcess(
71 ProxyConfigService
* proxy_config_service
,
72 ProxyScriptFetcher
* proxy_script_fetcher
,
73 DhcpProxyScriptFetcher
* dhcp_proxy_script_fetcher
,
74 HostResolver
* host_resolver
,
76 NetworkDelegate
* network_delegate
) {
77 return CreateProxyServiceUsingMojoFactory(
78 InProcessMojoProxyResolverFactory::GetInstance(), proxy_config_service
,
79 proxy_script_fetcher
, dhcp_proxy_script_fetcher
, host_resolver
, net_log
,