Index: net/socket/tcp_socket_posix.cc |
diff --git a/net/socket/tcp_socket_posix.cc b/net/socket/tcp_socket_posix.cc |
index 0546e6075a57e7663640ac93993b8fa71f1cd3e4..f4275d095d52621277f2d5b849d20b7bbcd0d473 100644 |
--- a/net/socket/tcp_socket_posix.cc |
+++ b/net/socket/tcp_socket_posix.cc |
@@ -146,8 +146,12 @@ void CheckSupportAndMaybeEnableTCPFastOpen(bool user_enabled) { |
#endif |
} |
-TCPSocketPosix::TCPSocketPosix(NetLog* net_log, const NetLog::Source& source) |
- : use_tcp_fastopen_(false), |
+TCPSocketPosix::TCPSocketPosix( |
+ scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
+ NetLog* net_log, |
+ const NetLog::Source& source) |
+ : socket_performance_watcher_(std::move(socket_performance_watcher)), |
+ use_tcp_fastopen_(false), |
tcp_fastopen_write_attempted_(false), |
tcp_fastopen_connected_(false), |
tcp_fastopen_status_(TCP_FASTOPEN_STATUS_UNKNOWN), |
@@ -524,7 +528,8 @@ int TCPSocketPosix::BuildTcpSocketPosix(scoped_ptr<TCPSocketPosix>* tcp_socket, |
return ERR_ADDRESS_INVALID; |
} |
- tcp_socket->reset(new TCPSocketPosix(net_log_.net_log(), net_log_.source())); |
+ tcp_socket->reset( |
+ new TCPSocketPosix(nullptr, net_log_.net_log(), net_log_.source())); |
(*tcp_socket)->socket_.reset(accept_socket_.release()); |
return OK; |
} |
@@ -532,6 +537,7 @@ int TCPSocketPosix::BuildTcpSocketPosix(scoped_ptr<TCPSocketPosix>* tcp_socket, |
void TCPSocketPosix::ConnectCompleted(const CompletionCallback& callback, |
int rv) const { |
DCHECK_NE(ERR_IO_PENDING, rv); |
+ NotifySocketPerformanceWatcher(); |
callback.Run(HandleConnectCompleted(rv)); |
} |
@@ -585,6 +591,7 @@ void TCPSocketPosix::ReadCompleted(const scoped_refptr<IOBuffer>& buf, |
const CompletionCallback& callback, |
int rv) { |
DCHECK_NE(ERR_IO_PENDING, rv); |
+ NotifySocketPerformanceWatcher(); |
callback.Run(HandleReadCompleted(buf.get(), rv)); |
} |
@@ -622,6 +629,7 @@ void TCPSocketPosix::WriteCompleted(const scoped_refptr<IOBuffer>& buf, |
const CompletionCallback& callback, |
int rv) { |
DCHECK_NE(ERR_IO_PENDING, rv); |
+ NotifySocketPerformanceWatcher(); |
callback.Run(HandleWriteCompleted(buf.get(), rv)); |
} |
@@ -709,6 +717,21 @@ int TCPSocketPosix::TcpFastOpenWrite(IOBuffer* buf, |
return socket_->WaitForWrite(buf, buf_len, callback); |
} |
+void TCPSocketPosix::NotifySocketPerformanceWatcher() const { |
+#if defined(TCP_INFO) |
+ if (!socket_performance_watcher_) |
+ return; |
+ |
+ tcp_info info; |
+ bool getsockopt_success = GetTcpInfo(socket_->socket_fd(), &info); |
+ if (!getsockopt_success) |
+ return; |
+ |
+ socket_performance_watcher_->OnUpdatedRTTAvailable( |
+ base::TimeDelta::FromMicroseconds(info.tcpi_rtt)); |
bengr
2016/02/08 18:51:14
#include "base/time/time.h"
Also, is tcpi_rtt gua
tbansal1
2016/02/08 21:33:26
It is already there in the .tcp_socket_posix.h fil
bengr
2016/02/08 23:42:06
Actually, isn't 0 a valid RTT? Perhaps leave it th
tbansal1
2016/02/09 17:11:22
Probably not. If RTT computed after doing EWMA is
|
+#endif // defined(TCP_INFO) |
+} |
+ |
void TCPSocketPosix::UpdateTCPFastOpenStatusAfterRead() { |
DCHECK(tcp_fastopen_status_ == TCP_FASTOPEN_FAST_CONNECT_RETURN || |
tcp_fastopen_status_ == TCP_FASTOPEN_SLOW_CONNECT_RETURN); |