Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: net/socket/transport_client_socket_pool.cc

Issue 1062413002: Remove unnecessary instrumentation for several jank bugs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fixes Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/socket/transport_client_socket_pool.h" 5 #include "net/socket/transport_client_socket_pool.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/profiler/scoped_tracker.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "net/base/ip_endpoint.h" 19 #include "net/base/ip_endpoint.h"
19 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
20 #include "net/log/net_log.h" 21 #include "net/log/net_log.h"
21 #include "net/socket/client_socket_factory.h" 22 #include "net/socket/client_socket_factory.h"
22 #include "net/socket/client_socket_handle.h" 23 #include "net/socket/client_socket_handle.h"
23 #include "net/socket/client_socket_pool_base.h" 24 #include "net/socket/client_socket_pool_base.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void TransportConnectJob::MakeAddressListStartWithIPv4(AddressList* list) { 232 void TransportConnectJob::MakeAddressListStartWithIPv4(AddressList* list) {
232 for (AddressList::iterator i = list->begin(); i != list->end(); ++i) { 233 for (AddressList::iterator i = list->begin(); i != list->end(); ++i) {
233 if (i->GetFamily() == ADDRESS_FAMILY_IPV4) { 234 if (i->GetFamily() == ADDRESS_FAMILY_IPV4) {
234 std::rotate(list->begin(), i, list->end()); 235 std::rotate(list->begin(), i, list->end());
235 break; 236 break;
236 } 237 }
237 } 238 }
238 } 239 }
239 240
240 int TransportConnectJob::DoResolveHost() { 241 int TransportConnectJob::DoResolveHost() {
241 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed. 242 // TODO(ricea): Remove ScopedTracker below once crbug.com/436634 is fixed.
242 tracked_objects::ScopedTracker tracking_profile( 243 tracked_objects::ScopedTracker tracking_profile(
243 FROM_HERE_WITH_EXPLICIT_FUNCTION( 244 FROM_HERE_WITH_EXPLICIT_FUNCTION(
244 "436634 TransportConnectJob::DoResolveHost")); 245 "436634 TransportConnectJob::DoResolveHost"));
245 246
246 return helper_.DoResolveHost(priority(), net_log()); 247 return helper_.DoResolveHost(priority(), net_log());
247 } 248 }
248 249
249 int TransportConnectJob::DoResolveHostComplete(int result) { 250 int TransportConnectJob::DoResolveHostComplete(int result) {
250 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed.
251 tracked_objects::ScopedTracker tracking_profile(
252 FROM_HERE_WITH_EXPLICIT_FUNCTION(
253 "436634 TransportConnectJob::DoResolveHostComplete"));
254
255 return helper_.DoResolveHostComplete(result, net_log()); 251 return helper_.DoResolveHostComplete(result, net_log());
256 } 252 }
257 253
258 int TransportConnectJob::DoTransportConnect() { 254 int TransportConnectJob::DoTransportConnect() {
259 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed.
260 tracked_objects::ScopedTracker tracking_profile(
261 FROM_HERE_WITH_EXPLICIT_FUNCTION(
262 "436634 TransportConnectJob::DoTransportConnect"));
263
264 base::TimeTicks now = base::TimeTicks::Now(); 255 base::TimeTicks now = base::TimeTicks::Now();
265 base::TimeTicks last_connect_time; 256 base::TimeTicks last_connect_time;
266 { 257 {
267 base::AutoLock lock(g_last_connect_time_lock.Get()); 258 base::AutoLock lock(g_last_connect_time_lock.Get());
268 last_connect_time = g_last_connect_time.Get(); 259 last_connect_time = g_last_connect_time.Get();
269 *g_last_connect_time.Pointer() = now; 260 *g_last_connect_time.Pointer() = now;
270 } 261 }
271 if (last_connect_time.is_null()) { 262 if (last_connect_time.is_null()) {
272 interval_between_connects_ = CONNECT_INTERVAL_GT_20MS; 263 interval_between_connects_ = CONNECT_INTERVAL_GT_20MS;
273 } else { 264 } else {
274 int64 interval = (now - last_connect_time).InMilliseconds(); 265 int64 interval = (now - last_connect_time).InMilliseconds();
275 if (interval <= 10) 266 if (interval <= 10)
276 interval_between_connects_ = CONNECT_INTERVAL_LE_10MS; 267 interval_between_connects_ = CONNECT_INTERVAL_LE_10MS;
277 else if (interval <= 20) 268 else if (interval <= 20)
278 interval_between_connects_ = CONNECT_INTERVAL_LE_20MS; 269 interval_between_connects_ = CONNECT_INTERVAL_LE_20MS;
279 else 270 else
280 interval_between_connects_ = CONNECT_INTERVAL_GT_20MS; 271 interval_between_connects_ = CONNECT_INTERVAL_GT_20MS;
281 } 272 }
282 273
283 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed.
284 tracked_objects::ScopedTracker tracking_profile1(
285 FROM_HERE_WITH_EXPLICIT_FUNCTION(
286 "436634 TransportConnectJob::DoTransportConnect1"));
287
288 helper_.set_next_state( 274 helper_.set_next_state(
289 TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE); 275 TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE);
290 transport_socket_ = 276 transport_socket_ =
291 helper_.client_socket_factory()->CreateTransportClientSocket( 277 helper_.client_socket_factory()->CreateTransportClientSocket(
292 helper_.addresses(), net_log().net_log(), net_log().source()); 278 helper_.addresses(), net_log().net_log(), net_log().source());
293 279
294 // If the list contains IPv6 and IPv4 addresses, the first address will 280 // If the list contains IPv6 and IPv4 addresses, the first address will
295 // be IPv6, and the IPv4 addresses will be tried as fallback addresses, 281 // be IPv6, and the IPv4 addresses will be tried as fallback addresses,
296 // per "Happy Eyeballs" (RFC 6555). 282 // per "Happy Eyeballs" (RFC 6555).
297 bool try_ipv6_connect_with_ipv4_fallback = 283 bool try_ipv6_connect_with_ipv4_fallback =
298 helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV6 && 284 helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV6 &&
299 !AddressListOnlyContainsIPv6(helper_.addresses()); 285 !AddressListOnlyContainsIPv6(helper_.addresses());
300 286
301 // Enable TCP FastOpen if indicated by transport socket params. 287 // Enable TCP FastOpen if indicated by transport socket params.
302 // Note: We currently do not turn on TCP FastOpen for destinations where 288 // Note: We currently do not turn on TCP FastOpen for destinations where
303 // we try a TCP connect over IPv6 with fallback to IPv4. 289 // we try a TCP connect over IPv6 with fallback to IPv4.
304 if (!try_ipv6_connect_with_ipv4_fallback && 290 if (!try_ipv6_connect_with_ipv4_fallback &&
305 helper_.params()->combine_connect_and_write() == 291 helper_.params()->combine_connect_and_write() ==
306 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DESIRED) { 292 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DESIRED) {
307 transport_socket_->EnableTCPFastOpenIfSupported(); 293 transport_socket_->EnableTCPFastOpenIfSupported();
308 } 294 }
309 295
310 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed.
311 tracked_objects::ScopedTracker tracking_profile2(
312 FROM_HERE_WITH_EXPLICIT_FUNCTION(
313 "436634 TransportConnectJob::DoTransportConnect2"));
314
315 int rv = transport_socket_->Connect(helper_.on_io_complete()); 296 int rv = transport_socket_->Connect(helper_.on_io_complete());
316
317 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed.
318 tracked_objects::ScopedTracker tracking_profile3(
319 FROM_HERE_WITH_EXPLICIT_FUNCTION(
320 "436634 TransportConnectJob::DoTransportConnect3"));
321
322 if (rv == ERR_IO_PENDING && try_ipv6_connect_with_ipv4_fallback) { 297 if (rv == ERR_IO_PENDING && try_ipv6_connect_with_ipv4_fallback) {
323 fallback_timer_.Start( 298 fallback_timer_.Start(
324 FROM_HERE, 299 FROM_HERE,
325 base::TimeDelta::FromMilliseconds( 300 base::TimeDelta::FromMilliseconds(
326 TransportConnectJobHelper::kIPv6FallbackTimerInMs), 301 TransportConnectJobHelper::kIPv6FallbackTimerInMs),
327 this, 302 this,
328 &TransportConnectJob::DoIPv6FallbackTransportConnect); 303 &TransportConnectJob::DoIPv6FallbackTransportConnect);
329 } 304 }
330 return rv; 305 return rv;
331 } 306 }
332 307
333 int TransportConnectJob::DoTransportConnectComplete(int result) { 308 int TransportConnectJob::DoTransportConnectComplete(int result) {
334 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed.
335 tracked_objects::ScopedTracker tracking_profile(
336 FROM_HERE_WITH_EXPLICIT_FUNCTION(
337 "436634 TransportConnectJob::DoTransportConnectComplete"));
338
339 if (result == OK) { 309 if (result == OK) {
340 bool is_ipv4 = 310 bool is_ipv4 =
341 helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV4; 311 helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV4;
342 TransportConnectJobHelper::ConnectionLatencyHistogram race_result = 312 TransportConnectJobHelper::ConnectionLatencyHistogram race_result =
343 TransportConnectJobHelper::CONNECTION_LATENCY_UNKNOWN; 313 TransportConnectJobHelper::CONNECTION_LATENCY_UNKNOWN;
344 if (is_ipv4) { 314 if (is_ipv4) {
345 race_result = TransportConnectJobHelper::CONNECTION_LATENCY_IPV4_NO_RACE; 315 race_result = TransportConnectJobHelper::CONNECTION_LATENCY_IPV4_NO_RACE;
346 } else { 316 } else {
347 if (AddressListOnlyContainsIPv6(helper_.addresses())) { 317 if (AddressListOnlyContainsIPv6(helper_.addresses())) {
348 race_result = TransportConnectJobHelper::CONNECTION_LATENCY_IPV6_SOLO; 318 race_result = TransportConnectJobHelper::CONNECTION_LATENCY_IPV6_SOLO;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 HigherLayeredPool* higher_pool) { 563 HigherLayeredPool* higher_pool) {
594 base_.AddHigherLayeredPool(higher_pool); 564 base_.AddHigherLayeredPool(higher_pool);
595 } 565 }
596 566
597 void TransportClientSocketPool::RemoveHigherLayeredPool( 567 void TransportClientSocketPool::RemoveHigherLayeredPool(
598 HigherLayeredPool* higher_pool) { 568 HigherLayeredPool* higher_pool) {
599 base_.RemoveHigherLayeredPool(higher_pool); 569 base_.RemoveHigherLayeredPool(higher_pool);
600 } 570 }
601 571
602 } // namespace net 572 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/transport_client_socket_pool.h ('k') | net/socket/websocket_transport_client_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698