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( |
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 16 matching lines...) Expand all Loading... |
107 #else | 107 #else |
108 return new PrefProxyConfigTrackerImpl(local_state_prefs); | 108 return new PrefProxyConfigTrackerImpl(local_state_prefs); |
109 #endif // defined(OS_CHROMEOS) | 109 #endif // defined(OS_CHROMEOS) |
110 } | 110 } |
111 | 111 |
112 // static | 112 // static |
113 scoped_ptr<net::ProxyService> ProxyServiceFactory::CreateProxyService( | 113 scoped_ptr<net::ProxyService> ProxyServiceFactory::CreateProxyService( |
114 net::NetLog* net_log, | 114 net::NetLog* net_log, |
115 net::URLRequestContext* context, | 115 net::URLRequestContext* context, |
116 net::NetworkDelegate* network_delegate, | 116 net::NetworkDelegate* network_delegate, |
117 net::ProxyConfigService* proxy_config_service, | 117 scoped_ptr<net::ProxyConfigService> proxy_config_service, |
118 const base::CommandLine& command_line, | 118 const base::CommandLine& command_line, |
119 bool quick_check_enabled) { | 119 bool quick_check_enabled) { |
120 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 120 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
121 #if defined(OS_IOS) | 121 #if defined(OS_IOS) |
122 bool use_v8 = false; | 122 bool use_v8 = false; |
123 #else | 123 #else |
124 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); | 124 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); |
125 // 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. |
126 // Should be possible now that a private isolate is used. | 126 // Should be possible now that a private isolate is used. |
127 // http://crbug.com/474654 | 127 // http://crbug.com/474654 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 #else | 159 #else |
160 net::DhcpProxyScriptFetcherFactory dhcp_factory; | 160 net::DhcpProxyScriptFetcherFactory dhcp_factory; |
161 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); | 161 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); |
162 #endif | 162 #endif |
163 | 163 |
164 #if !defined(OS_ANDROID) | 164 #if !defined(OS_ANDROID) |
165 // In-process Mojo PAC can only be set on the command line, so its presence | 165 // In-process Mojo PAC can only be set on the command line, so its presence |
166 // should override other options. | 166 // should override other options. |
167 if (command_line.HasSwitch(switches::kV8PacMojoInProcess)) { | 167 if (command_line.HasSwitch(switches::kV8PacMojoInProcess)) { |
168 proxy_service = net::CreateProxyServiceUsingMojoInProcess( | 168 proxy_service = net::CreateProxyServiceUsingMojoInProcess( |
169 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 169 proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context), |
170 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, | 170 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, |
171 network_delegate); | 171 network_delegate); |
172 } else if (EnableOutOfProcessV8Pac(command_line)) { | 172 } else if (EnableOutOfProcessV8Pac(command_line)) { |
173 proxy_service = net::CreateProxyServiceUsingMojoFactory( | 173 proxy_service = net::CreateProxyServiceUsingMojoFactory( |
174 UtilityProcessMojoProxyResolverFactory::GetInstance(), | 174 UtilityProcessMojoProxyResolverFactory::GetInstance(), |
175 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 175 proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context), |
176 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, | 176 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, |
177 network_delegate); | 177 network_delegate); |
178 } | 178 } |
179 #endif // !defined(OS_ANDROID) | 179 #endif // !defined(OS_ANDROID) |
180 | 180 |
181 if (!proxy_service) { | 181 if (!proxy_service) { |
182 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( | 182 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( |
183 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 183 proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context), |
184 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, | 184 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, |
185 network_delegate); | 185 network_delegate); |
186 } | 186 } |
187 #endif // defined(OS_IOS) | 187 #endif // defined(OS_IOS) |
188 } else { | 188 } else { |
189 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( | 189 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( |
190 proxy_config_service, | 190 proxy_config_service.Pass(), num_pac_threads, net_log); |
191 num_pac_threads, | |
192 net_log); | |
193 } | 191 } |
194 | 192 |
195 proxy_service->set_quick_check_enabled(quick_check_enabled); | 193 proxy_service->set_quick_check_enabled(quick_check_enabled); |
196 | 194 |
197 return proxy_service; | 195 return proxy_service; |
198 } | 196 } |
OLD | NEW |