OLD | NEW |
---|---|
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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/io_thread.h" | 14 #include "chrome/browser/io_thread.h" |
14 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" | 15 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" |
15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "net/log/net_log.h" | 18 #include "net/log/net_log.h" |
18 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" | 19 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" |
19 #include "net/proxy/proxy_config_service.h" | 20 #include "net/proxy/proxy_config_service.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
31 #include "net/proxy/proxy_resolver_v8.h" | 32 #include "net/proxy/proxy_resolver_v8.h" |
32 #endif | 33 #endif |
33 | 34 |
34 #if !defined(OS_IOS) && !defined(OS_ANDROID) | 35 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
35 #include "chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h" | 36 #include "chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h" |
36 #include "net/proxy/proxy_service_mojo.h" | 37 #include "net/proxy/proxy_service_mojo.h" |
37 #endif | 38 #endif |
38 | 39 |
39 using content::BrowserThread; | 40 using content::BrowserThread; |
40 | 41 |
42 namespace { | |
43 | |
44 #if !defined(OS_ANDROID) | |
45 bool EnableOutOfProcessV8Pac(const base::CommandLine& command_line) { | |
46 const std::string group_name = | |
47 base::FieldTrialList::FindFullName("OutOfProcessPac"); | |
48 | |
49 if (command_line.HasSwitch(switches::kDisableOutOfProcessPac)) | |
50 return false; | |
51 if (command_line.HasSwitch(switches::kV8PacMojoOutOfProcess)) | |
52 return true; | |
53 return group_name == "Enabled"; | |
54 } | |
55 #endif // !defined(OS_ANDROID) | |
56 | |
57 } // namespace | |
58 | |
41 // static | 59 // static |
42 net::ProxyConfigService* ProxyServiceFactory::CreateProxyConfigService( | 60 net::ProxyConfigService* ProxyServiceFactory::CreateProxyConfigService( |
43 PrefProxyConfigTracker* tracker) { | 61 PrefProxyConfigTracker* tracker) { |
44 // The linux gconf-based proxy settings getter relies on being initialized | 62 // The linux gconf-based proxy settings getter relies on being initialized |
45 // from the UI thread. | 63 // from the UI thread. |
46 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 64 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
47 | 65 |
48 scoped_ptr<net::ProxyConfigService> base_service; | 66 scoped_ptr<net::ProxyConfigService> base_service; |
49 | 67 |
50 #if !defined(OS_CHROMEOS) | 68 #if !defined(OS_CHROMEOS) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 net::NetLog* net_log, | 114 net::NetLog* net_log, |
97 net::URLRequestContext* context, | 115 net::URLRequestContext* context, |
98 net::NetworkDelegate* network_delegate, | 116 net::NetworkDelegate* network_delegate, |
99 net::ProxyConfigService* proxy_config_service, | 117 net::ProxyConfigService* proxy_config_service, |
100 const base::CommandLine& command_line, | 118 const base::CommandLine& command_line, |
101 bool quick_check_enabled) { | 119 bool quick_check_enabled) { |
102 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 120 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
103 #if defined(OS_IOS) | 121 #if defined(OS_IOS) |
104 bool use_v8 = false; | 122 bool use_v8 = false; |
105 #else | 123 #else |
106 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); | 124 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); |
eroman
2015/05/12 05:21:40
I think the presence of this flag should also over
Anand Mistry (off Chromium)
2015/05/12 07:16:04
Isn't that already the case? If this flag is set,
eroman
2015/05/14 22:31:29
right you are!
| |
107 // TODO(eroman): Figure out why this doesn't work in single-process mode. | 125 // TODO(eroman): Figure out why this doesn't work in single-process mode. |
108 // Should be possible now that a private isolate is used. | 126 // Should be possible now that a private isolate is used. |
109 // http://crbug.com/474654 | 127 // http://crbug.com/474654 |
110 if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) { | 128 if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) { |
111 LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; | 129 LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; |
112 use_v8 = false; // Fallback to non-v8 implementation. | 130 use_v8 = false; // Fallback to non-v8 implementation. |
113 } | 131 } |
114 #endif // defined(OS_IOS) | 132 #endif // defined(OS_IOS) |
115 | 133 |
116 size_t num_pac_threads = 0u; // Use default number of threads. | 134 size_t num_pac_threads = 0u; // Use default number of threads. |
(...skipping 20 matching lines...) Expand all Loading... | |
137 net::DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher; | 155 net::DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher; |
138 #if defined(OS_CHROMEOS) | 156 #if defined(OS_CHROMEOS) |
139 dhcp_proxy_script_fetcher = | 157 dhcp_proxy_script_fetcher = |
140 new chromeos::DhcpProxyScriptFetcherChromeos(context); | 158 new chromeos::DhcpProxyScriptFetcherChromeos(context); |
141 #else | 159 #else |
142 net::DhcpProxyScriptFetcherFactory dhcp_factory; | 160 net::DhcpProxyScriptFetcherFactory dhcp_factory; |
143 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); | 161 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); |
144 #endif | 162 #endif |
145 | 163 |
146 #if !defined(OS_ANDROID) | 164 #if !defined(OS_ANDROID) |
147 if (command_line.HasSwitch(switches::kV8PacMojoOutOfProcess)) { | 165 // In-process Mojo PAC can only be set on the command line, so it's presence |
166 // should override other options. | |
167 if (command_line.HasSwitch(switches::kV8PacMojoInProcess)) { | |
168 proxy_service = net::CreateProxyServiceUsingMojoInProcess( | |
169 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | |
170 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, | |
171 network_delegate); | |
172 } | |
173 | |
174 if (!proxy_service && EnableOutOfProcessV8Pac(command_line)) { | |
eroman
2015/05/12 05:21:41
rather than !proxy_service, can you do an "else if
Anand Mistry (off Chromium)
2015/05/12 07:16:04
Done.
| |
148 proxy_service = net::CreateProxyServiceUsingMojoFactory( | 175 proxy_service = net::CreateProxyServiceUsingMojoFactory( |
149 UtilityProcessMojoProxyResolverFactory::GetInstance(), | 176 UtilityProcessMojoProxyResolverFactory::GetInstance(), |
150 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 177 proxy_config_service, new net::ProxyScriptFetcherImpl(context), |
151 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, | 178 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, |
152 network_delegate); | 179 network_delegate); |
153 } else if (command_line.HasSwitch(switches::kV8PacMojoInProcess)) { | |
154 proxy_service = net::CreateProxyServiceUsingMojoInProcess( | |
155 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | |
156 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, | |
157 network_delegate); | |
158 } | 180 } |
159 #endif // !defined(OS_ANDROID) | 181 #endif // !defined(OS_ANDROID) |
160 | 182 |
161 if (!proxy_service) { | 183 if (!proxy_service) { |
162 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( | 184 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( |
163 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 185 proxy_config_service, new net::ProxyScriptFetcherImpl(context), |
164 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, | 186 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, |
165 network_delegate); | 187 network_delegate); |
166 } | 188 } |
167 #endif // defined(OS_IOS) | 189 #endif // defined(OS_IOS) |
168 } else { | 190 } else { |
169 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( | 191 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( |
170 proxy_config_service, | 192 proxy_config_service, |
171 num_pac_threads, | 193 num_pac_threads, |
172 net_log); | 194 net_log); |
173 } | 195 } |
174 | 196 |
175 proxy_service->set_quick_check_enabled(quick_check_enabled); | 197 proxy_service->set_quick_check_enabled(quick_check_enabled); |
176 | 198 |
177 return proxy_service; | 199 return proxy_service; |
178 } | 200 } |
OLD | NEW |