diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 20:29:45 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 20:29:45 +0000 |
commit | 9b5614aec311bc0d04416b1fa279e496cca84714 (patch) | |
tree | ef89c857a897d45a8540aa0a84252a4a9329b83a /net/socket/tcp_client_socket_libevent.cc | |
parent | 4055f9a6cd7de30e99288aa1f51b42276a93e705 (diff) | |
download | chromium_src-9b5614aec311bc0d04416b1fa279e496cca84714.zip chromium_src-9b5614aec311bc0d04416b1fa279e496cca84714.tar.gz chromium_src-9b5614aec311bc0d04416b1fa279e496cca84714.tar.bz2 |
Gather preconnection use vs waste statistics
I now gather statistics only in the transport socket
classes TcpClientSocket*. All other socket classes
forward significant data (that they are used in
a speculation) to their transport class, where
this data is stored, and then dumped when the
TCP socket is closed.
This CL also repaired a slight miscount in bytes
read and written on Windows, as error codes
were mistakenly accumulated as byte counts.
This CL repaired a significant undercounting
in linux/mac via StatsCounter (the logging counter
appears correct).
Libjingle support is minimal (NOTREACHED), but
I don't know that there are subresources that will
be speculatively preconnected from that class (and
it is less obvious how the class uses underlying
sockets, if at all).
BUG=42694
r=willchan
Review URL: http://codereview.chromium.org/3163033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57377 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/tcp_client_socket_libevent.cc')
-rw-r--r-- | net/socket/tcp_client_socket_libevent.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc index 55c4190..a63528b 100644 --- a/net/socket/tcp_client_socket_libevent.cc +++ b/net/socket/tcp_client_socket_libevent.cc @@ -233,8 +233,10 @@ int TCPClientSocketLibevent::DoConnectComplete(int result) { write_socket_watcher_.StopWatchingFileDescriptor(); - if (result == OK) + if (result == OK) { + use_history_.set_was_ever_connected(); return OK; // Done! + } // Close whatever partially connected socket we currently have. DoDisconnect(); @@ -320,7 +322,8 @@ int TCPClientSocketLibevent::Read(IOBuffer* buf, if (nread >= 0) { static StatsCounter read_bytes("tcp.read_bytes"); read_bytes.Add(nread); - + if (nread > 0) + use_history_.set_was_used_to_convey_data(); net_log_.AddEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, new NetLogIntegerParameter("num_bytes", nread)); return nread; @@ -358,6 +361,8 @@ int TCPClientSocketLibevent::Write(IOBuffer* buf, if (nwrite >= 0) { static StatsCounter write_bytes("tcp.write_bytes"); write_bytes.Add(nwrite); + if (nwrite > 0) + use_history_.set_was_used_to_convey_data(); net_log_.AddEvent(NetLog::TYPE_SOCKET_BYTES_SENT, new NetLogIntegerParameter("num_bytes", nwrite)); return nwrite; @@ -474,6 +479,10 @@ void TCPClientSocketLibevent::DidCompleteRead() { int result; if (bytes_transferred >= 0) { result = bytes_transferred; + static StatsCounter read_bytes("tcp.read_bytes"); + read_bytes.Add(bytes_transferred); + if (bytes_transferred > 0) + use_history_.set_was_used_to_convey_data(); net_log_.AddEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, new NetLogIntegerParameter("num_bytes", result)); } else { @@ -497,6 +506,10 @@ void TCPClientSocketLibevent::DidCompleteWrite() { int result; if (bytes_transferred >= 0) { result = bytes_transferred; + static StatsCounter write_bytes("tcp.write_bytes"); + write_bytes.Add(bytes_transferred); + if (bytes_transferred > 0) + use_history_.set_was_used_to_convey_data(); net_log_.AddEvent(NetLog::TYPE_SOCKET_BYTES_SENT, new NetLogIntegerParameter("num_bytes", result)); } else { @@ -520,4 +533,12 @@ int TCPClientSocketLibevent::GetPeerAddress(AddressList* address) const { return OK; } +void TCPClientSocketLibevent::SetSubresourceSpeculation() { + use_history_.set_subresource_speculation(); +} + +void TCPClientSocketLibevent::SetOmniboxSpeculation() { + use_history_.set_subresource_speculation(); +} + } // namespace net |