Chromium Code Reviews| Index: net/socket/tcp_client_socket.cc |
| diff --git a/net/socket/tcp_client_socket.cc b/net/socket/tcp_client_socket.cc |
| index a1c1fadb85e2b8ba0d01c600c760536f7e206eeb..6ab5da7e7ed29c46303fdbec69cb7639cf684fce 100644 |
| --- a/net/socket/tcp_client_socket.cc |
| +++ b/net/socket/tcp_client_socket.cc |
| @@ -6,7 +6,9 @@ |
| #include "base/callback_helpers.h" |
| #include "base/logging.h" |
| +#include "base/metrics/histogram_macros.h" |
| #include "base/profiler/scoped_tracker.h" |
| +#include "base/time/time.h" |
| #include "net/base/io_buffer.h" |
| #include "net/base/ip_endpoint.h" |
| #include "net/base/net_errors.h" |
| @@ -38,6 +40,7 @@ TCPClientSocket::TCPClientSocket(scoped_ptr<TCPSocket> connected_socket, |
| } |
| TCPClientSocket::~TCPClientSocket() { |
| + EmitTCPMetricsHistogramsOnSocketClose(); |
| } |
| int TCPClientSocket::Bind(const IPEndPoint& address) { |
| @@ -178,6 +181,7 @@ int TCPClientSocket::DoConnectComplete(int result) { |
| } |
| void TCPClientSocket::Disconnect() { |
| + EmitTCPMetricsHistogramsOnSocketClose(); |
|
mmenke
2015/07/07 19:53:49
Suggest a couple things:
1) Rename this to EmitTC
Bryan McQuade
2015/07/07 21:03:32
I changed to EmitTCPMetricsHistogramsOnDisconnect.
|
| DoDisconnect(); |
| current_address_index_ = -1; |
| bind_address_.reset(); |
| @@ -350,4 +354,16 @@ int TCPClientSocket::OpenSocket(AddressFamily family) { |
| return OK; |
| } |
| +void TCPClientSocket::EmitTCPMetricsHistogramsOnSocketClose() { |
| + if (previously_disconnected_) { |
|
Alexei Svitkine (slow)
2015/07/07 18:50:56
Nit: No {}'s for 1-line bodies.
Bryan McQuade
2015/07/07 19:35:13
Done.
mmenke
2015/07/07 19:53:49
Is this needed? Seems weird to exclude the second
Bryan McQuade
2015/07/07 21:03:32
Removed.
|
| + return; |
| + } |
| + base::TimeDelta rtt; |
| + if (socket_ && socket_->GetEstimatedRoundTripTime(&rtt)) { |
|
mmenke
2015/07/07 19:53:49
socket_ can't be NULL (It's set to a non-NULL valu
Bryan McQuade
2015/07/07 21:03:32
Done.
|
| + UMA_HISTOGRAM_CUSTOM_TIMES("Net.TcpRttAtSocketClose", rtt, |
|
Alexei Svitkine (slow)
2015/07/07 18:50:56
Nit: Optional suggestion:
Rename to Net.TcpRtt.At
Bryan McQuade
2015/07/07 19:35:13
Great suggestion, thanks! Done.
|
| + base::TimeDelta::FromMilliseconds(1), |
| + base::TimeDelta::FromMinutes(10), 100); |
|
Alexei Svitkine (slow)
2015/07/07 18:50:56
Nit: Why do you need 100 buckets instead of the us
Bryan McQuade
2015/07/07 19:35:13
I chose this bucketing strategy to match the simil
|
| + } |
| +} |
| + |
| } // namespace net |