summaryrefslogtreecommitdiffstats
path: root/net/socket/tcp_client_socket_libevent.cc
diff options
context:
space:
mode:
authorgagansingh@google.com <gagansingh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 16:47:06 +0000
committergagansingh@google.com <gagansingh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 16:47:06 +0000
commit0ca76cb6e3d1ca12d55bab9900a8f0a650c6db09 (patch)
treef03dd8bc67014c738f70a1c1bb20f62af72902e6 /net/socket/tcp_client_socket_libevent.cc
parent591805d2915ce33ccd61eb624924f14f95b5c15d (diff)
downloadchromium_src-0ca76cb6e3d1ca12d55bab9900a8f0a650c6db09.zip
chromium_src-0ca76cb6e3d1ca12d55bab9900a8f0a650c6db09.tar.gz
chromium_src-0ca76cb6e3d1ca12d55bab9900a8f0a650c6db09.tar.bz2
Warmth of a connection (cwnd) is estimated by the amount of data written to the socket.
Choosing the warmest connection would mean faster resource load times. idle time is the time a socket has remained idle (no http requests being served on it). Probability of server resetting a connection increases with idle time duration. Using a cost function that takes into account bytes transferred and idle time to pick best connection to schedule http requests on. CODEREVIEW done in http://codereview.chromium.org/6990036/ Contributed by gagansingh@google.com Review URL: http://codereview.chromium.org/7189055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90373 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/tcp_client_socket_libevent.cc')
-rw-r--r--net/socket/tcp_client_socket_libevent.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index 38c3446..27c106c 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -137,7 +137,8 @@ TCPClientSocketLibevent::TCPClientSocketLibevent(
net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)),
previously_disconnected_(false),
use_tcp_fastopen_(false),
- tcp_fastopen_connected_(false) {
+ tcp_fastopen_connected_(false),
+ num_bytes_read_(0) {
scoped_refptr<NetLog::EventParameters> params;
if (source.is_valid())
params = new NetLogSourceParameter("source_dependency", source);
@@ -298,6 +299,7 @@ int TCPClientSocketLibevent::DoConnect() {
// Connect the socket.
if (!use_tcp_fastopen_) {
+ connect_start_time_ = base::TimeTicks::Now();
if (!HANDLE_EINTR(connect(socket_, current_ai_->ai_addr,
static_cast<int>(current_ai_->ai_addrlen)))) {
// Connected without waiting!
@@ -339,6 +341,7 @@ int TCPClientSocketLibevent::DoConnectComplete(int result) {
write_socket_watcher_.StopWatchingFileDescriptor();
if (result == OK) {
+ connect_time_micros_ = base::TimeTicks::Now() - connect_start_time_;
use_history_.set_was_ever_connected();
return OK; // Done!
}
@@ -440,6 +443,7 @@ int TCPClientSocketLibevent::Read(IOBuffer* buf,
if (nread >= 0) {
base::StatsCounter read_bytes("tcp.read_bytes");
read_bytes.Add(nread);
+ num_bytes_read_ += static_cast<int64>(nread);
if (nread > 0)
use_history_.set_was_used_to_convey_data();
net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, nread,
@@ -634,6 +638,7 @@ void TCPClientSocketLibevent::DidCompleteRead() {
result = bytes_transferred;
base::StatsCounter read_bytes("tcp.read_bytes");
read_bytes.Add(bytes_transferred);
+ num_bytes_read_ += static_cast<int64>(bytes_transferred);
if (bytes_transferred > 0)
use_history_.set_was_used_to_convey_data();
net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, result,
@@ -723,4 +728,12 @@ bool TCPClientSocketLibevent::UsingTCPFastOpen() const {
return use_tcp_fastopen_;
}
+int64 TCPClientSocketLibevent::NumBytesRead() const {
+ return num_bytes_read_;
+}
+
+base::TimeDelta TCPClientSocketLibevent::GetConnectTimeMicros() const {
+ return connect_time_micros_;
+}
+
} // namespace net