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

Unified Diff: net/socket/tcp_socket_posix.cc

Issue 1376473003: Notify NQE of TCP RTT values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: net/socket/tcp_socket_posix.cc
diff --git a/net/socket/tcp_socket_posix.cc b/net/socket/tcp_socket_posix.cc
index 653eb82445d658160067f0aea06bca0b75a9fc7c..b0e161fd0ba8ee1dab99546d17e825fb6897173a 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_(socket_performance_watcher.Pass()),
+ use_tcp_fastopen_(false),
tcp_fastopen_write_attempted_(false),
tcp_fastopen_connected_(false),
tcp_fastopen_status_(TCP_FASTOPEN_STATUS_UNKNOWN),
@@ -520,7 +524,9 @@ 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(/*socket_performance_watcher_factory=*/nullptr,
+ net_log_.net_log(), net_log_.source()));
(*tcp_socket)->socket_.reset(accept_socket_.release());
return OK;
}
@@ -528,6 +534,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));
}
@@ -581,6 +588,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));
}
@@ -618,6 +626,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));
}
@@ -705,6 +714,22 @@ int TCPSocketPosix::TcpFastOpenWrite(IOBuffer* buf,
return socket_->WaitForWrite(buf, buf_len, callback);
}
+void TCPSocketPosix::NotifySocketPerformanceWatcher() const {
+ if (!socket_performance_watcher_)
Ryan Sleevi 2015/10/20 00:10:36 Is there a reason not to wrap the entire method bo
tbansal1 2016/02/05 19:44:15 Done, I did not think of the optimization.
+ return;
+
+ bool getsockopt_success = false;
Ryan Sleevi 2015/10/20 00:10:36 I'd expect this will result in a compiler warning
tbansal1 2016/02/05 19:44:15 Obsolete.
+#if defined(TCP_INFO)
+ tcp_info info;
+ getsockopt_success = GetTcpInfo(socket_->socket_fd(), &info);
+ if (!getsockopt_success)
+ return;
+
+ socket_performance_watcher_->OnUpdatedRTTAvailable(
+ base::TimeDelta::FromMicroseconds(info.tcpi_rtt));
+#endif // defined(TCP_INFO)
+}
+
void TCPSocketPosix::UpdateTCPFastOpenStatusAfterRead() {
DCHECK(tcp_fastopen_status_ == TCP_FASTOPEN_FAST_CONNECT_RETURN ||
tcp_fastopen_status_ == TCP_FASTOPEN_SLOW_CONNECT_RETURN);

Powered by Google App Engine
This is Rietveld 408576698