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

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

Issue 1215543003: Add UMA for the kernel's TCP RTT estimate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 5 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) 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/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
11 #include "base/time/time.h"
10 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
11 #include "net/base/ip_endpoint.h" 13 #include "net/base/ip_endpoint.h"
12 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
13 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
14 16
15 namespace net { 17 namespace net {
16 18
17 TCPClientSocket::TCPClientSocket(const AddressList& addresses, 19 TCPClientSocket::TCPClientSocket(const AddressList& addresses,
18 net::NetLog* net_log, 20 net::NetLog* net_log,
19 const net::NetLog::Source& source) 21 const net::NetLog::Source& source)
(...skipping 11 matching lines...) Expand all
31 current_address_index_(0), 33 current_address_index_(0),
32 next_connect_state_(CONNECT_STATE_NONE), 34 next_connect_state_(CONNECT_STATE_NONE),
33 previously_disconnected_(false) { 35 previously_disconnected_(false) {
34 DCHECK(socket_); 36 DCHECK(socket_);
35 37
36 socket_->SetDefaultOptionsForClient(); 38 socket_->SetDefaultOptionsForClient();
37 use_history_.set_was_ever_connected(); 39 use_history_.set_was_ever_connected();
38 } 40 }
39 41
40 TCPClientSocket::~TCPClientSocket() { 42 TCPClientSocket::~TCPClientSocket() {
43 Disconnect();
41 } 44 }
42 45
43 int TCPClientSocket::Bind(const IPEndPoint& address) { 46 int TCPClientSocket::Bind(const IPEndPoint& address) {
44 if (current_address_index_ >= 0 || bind_address_) { 47 if (current_address_index_ >= 0 || bind_address_) {
45 // Cannot bind the socket if we are already connected or connecting. 48 // Cannot bind the socket if we are already connected or connecting.
46 NOTREACHED(); 49 NOTREACHED();
47 return ERR_UNEXPECTED; 50 return ERR_UNEXPECTED;
48 } 51 }
49 52
50 int result = OK; 53 int result = OK;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return result; 180 return result;
178 } 181 }
179 182
180 void TCPClientSocket::Disconnect() { 183 void TCPClientSocket::Disconnect() {
181 DoDisconnect(); 184 DoDisconnect();
182 current_address_index_ = -1; 185 current_address_index_ = -1;
183 bind_address_.reset(); 186 bind_address_.reset();
184 } 187 }
185 188
186 void TCPClientSocket::DoDisconnect() { 189 void TCPClientSocket::DoDisconnect() {
190 EmitTCPMetricsHistogramsOnDisconnect();
187 // If connecting or already connected, record that the socket has been 191 // If connecting or already connected, record that the socket has been
188 // disconnected. 192 // disconnected.
189 previously_disconnected_ = socket_->IsValid() && current_address_index_ >= 0; 193 previously_disconnected_ = socket_->IsValid() && current_address_index_ >= 0;
190 socket_->Close(); 194 socket_->Close();
191 } 195 }
192 196
193 bool TCPClientSocket::IsConnected() const { 197 bool TCPClientSocket::IsConnected() const {
194 return socket_->IsConnected(); 198 return socket_->IsConnected();
195 } 199 }
196 200
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 347
344 int result = socket_->Open(family); 348 int result = socket_->Open(family);
345 if (result != OK) 349 if (result != OK)
346 return result; 350 return result;
347 351
348 socket_->SetDefaultOptionsForClient(); 352 socket_->SetDefaultOptionsForClient();
349 353
350 return OK; 354 return OK;
351 } 355 }
352 356
357 void TCPClientSocket::EmitTCPMetricsHistogramsOnDisconnect() {
358 base::TimeDelta rtt;
359 if (socket_->GetEstimatedRoundTripTime(&rtt)) {
360 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TcpRtt.AtDisconnect", rtt,
361 base::TimeDelta::FromMilliseconds(1),
362 base::TimeDelta::FromMinutes(10), 100);
363 }
364 }
365
353 } // namespace net 366 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698