OLD | NEW |
| (Empty) |
1 // Copyright 2017 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. | |
4 | |
5 #include "net/url_request/url_request_context_builder_v8.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "net/proxy/proxy_config_service.h" | |
9 #include "net/proxy/proxy_script_fetcher_impl.h" | |
10 #include "net/proxy/proxy_service_v8.h" | |
11 | |
12 #ifdef ENABLE_NET_MOJO | |
13 #include "net/proxy/proxy_service_mojo.h" | |
14 #endif | |
15 | |
16 namespace net { | |
17 | |
18 URLRequestContextBuilderV8::URLRequestContextBuilderV8() | |
19 : dhcp_fetcher_factory_(new DhcpProxyScriptFetcherFactory()) {} | |
20 | |
21 URLRequestContextBuilderV8::~URLRequestContextBuilderV8() = default; | |
22 | |
23 std::unique_ptr<ProxyService> URLRequestContextBuilderV8::CreateProxyService( | |
24 std::unique_ptr<ProxyConfigService> proxy_config_service, | |
25 URLRequestContext* url_request_context, | |
26 HostResolver* host_resolver, | |
27 NetworkDelegate* network_delegate, | |
28 NetLog* net_log) { | |
29 DCHECK(url_request_context); | |
30 DCHECK(host_resolver); | |
31 | |
32 if (!use_v8_) { | |
33 return URLRequestContextBuilder::CreateProxyService( | |
34 std::move(proxy_config_service), url_request_context, host_resolver, | |
35 network_delegate, net_log); | |
36 } | |
37 | |
38 std::unique_ptr<net::DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher = | |
39 dhcp_fetcher_factory_->Create(url_request_context); | |
40 std::unique_ptr<net::ProxyScriptFetcher> proxy_script_fetcher = | |
41 base::MakeUnique<ProxyScriptFetcherImpl>(url_request_context); | |
42 std::unique_ptr<ProxyService> proxy_service; | |
43 #ifdef ENABLE_NET_MOJO | |
44 if (mojo_proxy_resolver_factory_) { | |
45 proxy_service = CreateProxyServiceUsingMojoFactory( | |
46 mojo_proxy_resolver_factory_, std::move(proxy_config_service), | |
47 proxy_script_fetcher.release(), std::move(dhcp_proxy_script_fetcher), | |
48 host_resolver, net_log, network_delegate); | |
49 } | |
50 #endif // ENABLE_NET_MOJO | |
51 if (!proxy_service) { | |
52 proxy_service = CreateProxyServiceUsingV8ProxyResolver( | |
53 std::move(proxy_config_service), proxy_script_fetcher.release(), | |
54 std::move(dhcp_proxy_script_fetcher), host_resolver, net_log, | |
55 network_delegate); | |
56 } | |
57 | |
58 proxy_service->set_quick_check_enabled(quick_check_enabled_); | |
59 proxy_service->set_sanitize_url_policy(sanitize_url_policy_); | |
60 | |
61 return proxy_service; | |
62 } | |
63 | |
64 } // namespace net | |
OLD | NEW |