| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/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" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 #endif // defined(OS_CHROMEOS) | 70 #endif // defined(OS_CHROMEOS) |
| 71 | 71 |
| 72 // static | 72 // static |
| 73 net::ProxyService* ProxyServiceFactory::CreateProxyService( | 73 net::ProxyService* ProxyServiceFactory::CreateProxyService( |
| 74 net::NetLog* net_log, | 74 net::NetLog* net_log, |
| 75 net::URLRequestContext* context, | 75 net::URLRequestContext* context, |
| 76 net::ProxyConfigService* proxy_config_service, | 76 net::ProxyConfigService* proxy_config_service, |
| 77 const CommandLine& command_line) { | 77 const CommandLine& command_line) { |
| 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 79 | 79 |
| 80 #if defined(OS_IOS) |
| 81 bool use_v8 = false; |
| 82 #else |
| 80 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); | 83 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); |
| 81 if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) { | 84 if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) { |
| 82 // See the note about V8 multithreading in net/proxy/proxy_resolver_v8.h | 85 // See the note about V8 multithreading in net/proxy/proxy_resolver_v8.h |
| 83 // to understand why we have this limitation. | 86 // to understand why we have this limitation. |
| 84 LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; | 87 LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; |
| 85 use_v8 = false; // Fallback to non-v8 implementation. | 88 use_v8 = false; // Fallback to non-v8 implementation. |
| 86 } | 89 } |
| 90 #endif // defined(OS_IOS) |
| 87 | 91 |
| 88 size_t num_pac_threads = 0u; // Use default number of threads. | 92 size_t num_pac_threads = 0u; // Use default number of threads. |
| 89 | 93 |
| 90 // Check the command line for an override on the number of proxy resolver | 94 // Check the command line for an override on the number of proxy resolver |
| 91 // threads to use. | 95 // threads to use. |
| 92 if (command_line.HasSwitch(switches::kNumPacThreads)) { | 96 if (command_line.HasSwitch(switches::kNumPacThreads)) { |
| 93 std::string s = command_line.GetSwitchValueASCII(switches::kNumPacThreads); | 97 std::string s = command_line.GetSwitchValueASCII(switches::kNumPacThreads); |
| 94 | 98 |
| 95 // Parse the switch (it should be a positive integer formatted as decimal). | 99 // Parse the switch (it should be a positive integer formatted as decimal). |
| 96 int n; | 100 int n; |
| 97 if (base::StringToInt(s, &n) && n > 0) { | 101 if (base::StringToInt(s, &n) && n > 0) { |
| 98 num_pac_threads = static_cast<size_t>(n); | 102 num_pac_threads = static_cast<size_t>(n); |
| 99 } else { | 103 } else { |
| 100 LOG(ERROR) << "Invalid switch for number of PAC threads: " << s; | 104 LOG(ERROR) << "Invalid switch for number of PAC threads: " << s; |
| 101 } | 105 } |
| 102 } | 106 } |
| 103 | 107 |
| 104 net::ProxyService* proxy_service; | 108 net::ProxyService* proxy_service; |
| 105 if (use_v8) { | 109 if (use_v8) { |
| 110 #if defined(OS_IOS) |
| 111 NOTREACHED(); |
| 112 #else |
| 106 net::DhcpProxyScriptFetcherFactory dhcp_factory; | 113 net::DhcpProxyScriptFetcherFactory dhcp_factory; |
| 107 if (command_line.HasSwitch(switches::kDisableDhcpWpad)) { | 114 if (command_line.HasSwitch(switches::kDisableDhcpWpad)) { |
| 108 dhcp_factory.set_enabled(false); | 115 dhcp_factory.set_enabled(false); |
| 109 } | 116 } |
| 110 | 117 |
| 111 proxy_service = net::ProxyService::CreateUsingV8ProxyResolver( | 118 proxy_service = net::ProxyService::CreateUsingV8ProxyResolver( |
| 112 proxy_config_service, | 119 proxy_config_service, |
| 113 num_pac_threads, | 120 num_pac_threads, |
| 114 new net::ProxyScriptFetcherImpl(context), | 121 new net::ProxyScriptFetcherImpl(context), |
| 115 dhcp_factory.Create(context), | 122 dhcp_factory.Create(context), |
| 116 context->host_resolver(), | 123 context->host_resolver(), |
| 117 net_log, | 124 net_log, |
| 118 context->network_delegate()); | 125 context->network_delegate()); |
| 126 #endif // defined(OS_IOS) |
| 119 } else { | 127 } else { |
| 120 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( | 128 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( |
| 121 proxy_config_service, | 129 proxy_config_service, |
| 122 num_pac_threads, | 130 num_pac_threads, |
| 123 net_log); | 131 net_log); |
| 124 } | 132 } |
| 125 | 133 |
| 126 return proxy_service; | 134 return proxy_service; |
| 127 } | 135 } |
| OLD | NEW |