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> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
15 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
18 #include "net/base/socket_performance_watcher.h" | |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 | 21 |
21 TCPClientSocket::TCPClientSocket(const AddressList& addresses, | 22 TCPClientSocket::TCPClientSocket( |
22 net::NetLog* net_log, | 23 const AddressList& addresses, |
23 const net::NetLog::Source& source) | 24 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
24 : socket_(new TCPSocket(net_log, source)), | 25 net::NetLog* net_log, |
26 const net::NetLog::Source& source) | |
27 : socket_performance_watcher_(socket_performance_watcher.get()), | |
28 socket_(new TCPSocket(std::move(socket_performance_watcher), | |
29 net_log, | |
30 source)), | |
25 addresses_(addresses), | 31 addresses_(addresses), |
26 current_address_index_(-1), | 32 current_address_index_(-1), |
27 next_connect_state_(CONNECT_STATE_NONE), | 33 next_connect_state_(CONNECT_STATE_NONE), |
28 previously_disconnected_(false), | 34 previously_disconnected_(false), |
29 total_received_bytes_(0) {} | 35 total_received_bytes_(0) {} |
30 | 36 |
31 TCPClientSocket::TCPClientSocket(scoped_ptr<TCPSocket> connected_socket, | 37 TCPClientSocket::TCPClientSocket(scoped_ptr<TCPSocket> connected_socket, |
32 const IPEndPoint& peer_address) | 38 const IPEndPoint& peer_address) |
33 : socket_(std::move(connected_socket)), | 39 : socket_(std::move(connected_socket)), |
34 addresses_(AddressList(peer_address)), | 40 addresses_(AddressList(peer_address)), |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 } | 120 } |
115 } while (rv != ERR_IO_PENDING && next_connect_state_ != CONNECT_STATE_NONE); | 121 } while (rv != ERR_IO_PENDING && next_connect_state_ != CONNECT_STATE_NONE); |
116 | 122 |
117 return rv; | 123 return rv; |
118 } | 124 } |
119 | 125 |
120 int TCPClientSocket::DoConnect() { | 126 int TCPClientSocket::DoConnect() { |
121 DCHECK_GE(current_address_index_, 0); | 127 DCHECK_GE(current_address_index_, 0); |
122 DCHECK_LT(current_address_index_, static_cast<int>(addresses_.size())); | 128 DCHECK_LT(current_address_index_, static_cast<int>(addresses_.size())); |
123 | 129 |
130 if (socket_performance_watcher_) | |
131 socket_performance_watcher_->OnReset(); | |
bengr
2016/02/16 16:41:17
Does this mean you reset on the first connect?
tbansal1
2016/02/17 02:53:34
Yes.
| |
132 | |
124 const IPEndPoint& endpoint = addresses_[current_address_index_]; | 133 const IPEndPoint& endpoint = addresses_[current_address_index_]; |
125 | 134 |
126 { | 135 { |
127 // TODO(ricea): Remove ScopedTracker below once crbug.com/436634 is fixed. | 136 // TODO(ricea): Remove ScopedTracker below once crbug.com/436634 is fixed. |
128 tracked_objects::ScopedTracker tracking_profile( | 137 tracked_objects::ScopedTracker tracking_profile( |
129 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 TCPClientSocket::DoConnect")); | 138 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 TCPClientSocket::DoConnect")); |
130 | 139 |
131 if (previously_disconnected_) { | 140 if (previously_disconnected_) { |
132 use_history_.Reset(); | 141 use_history_.Reset(); |
133 connection_attempts_.clear(); | 142 connection_attempts_.clear(); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 void TCPClientSocket::EmitTCPMetricsHistogramsOnDisconnect() { | 389 void TCPClientSocket::EmitTCPMetricsHistogramsOnDisconnect() { |
381 base::TimeDelta rtt; | 390 base::TimeDelta rtt; |
382 if (socket_->GetEstimatedRoundTripTime(&rtt)) { | 391 if (socket_->GetEstimatedRoundTripTime(&rtt)) { |
383 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TcpRtt.AtDisconnect", rtt, | 392 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TcpRtt.AtDisconnect", rtt, |
384 base::TimeDelta::FromMilliseconds(1), | 393 base::TimeDelta::FromMilliseconds(1), |
385 base::TimeDelta::FromMinutes(10), 100); | 394 base::TimeDelta::FromMinutes(10), 100); |
386 } | 395 } |
387 } | 396 } |
388 | 397 |
389 } // namespace net | 398 } // namespace net |
OLD | NEW |