| 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/strings/string_number_conversions.h" | 8 #include "base/strings/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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 25 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 25 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
| 26 #include "chromeos/network/dhcp_proxy_script_fetcher_chromeos.h" | 26 #include "chromeos/network/dhcp_proxy_script_fetcher_chromeos.h" |
| 27 #endif // defined(OS_CHROMEOS) | 27 #endif // defined(OS_CHROMEOS) |
| 28 | 28 |
| 29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 30 #include "win8/util/win8_util.h" | 30 #include "win8/util/win8_util.h" |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
| 34 #include "net/proxy/proxy_resolver_v8.h" |
| 35 #endif |
| 36 |
| 33 using content::BrowserThread; | 37 using content::BrowserThread; |
| 34 | 38 |
| 35 // static | 39 // static |
| 36 net::ProxyConfigService* ProxyServiceFactory::CreateProxyConfigService( | 40 net::ProxyConfigService* ProxyServiceFactory::CreateProxyConfigService( |
| 37 PrefProxyConfigTracker* tracker) { | 41 PrefProxyConfigTracker* tracker) { |
| 38 // The linux gconf-based proxy settings getter relies on being initialized | 42 // The linux gconf-based proxy settings getter relies on being initialized |
| 39 // from the UI thread. | 43 // from the UI thread. |
| 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 41 | 45 |
| 42 scoped_ptr<net::ProxyConfigService> base_service; | 46 scoped_ptr<net::ProxyConfigService> base_service; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 #else | 104 #else |
| 101 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); | 105 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); |
| 102 if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) { | 106 if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) { |
| 103 // See the note about V8 multithreading in net/proxy/proxy_resolver_v8.h | 107 // See the note about V8 multithreading in net/proxy/proxy_resolver_v8.h |
| 104 // to understand why we have this limitation. | 108 // to understand why we have this limitation. |
| 105 LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; | 109 LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; |
| 106 use_v8 = false; // Fallback to non-v8 implementation. | 110 use_v8 = false; // Fallback to non-v8 implementation. |
| 107 } | 111 } |
| 108 #endif // defined(OS_IOS) | 112 #endif // defined(OS_IOS) |
| 109 | 113 |
| 110 #if defined(OS_WIN) | |
| 111 // Crashes. http://crbug.com/266838 | |
| 112 if (use_v8 && win8::IsSingleWindowMetroMode()) | |
| 113 use_v8 = false; | |
| 114 #endif | |
| 115 | |
| 116 size_t num_pac_threads = 0u; // Use default number of threads. | 114 size_t num_pac_threads = 0u; // Use default number of threads. |
| 117 | 115 |
| 118 // Check the command line for an override on the number of proxy resolver | 116 // Check the command line for an override on the number of proxy resolver |
| 119 // threads to use. | 117 // threads to use. |
| 120 if (command_line.HasSwitch(switches::kNumPacThreads)) { | 118 if (command_line.HasSwitch(switches::kNumPacThreads)) { |
| 121 std::string s = command_line.GetSwitchValueASCII(switches::kNumPacThreads); | 119 std::string s = command_line.GetSwitchValueASCII(switches::kNumPacThreads); |
| 122 | 120 |
| 123 // Parse the switch (it should be a positive integer formatted as decimal). | 121 // Parse the switch (it should be a positive integer formatted as decimal). |
| 124 int n; | 122 int n; |
| 125 if (base::StringToInt(s, &n) && n > 0) { | 123 if (base::StringToInt(s, &n) && n > 0) { |
| 126 num_pac_threads = static_cast<size_t>(n); | 124 num_pac_threads = static_cast<size_t>(n); |
| 127 } else { | 125 } else { |
| 128 LOG(ERROR) << "Invalid switch for number of PAC threads: " << s; | 126 LOG(ERROR) << "Invalid switch for number of PAC threads: " << s; |
| 129 } | 127 } |
| 130 } | 128 } |
| 131 | 129 |
| 132 net::ProxyService* proxy_service = NULL; | 130 net::ProxyService* proxy_service = NULL; |
| 133 if (use_v8) { | 131 if (use_v8) { |
| 134 #if defined(OS_IOS) | 132 #if defined(OS_IOS) |
| 135 NOTREACHED(); | 133 NOTREACHED(); |
| 136 #else | 134 #else |
| 135 net::ProxyResolverV8::CreateIsolate(); |
| 136 |
| 137 net::DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher; | 137 net::DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher; |
| 138 #if defined(OS_CHROMEOS) | 138 #if defined(OS_CHROMEOS) |
| 139 dhcp_proxy_script_fetcher = | 139 dhcp_proxy_script_fetcher = |
| 140 new chromeos::DhcpProxyScriptFetcherChromeos(context); | 140 new chromeos::DhcpProxyScriptFetcherChromeos(context); |
| 141 #else | 141 #else |
| 142 net::DhcpProxyScriptFetcherFactory dhcp_factory; | 142 net::DhcpProxyScriptFetcherFactory dhcp_factory; |
| 143 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); | 143 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); |
| 144 #endif | 144 #endif |
| 145 | 145 |
| 146 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( | 146 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( |
| 147 proxy_config_service, | 147 proxy_config_service, |
| 148 new net::ProxyScriptFetcherImpl(context), | 148 new net::ProxyScriptFetcherImpl(context), |
| 149 dhcp_proxy_script_fetcher, | 149 dhcp_proxy_script_fetcher, |
| 150 context->host_resolver(), | 150 context->host_resolver(), |
| 151 net_log, | 151 net_log, |
| 152 network_delegate); | 152 network_delegate); |
| 153 #endif // defined(OS_IOS) | 153 #endif // defined(OS_IOS) |
| 154 } else { | 154 } else { |
| 155 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( | 155 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( |
| 156 proxy_config_service, | 156 proxy_config_service, |
| 157 num_pac_threads, | 157 num_pac_threads, |
| 158 net_log); | 158 net_log); |
| 159 } | 159 } |
| 160 | 160 |
| 161 proxy_service->set_quick_check_enabled(quick_check_enabled); | 161 proxy_service->set_quick_check_enabled(quick_check_enabled); |
| 162 | 162 |
| 163 return proxy_service; | 163 return proxy_service; |
| 164 } | 164 } |
| OLD | NEW |