Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: chrome/browser/net/proxy_service_factory.cc

Issue 862813002: WIP: Prototype OOP V8 PAC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Slight cleanup and report JS memory usage. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/task_manager/child_process_resource_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/net/proxy_service_factory.h" 5 #include "chrome/browser/net/proxy_service_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/io_thread.h" 11 #include "chrome/browser/io_thread.h"
12 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" 12 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/utility_process_host.h"
16 #include "content/public/browser/utility_process_host_client.h"
17 #include "content/public/common/service_registry.h"
15 #include "net/base/net_log.h" 18 #include "net/base/net_log.h"
19 #include "net/dns/host_resolver.mojom.h"
20 #include "net/dns/host_resolver_mojo_host.h"
16 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" 21 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h"
22 #include "net/proxy/network_delegate_error_observer.h"
17 #include "net/proxy/proxy_config_service.h" 23 #include "net/proxy/proxy_config_service.h"
24 #include "net/proxy/proxy_resolver.mojom.h"
25 #include "net/proxy/proxy_resolver_error_observer_mojo_host.h"
26 #include "net/proxy/proxy_resolver_mojo.h"
27 #include "net/proxy/proxy_resolver_mojo_host.h"
18 #include "net/proxy/proxy_script_fetcher_impl.h" 28 #include "net/proxy/proxy_script_fetcher_impl.h"
19 #include "net/proxy/proxy_service.h" 29 #include "net/proxy/proxy_service.h"
20 #include "net/proxy/proxy_service_v8.h" 30 #include "net/proxy/proxy_service_v8.h"
21 #include "net/url_request/url_request_context.h" 31 #include "net/url_request/url_request_context.h"
22 32
23 #if defined(OS_CHROMEOS) 33 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/chromeos/proxy_config_service_impl.h" 34 #include "chrome/browser/chromeos/proxy_config_service_impl.h"
25 #include "chromeos/network/dhcp_proxy_script_fetcher_chromeos.h" 35 #include "chromeos/network/dhcp_proxy_script_fetcher_chromeos.h"
26 #endif // defined(OS_CHROMEOS) 36 #endif // defined(OS_CHROMEOS)
27 37
28 #if !defined(OS_IOS) 38 #if !defined(OS_IOS)
29 #include "net/proxy/proxy_resolver_v8.h" 39 #include "net/proxy/proxy_resolver_v8.h"
30 #endif 40 #endif
31 41
32 using content::BrowserThread; 42 using content::BrowserThread;
33 43
44 namespace {
45
46 net::ProxyService* CreateProxyServiceUsingMojo(
47 net::ProxyConfigService* proxy_config_service,
48 net::ProxyScriptFetcher* proxy_script_fetcher,
49 net::DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
50 net::HostResolver* host_resolver,
51 net::NetLog* net_log,
52 net::NetworkDelegate* network_delegate) {
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
54 DCHECK(proxy_config_service);
55 DCHECK(proxy_script_fetcher);
56 DCHECK(dhcp_proxy_script_fetcher);
57 DCHECK(host_resolver);
58
59 content::UtilityProcessHost* utility_process_host;
60 utility_process_host = content::UtilityProcessHost::Create(
61 scoped_refptr<content::UtilityProcessHostClient>(),
62 base::MessageLoopProxy::current().get());
63 utility_process_host->StartMojoMode();
64 content::ServiceRegistry* service_registry =
65 utility_process_host->GetServiceRegistry();
66
67 net::proxy::ResolverFactoryPtr resolver_factory;
68 service_registry->ConnectToRemoteService(&resolver_factory);
69
70 net::proxy::ResolverPtr resolver_handle;
71 net::dns::ResolverPtr dns_resolver_handle;
72 net::proxy::ErrorObserverPtr error_observer_handle;
73 mojo::BindToProxy(new net::HostResolverMojoHost(host_resolver),
74 &dns_resolver_handle);
75 mojo::BindToProxy(
76 new net::ProxyResolverErrorObserverMojoHost(
77 make_scoped_ptr(new net::NetworkDelegateErrorObserver(
78 network_delegate, base::MessageLoopProxy::current().get()))),
79 &error_observer_handle);
80
81 resolver_factory->CreateResolver(mojo::GetProxy(&resolver_handle),
82 dns_resolver_handle.Pass(),
83 error_observer_handle.Pass());
84
85 net::ProxyResolver* proxy_resolver =
86 new net::ProxyResolverMojo(resolver_handle.Pass(), host_resolver);
87
88 net::ProxyService* proxy_service =
89 new net::ProxyService(proxy_config_service, proxy_resolver, net_log);
90
91 // Configure fetchers to use for PAC script downloads and auto-detect.
92 proxy_service->SetProxyScriptFetchers(proxy_script_fetcher,
93 dhcp_proxy_script_fetcher);
94
95 return proxy_service;
96 }
97
98 }
99
34 // static 100 // static
35 net::ProxyConfigService* ProxyServiceFactory::CreateProxyConfigService( 101 net::ProxyConfigService* ProxyServiceFactory::CreateProxyConfigService(
36 PrefProxyConfigTracker* tracker) { 102 PrefProxyConfigTracker* tracker) {
37 // The linux gconf-based proxy settings getter relies on being initialized 103 // The linux gconf-based proxy settings getter relies on being initialized
38 // from the UI thread. 104 // from the UI thread.
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
40 106
41 scoped_ptr<net::ProxyConfigService> base_service; 107 scoped_ptr<net::ProxyConfigService> base_service;
42 108
43 #if !defined(OS_CHROMEOS) 109 #if !defined(OS_CHROMEOS)
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } else { 186 } else {
121 LOG(ERROR) << "Invalid switch for number of PAC threads: " << s; 187 LOG(ERROR) << "Invalid switch for number of PAC threads: " << s;
122 } 188 }
123 } 189 }
124 190
125 net::ProxyService* proxy_service = NULL; 191 net::ProxyService* proxy_service = NULL;
126 if (use_v8) { 192 if (use_v8) {
127 #if defined(OS_IOS) 193 #if defined(OS_IOS)
128 NOTREACHED(); 194 NOTREACHED();
129 #else 195 #else
130 net::ProxyResolverV8::EnsureIsolateCreated();
131
132 net::DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher; 196 net::DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher;
133 #if defined(OS_CHROMEOS) 197 #if defined(OS_CHROMEOS)
134 dhcp_proxy_script_fetcher = 198 dhcp_proxy_script_fetcher =
135 new chromeos::DhcpProxyScriptFetcherChromeos(context); 199 new chromeos::DhcpProxyScriptFetcherChromeos(context);
136 #else 200 #else
137 net::DhcpProxyScriptFetcherFactory dhcp_factory; 201 net::DhcpProxyScriptFetcherFactory dhcp_factory;
138 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); 202 dhcp_proxy_script_fetcher = dhcp_factory.Create(context);
139 #endif 203 #endif
140 204
141 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( 205 proxy_service = CreateProxyServiceUsingMojo(
142 proxy_config_service, 206 proxy_config_service,
143 new net::ProxyScriptFetcherImpl(context), 207 new net::ProxyScriptFetcherImpl(context),
144 dhcp_proxy_script_fetcher, 208 dhcp_proxy_script_fetcher,
145 context->host_resolver(), 209 context->host_resolver(),
146 net_log, 210 net_log,
147 network_delegate); 211 network_delegate);
148 #endif // defined(OS_IOS) 212 #endif // defined(OS_IOS)
149 } else { 213 } else {
150 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( 214 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver(
151 proxy_config_service, 215 proxy_config_service,
152 num_pac_threads, 216 num_pac_threads,
153 net_log); 217 net_log);
154 } 218 }
155 219
156 proxy_service->set_quick_check_enabled(quick_check_enabled); 220 proxy_service->set_quick_check_enabled(quick_check_enabled);
157 221
158 return proxy_service; 222 return proxy_service;
159 } 223 }
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/task_manager/child_process_resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698