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/profiler/scoped_tracker.h" | |
9 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
10 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
11 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/io_thread.h" | 11 #include "chrome/browser/io_thread.h" |
13 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" | 12 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" |
14 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
15 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
16 #include "net/base/net_log.h" | 15 #include "net/base/net_log.h" |
17 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" | 16 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" |
18 #include "net/proxy/proxy_config_service.h" | 17 #include "net/proxy/proxy_config_service.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 86 |
88 // static | 87 // static |
89 net::ProxyService* ProxyServiceFactory::CreateProxyService( | 88 net::ProxyService* ProxyServiceFactory::CreateProxyService( |
90 net::NetLog* net_log, | 89 net::NetLog* net_log, |
91 net::URLRequestContext* context, | 90 net::URLRequestContext* context, |
92 net::NetworkDelegate* network_delegate, | 91 net::NetworkDelegate* network_delegate, |
93 net::ProxyConfigService* proxy_config_service, | 92 net::ProxyConfigService* proxy_config_service, |
94 const base::CommandLine& command_line, | 93 const base::CommandLine& command_line, |
95 bool quick_check_enabled) { | 94 bool quick_check_enabled) { |
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
97 | |
98 // TODO(michaeln): Remove ScopedTracker below once crbug.com/454983 is fixed. | |
99 tracked_objects::ScopedTracker tracking_profile( | |
100 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
101 "454983 ProxyServiceFactory::CreateProxyService")); | |
102 | |
103 #if defined(OS_IOS) | 96 #if defined(OS_IOS) |
104 bool use_v8 = false; | 97 bool use_v8 = false; |
105 #else | 98 #else |
106 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); | 99 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); |
107 #endif // defined(OS_IOS) | 100 #endif // defined(OS_IOS) |
108 | 101 |
109 size_t num_pac_threads = 0u; // Use default number of threads. | 102 size_t num_pac_threads = 0u; // Use default number of threads. |
110 | 103 |
111 // Check the command line for an override on the number of proxy resolver | 104 // Check the command line for an override on the number of proxy resolver |
112 // threads to use. | 105 // threads to use. |
113 if (command_line.HasSwitch(switches::kNumPacThreads)) { | 106 if (command_line.HasSwitch(switches::kNumPacThreads)) { |
114 std::string s = command_line.GetSwitchValueASCII(switches::kNumPacThreads); | 107 std::string s = command_line.GetSwitchValueASCII(switches::kNumPacThreads); |
115 | 108 |
116 // Parse the switch (it should be a positive integer formatted as decimal). | 109 // Parse the switch (it should be a positive integer formatted as decimal). |
117 int n; | 110 int n; |
118 if (base::StringToInt(s, &n) && n > 0) { | 111 if (base::StringToInt(s, &n) && n > 0) { |
119 num_pac_threads = static_cast<size_t>(n); | 112 num_pac_threads = static_cast<size_t>(n); |
120 } else { | 113 } else { |
121 LOG(ERROR) << "Invalid switch for number of PAC threads: " << s; | 114 LOG(ERROR) << "Invalid switch for number of PAC threads: " << s; |
122 } | 115 } |
123 } | 116 } |
124 | 117 |
125 // TODO(eroman): Remove once crbug.com/454983 is fixed. | |
126 tracked_objects::ScopedTracker tracking_profile2( | |
127 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
128 "454983 ProxyServiceFactory::CreateProxyService_2")); | |
129 | |
130 net::ProxyService* proxy_service = NULL; | 118 net::ProxyService* proxy_service = NULL; |
131 if (use_v8) { | 119 if (use_v8) { |
132 // TODO(eroman): Remove once crbug.com/454983 is fixed. | |
133 tracked_objects::ScopedTracker tracking_profile3( | |
134 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
135 "454983 ProxyServiceFactory::CreateProxyService_3")); | |
136 | |
137 #if defined(OS_IOS) | 120 #if defined(OS_IOS) |
138 NOTREACHED(); | 121 NOTREACHED(); |
139 #else | 122 #else |
140 net::DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher; | 123 net::DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher; |
141 #if defined(OS_CHROMEOS) | 124 #if defined(OS_CHROMEOS) |
142 dhcp_proxy_script_fetcher = | 125 dhcp_proxy_script_fetcher = |
143 new chromeos::DhcpProxyScriptFetcherChromeos(context); | 126 new chromeos::DhcpProxyScriptFetcherChromeos(context); |
144 #else | 127 #else |
145 net::DhcpProxyScriptFetcherFactory dhcp_factory; | 128 net::DhcpProxyScriptFetcherFactory dhcp_factory; |
146 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); | 129 dhcp_proxy_script_fetcher = dhcp_factory.Create(context); |
147 #endif | 130 #endif |
148 | 131 |
149 // TODO(eroman): Remove once crbug.com/454983 is fixed. | |
150 tracked_objects::ScopedTracker tracking_profile4( | |
151 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
152 "454983 ProxyServiceFactory::CreateProxyService_4")); | |
153 | |
154 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( | 132 proxy_service = net::CreateProxyServiceUsingV8ProxyResolver( |
155 proxy_config_service, | 133 proxy_config_service, |
156 new net::ProxyScriptFetcherImpl(context), | 134 new net::ProxyScriptFetcherImpl(context), |
157 dhcp_proxy_script_fetcher, | 135 dhcp_proxy_script_fetcher, |
158 context->host_resolver(), | 136 context->host_resolver(), |
159 net_log, | 137 net_log, |
160 network_delegate); | 138 network_delegate); |
161 #endif // defined(OS_IOS) | 139 #endif // defined(OS_IOS) |
162 } else { | 140 } else { |
163 // TODO(eroman): Remove once crbug.com/454983 is fixed. | |
164 tracked_objects::ScopedTracker tracking_profile5( | |
165 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
166 "454983 ProxyServiceFactory::CreateProxyService_5")); | |
167 | |
168 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( | 141 proxy_service = net::ProxyService::CreateUsingSystemProxyResolver( |
169 proxy_config_service, | 142 proxy_config_service, |
170 num_pac_threads, | 143 num_pac_threads, |
171 net_log); | 144 net_log); |
172 } | 145 } |
173 | 146 |
174 proxy_service->set_quick_check_enabled(quick_check_enabled); | 147 proxy_service->set_quick_check_enabled(quick_check_enabled); |
175 | 148 |
176 return proxy_service; | 149 return proxy_service; |
177 } | 150 } |
OLD | NEW |