Chromium Code Reviews| 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 "net/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 } | 293 } |
| 294 | 294 |
| 295 bool HttpStreamFactoryImpl::OnInitConnection(const JobController& controller, | 295 bool HttpStreamFactoryImpl::OnInitConnection(const JobController& controller, |
| 296 const ProxyInfo& proxy_info, | 296 const ProxyInfo& proxy_info, |
| 297 PrivacyMode privacy_mode) { | 297 PrivacyMode privacy_mode) { |
| 298 if (!controller.is_preconnect()) { | 298 if (!controller.is_preconnect()) { |
| 299 // Connection initialization can be skipped only for the preconnect jobs. | 299 // Connection initialization can be skipped only for the preconnect jobs. |
| 300 return false; | 300 return false; |
| 301 } | 301 } |
| 302 | 302 |
| 303 if (!session_->params().restrict_to_one_preconnect_for_proxies || | 303 if (!ProxyServerSupportsPriorities(proxy_info)) |
| 304 !ProxyServerSupportsPriorities(proxy_info)) { | |
| 305 return false; | 304 return false; |
| 306 } | |
| 307 | 305 |
| 308 PreconnectingProxyServer preconnecting_proxy_server(proxy_info.proxy_server(), | 306 PreconnectingProxyServer preconnecting_proxy_server(proxy_info.proxy_server(), |
| 309 privacy_mode); | 307 privacy_mode); |
| 310 | 308 |
| 311 if (base::ContainsKey(preconnecting_proxy_servers_, | 309 if (base::ContainsKey(preconnecting_proxy_servers_, |
| 312 preconnecting_proxy_server)) { | 310 preconnecting_proxy_server)) { |
| 313 UMA_HISTOGRAM_EXACT_LINEAR("Net.PreconnectSkippedToProxyServers", 1, 2); | 311 UMA_HISTOGRAM_EXACT_LINEAR("Net.PreconnectSkippedToProxyServers", 1, 2); |
| 314 // Skip preconnect to the proxy server since we are already preconnecting | 312 // Skip preconnect to the proxy server since we are already preconnecting |
| 315 // (probably via some other job). | 313 // (probably via some other job). |
|
xunjieli
2017/04/28 14:24:31
Could you link crbug.com/682041 in this comment?
tbansal1
2017/04/28 16:36:08
Done.
| |
| 316 return true; | 314 return true; |
| 317 } | 315 } |
| 318 | 316 |
| 319 // Add the proxy server to the set of preconnecting proxy servers. | 317 // Add the proxy server to the set of preconnecting proxy servers. |
| 320 // The maximum size of |preconnecting_proxy_servers_|. | 318 // The maximum size of |preconnecting_proxy_servers_|. |
| 321 static const size_t kMaxPreconnectingServerSize = 3; | 319 static const size_t kMaxPreconnectingServerSize = 3; |
| 322 if (preconnecting_proxy_servers_.size() >= kMaxPreconnectingServerSize) { | 320 if (preconnecting_proxy_servers_.size() >= kMaxPreconnectingServerSize) { |
| 323 // Erase the first entry. A better approach (at the cost of higher memory | 321 // Erase the first entry. A better approach (at the cost of higher memory |
| 324 // overhead) may be to erase the least recently used entry. | 322 // overhead) may be to erase the least recently used entry. |
| 325 preconnecting_proxy_servers_.erase(preconnecting_proxy_servers_.begin()); | 323 preconnecting_proxy_servers_.erase(preconnecting_proxy_servers_.begin()); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 factory_dump->AddScalar("main_job_count", | 450 factory_dump->AddScalar("main_job_count", |
| 453 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 451 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 454 main_job_count); | 452 main_job_count); |
| 455 // The number of preconnect controllers. | 453 // The number of preconnect controllers. |
| 456 factory_dump->AddScalar("preconnect_count", | 454 factory_dump->AddScalar("preconnect_count", |
| 457 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 455 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 458 num_controllers_for_preconnect); | 456 num_controllers_for_preconnect); |
| 459 } | 457 } |
| 460 | 458 |
| 461 } // namespace net | 459 } // namespace net |
| OLD | NEW |