| 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 <utility> |
| 8 |
| 7 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
| 11 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 12 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
| 13 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
| 14 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 15 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 16 | 18 |
| 17 namespace net { | 19 namespace net { |
| 18 | 20 |
| 19 TCPClientSocket::TCPClientSocket(const AddressList& addresses, | 21 TCPClientSocket::TCPClientSocket(const AddressList& addresses, |
| 20 net::NetLog* net_log, | 22 net::NetLog* net_log, |
| 21 const net::NetLog::Source& source) | 23 const net::NetLog::Source& source) |
| 22 : socket_(new TCPSocket(net_log, source)), | 24 : socket_(new TCPSocket(net_log, source)), |
| 23 addresses_(addresses), | 25 addresses_(addresses), |
| 24 current_address_index_(-1), | 26 current_address_index_(-1), |
| 25 next_connect_state_(CONNECT_STATE_NONE), | 27 next_connect_state_(CONNECT_STATE_NONE), |
| 26 previously_disconnected_(false), | 28 previously_disconnected_(false), |
| 27 total_received_bytes_(0) {} | 29 total_received_bytes_(0) {} |
| 28 | 30 |
| 29 TCPClientSocket::TCPClientSocket(scoped_ptr<TCPSocket> connected_socket, | 31 TCPClientSocket::TCPClientSocket(scoped_ptr<TCPSocket> connected_socket, |
| 30 const IPEndPoint& peer_address) | 32 const IPEndPoint& peer_address) |
| 31 : socket_(connected_socket.Pass()), | 33 : socket_(std::move(connected_socket)), |
| 32 addresses_(AddressList(peer_address)), | 34 addresses_(AddressList(peer_address)), |
| 33 current_address_index_(0), | 35 current_address_index_(0), |
| 34 next_connect_state_(CONNECT_STATE_NONE), | 36 next_connect_state_(CONNECT_STATE_NONE), |
| 35 previously_disconnected_(false), | 37 previously_disconnected_(false), |
| 36 total_received_bytes_(0) { | 38 total_received_bytes_(0) { |
| 37 DCHECK(socket_); | 39 DCHECK(socket_); |
| 38 | 40 |
| 39 socket_->SetDefaultOptionsForClient(); | 41 socket_->SetDefaultOptionsForClient(); |
| 40 use_history_.set_was_ever_connected(); | 42 use_history_.set_was_ever_connected(); |
| 41 } | 43 } |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 void TCPClientSocket::EmitTCPMetricsHistogramsOnDisconnect() { | 380 void TCPClientSocket::EmitTCPMetricsHistogramsOnDisconnect() { |
| 379 base::TimeDelta rtt; | 381 base::TimeDelta rtt; |
| 380 if (socket_->GetEstimatedRoundTripTime(&rtt)) { | 382 if (socket_->GetEstimatedRoundTripTime(&rtt)) { |
| 381 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TcpRtt.AtDisconnect", rtt, | 383 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TcpRtt.AtDisconnect", rtt, |
| 382 base::TimeDelta::FromMilliseconds(1), | 384 base::TimeDelta::FromMilliseconds(1), |
| 383 base::TimeDelta::FromMinutes(10), 100); | 385 base::TimeDelta::FromMinutes(10), 100); |
| 384 } | 386 } |
| 385 } | 387 } |
| 386 | 388 |
| 387 } // namespace net | 389 } // namespace net |
| OLD | NEW |