OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/tcp_client_socket.h" | 5 #include "net/socket/tcp_client_socket.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
13 #include "net/base/ip_endpoint.h" | 13 #include "net/base/ip_endpoint.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
| 16 #include "net/base/socket_performance_watcher.h" |
16 | 17 |
17 namespace net { | 18 namespace net { |
18 | 19 |
19 TCPClientSocket::TCPClientSocket(const AddressList& addresses, | 20 TCPClientSocket::TCPClientSocket( |
20 net::NetLog* net_log, | 21 const AddressList& addresses, |
21 const net::NetLog::Source& source) | 22 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
22 : socket_(new TCPSocket(net_log, source)), | 23 net::NetLog* net_log, |
| 24 const net::NetLog::Source& source) |
| 25 : socket_( |
| 26 new TCPSocket(socket_performance_watcher.Pass(), net_log, source)), |
23 addresses_(addresses), | 27 addresses_(addresses), |
24 current_address_index_(-1), | 28 current_address_index_(-1), |
25 next_connect_state_(CONNECT_STATE_NONE), | 29 next_connect_state_(CONNECT_STATE_NONE), |
26 previously_disconnected_(false) { | 30 previously_disconnected_(false) {} |
27 } | |
28 | 31 |
29 TCPClientSocket::TCPClientSocket(scoped_ptr<TCPSocket> connected_socket, | 32 TCPClientSocket::TCPClientSocket(scoped_ptr<TCPSocket> connected_socket, |
30 const IPEndPoint& peer_address) | 33 const IPEndPoint& peer_address) |
31 : socket_(connected_socket.Pass()), | 34 : socket_(connected_socket.Pass()), |
32 addresses_(AddressList(peer_address)), | 35 addresses_(AddressList(peer_address)), |
33 current_address_index_(0), | 36 current_address_index_(0), |
34 next_connect_state_(CONNECT_STATE_NONE), | 37 next_connect_state_(CONNECT_STATE_NONE), |
35 previously_disconnected_(false) { | 38 previously_disconnected_(false) { |
36 DCHECK(socket_); | 39 DCHECK(socket_); |
37 | 40 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 void TCPClientSocket::EmitTCPMetricsHistogramsOnDisconnect() { | 360 void TCPClientSocket::EmitTCPMetricsHistogramsOnDisconnect() { |
358 base::TimeDelta rtt; | 361 base::TimeDelta rtt; |
359 if (socket_->GetEstimatedRoundTripTime(&rtt)) { | 362 if (socket_->GetEstimatedRoundTripTime(&rtt)) { |
360 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TcpRtt.AtDisconnect", rtt, | 363 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TcpRtt.AtDisconnect", rtt, |
361 base::TimeDelta::FromMilliseconds(1), | 364 base::TimeDelta::FromMilliseconds(1), |
362 base::TimeDelta::FromMinutes(10), 100); | 365 base::TimeDelta::FromMinutes(10), 100); |
363 } | 366 } |
364 } | 367 } |
365 | 368 |
366 } // namespace net | 369 } // namespace net |
OLD | NEW |