| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 its 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 } else if (EnableOutOfProcessV8Pac(command_line)) { |
| 148 proxy_service = net::CreateProxyServiceUsingMojoFactory( | 173 proxy_service = net::CreateProxyServiceUsingMojoFactory( |
| 149 UtilityProcessMojoProxyResolverFactory::GetInstance(), | 174 UtilityProcessMojoProxyResolverFactory::GetInstance(), |
| 150 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 175 proxy_config_service, new net::ProxyScriptFetcherImpl(context), |
| 151 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, | 176 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, |
| 152 network_delegate); | 177 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 } | 178 } |
| 159 #endif // !defined(OS_ANDROID) | 179 #endif // !defined(OS_ANDROID) |
| 160 | 180 |
| 161 if (!proxy_service) { | 181 if (!proxy_service) { |
| 162 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( | 182 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( |
| 163 proxy_config_service, new net::ProxyScriptFetcherImpl(context), | 183 proxy_config_service, new net::ProxyScriptFetcherImpl(context), |
| 164 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, | 184 dhcp_proxy_script_fetcher, context->host_resolver(), net_log, |
| 165 network_delegate); | 185 network_delegate); |
| 166 } | 186 } |
| 167 #endif // defined(OS_IOS) | 187 #endif // defined(OS_IOS) |
| 168 } else { | 188 } else { |
| 169 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( | 189 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( |
| 170 proxy_config_service, | 190 proxy_config_service, |
| 171 num_pac_threads, | 191 num_pac_threads, |
| 172 net_log); | 192 net_log); |
| 173 } | 193 } |
| 174 | 194 |
| 175 proxy_service->set_quick_check_enabled(quick_check_enabled); | 195 proxy_service->set_quick_check_enabled(quick_check_enabled); |
| 176 | 196 |
| 177 return proxy_service; | 197 return proxy_service; |
| 178 } | 198 } |
| OLD | NEW |