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/metrics/field_trial.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 // determines the effective proxy config to take effect in the network layer, | 70 // determines the effective proxy config to take effect in the network layer, |
71 // be it from prefs or system (which is network shill on chromeos). | 71 // be it from prefs or system (which is network shill on chromeos). |
72 | 72 |
73 // For other platforms, create a baseline service that provides proxy | 73 // For other platforms, create a baseline service that provides proxy |
74 // configuration in case nothing is configured through prefs (Note: prefs | 74 // configuration in case nothing is configured through prefs (Note: prefs |
75 // include command line and configuration policy). | 75 // include command line and configuration policy). |
76 | 76 |
77 // TODO(port): the IO and FILE message loops are only used by Linux. Can | 77 // TODO(port): the IO and FILE message loops are only used by Linux. Can |
78 // that code be moved to chrome/browser instead of being in net, so that it | 78 // that code be moved to chrome/browser instead of being in net, so that it |
79 // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354. | 79 // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354. |
80 base_service.reset(net::ProxyService::CreateSystemProxyConfigService( | 80 base_service = (net::ProxyService::CreateSystemProxyConfigService( |
mmenke
2015/09/18 18:58:53
nit: Extra parens not needed.
Charlie Harrison
2015/09/18 19:56:06
Done.
| |
81 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 81 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
82 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); | 82 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); |
83 #endif // !defined(OS_CHROMEOS) | 83 #endif // !defined(OS_CHROMEOS) |
84 | 84 |
85 return tracker->CreateTrackingProxyConfigService(base_service.Pass()) | 85 return tracker->CreateTrackingProxyConfigService(base_service.Pass()) |
86 .release(); | 86 .release(); |
87 } | 87 } |
88 | 88 |
89 // static | 89 // static |
90 PrefProxyConfigTracker* | 90 PrefProxyConfigTracker* |
(...skipping 20 matching lines...) Expand all Loading... | |
111 local_state_prefs, | 111 local_state_prefs, |
112 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 112 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
113 #endif // defined(OS_CHROMEOS) | 113 #endif // defined(OS_CHROMEOS) |
114 } | 114 } |
115 | 115 |
116 // static | 116 // static |
117 scoped_ptr<net::ProxyService> ProxyServiceFactory::CreateProxyService( | 117 scoped_ptr<net::ProxyService> ProxyServiceFactory::CreateProxyService( |
118 net::NetLog* net_log, | 118 net::NetLog* net_log, |
119 net::URLRequestContext* context, | 119 net::URLRequestContext* context, |
120 net::NetworkDelegate* network_delegate, | 120 net::NetworkDelegate* network_delegate, |
121 net::ProxyConfigService* proxy_config_service, | 121 scoped_ptr<net::ProxyConfigService> proxy_config_service, |
122 const base::CommandLine& command_line, | 122 const base::CommandLine& command_line, |
123 bool quick_check_enabled) { | 123 bool quick_check_enabled) { |
124 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 124 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
125 #if defined(OS_IOS) | 125 #if defined(OS_IOS) |
126 bool use_v8 = false; | 126 bool use_v8 = false; |
127 #else | 127 #else |
128 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); | 128 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); |
129 // TODO(eroman): Figure out why this doesn't work in single-process mode. | 129 // TODO(eroman): Figure out why this doesn't work in single-process mode. |
130 // Should be possible now that a private isolate is used. | 130 // Should be possible now that a private isolate is used. |
131 // http://crbug.com/474654 | 131 // http://crbug.com/474654 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 #else | 163 #else |
164 net::DhcpProxyScriptFetcherFactory dhcp_factory; | 164 net::DhcpProxyScriptFetcherFactory dhcp_factory; |
165 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); | 165 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); |
166 #endif | 166 #endif |
167 | 167 |
168 #if !defined(OS_ANDROID) | 168 #if !defined(OS_ANDROID) |
169 // In-process Mojo PAC can only be set on the command line, so its presence | 169 // In-process Mojo PAC can only be set on the command line, so its presence |
170 // should override other options. | 170 // should override other options. |
171 if (command_line.HasSwitch(switches::kV8PacMojoInProcess)) { | 171 if (command_line.HasSwitch(switches::kV8PacMojoInProcess)) { |
172 proxy_service = net::CreateProxyServiceUsingMojoInProcess( | 172 proxy_service = net::CreateProxyServiceUsingMojoInProcess( |
173 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 173 proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context), |
174 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, | 174 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, |
175 network_delegate); | 175 network_delegate); |
176 } else if (EnableOutOfProcessV8Pac(command_line)) { | 176 } else if (EnableOutOfProcessV8Pac(command_line)) { |
177 proxy_service = net::CreateProxyServiceUsingMojoFactory( | 177 proxy_service = net::CreateProxyServiceUsingMojoFactory( |
178 UtilityProcessMojoProxyResolverFactory::GetInstance(), | 178 UtilityProcessMojoProxyResolverFactory::GetInstance(), |
179 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 179 proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context), |
180 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, | 180 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, |
181 network_delegate); | 181 network_delegate); |
182 } | 182 } |
183 #endif // !defined(OS_ANDROID) | 183 #endif // !defined(OS_ANDROID) |
184 | 184 |
185 if (!proxy_service) { | 185 if (!proxy_service) { |
186 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( | 186 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( |
187 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 187 proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context), |
188 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, | 188 dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log, |
189 network_delegate); | 189 network_delegate); |
190 } | 190 } |
191 #endif // defined(OS_IOS) | 191 #endif // defined(OS_IOS) |
192 } else { | 192 } else { |
193 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( | 193 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( |
194 proxy_config_service, | 194 proxy_config_service.Pass(), num_pac_threads, net_log); |
195 num_pac_threads, | |
196 net_log); | |
197 } | 195 } |
198 | 196 |
199 proxy_service->set_quick_check_enabled(quick_check_enabled); | 197 proxy_service->set_quick_check_enabled(quick_check_enabled); |
200 | 198 |
201 return proxy_service; | 199 return proxy_service; |
202 } | 200 } |
OLD | NEW |