diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-02 16:09:01 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-02 16:09:01 +0000 |
commit | 0f873e8291deea212112dc7d6b48b0f0450522c2 (patch) | |
tree | d888b57c8ff0e55d322e450d9df2d1f5eb36d283 /net/socket/socket_test_util.cc | |
parent | eb7ce94497639ec1e9a7a1549dc941d8e28e98ba (diff) | |
download | chromium_src-0f873e8291deea212112dc7d6b48b0f0450522c2.zip chromium_src-0f873e8291deea212112dc7d6b48b0f0450522c2.tar.gz chromium_src-0f873e8291deea212112dc7d6b48b0f0450522c2.tar.bz2 |
Fix ClientSocketHandle reuse_type(). Correctly track socket use.
In particular, we used to consider that a socket had been used whenever it got returned to the ClientSocketPool. But, with preconnect, that is no longer true. Luckily, we now have UseHistory in the transport sockets. So, I create a WasEverUsed() method in ClientSocket, plumb this into all sockets, and use that in ClientSocketPoolBaseHelper instead of tracking whether or not the socket had been returned to the client or not.
This ultimately will have two implications. We will record the correct values in Net.HttpSocketType histograms and we will use the correct timeout for preconnect sockets in ClientSocketPoolBaseHelper::CleanupIdleSockets().
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3353004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/socket_test_util.cc')
-rw-r--r-- | net/socket/socket_test_util.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc index bd47f7c..440c790 100644 --- a/net/socket/socket_test_util.cc +++ b/net/socket/socket_test_util.cc @@ -178,7 +178,8 @@ MockTCPClientSocket::MockTCPClientSocket(const net::AddressList& addresses, peer_closed_connection_(false), pending_buf_(NULL), pending_buf_len_(0), - pending_callback_(NULL) { + pending_callback_(NULL), + was_used_to_convey_data_(false) { DCHECK(data_); data_->Reset(); } @@ -248,10 +249,13 @@ int MockTCPClientSocket::Write(net::IOBuffer* buf, int buf_len, std::string data(buf->data(), buf_len); net::MockWriteResult write_result = data_->OnWrite(data); + was_used_to_convey_data_ = true; + if (write_result.async) { RunCallbackAsync(callback, write_result.result); return net::ERR_IO_PENDING; } + return write_result.result; } @@ -279,6 +283,8 @@ int MockTCPClientSocket::CompleteRead() { DCHECK(pending_buf_); DCHECK(pending_buf_len_ > 0); + was_used_to_convey_data_ = true; + // Save the pending async IO data and reset our |pending_| state. net::IOBuffer* buf = pending_buf_; int buf_len = pending_buf_len_; @@ -323,7 +329,8 @@ DeterministicMockTCPClientSocket::DeterministicMockTCPClientSocket( read_buf_len_(0), read_pending_(false), read_callback_(NULL), - data_(data) {} + data_(data), + was_used_to_convey_data_(false) {} void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {} @@ -366,6 +373,8 @@ int DeterministicMockTCPClientSocket::Write( write_pending_ = true; return net::ERR_IO_PENDING; } + + was_used_to_convey_data_ = true; write_pending_ = false; return write_result.result; } @@ -390,10 +399,12 @@ int DeterministicMockTCPClientSocket::Read( return ERR_IO_PENDING; } + was_used_to_convey_data_ = true; return CompleteRead(); } void DeterministicMockTCPClientSocket::CompleteWrite(){ + was_used_to_convey_data_ = true; write_pending_ = false; write_callback_->Run(write_result_); } @@ -403,6 +414,8 @@ int DeterministicMockTCPClientSocket::CompleteRead() { DCHECK_LE(read_data_.data_len, read_buf_len_); DCHECK(read_buf_); + was_used_to_convey_data_ = true; + if (read_data_.result == ERR_IO_PENDING) read_data_ = data_->GetNextRead(); DCHECK_NE(ERR_IO_PENDING, read_data_.result); @@ -497,6 +510,10 @@ bool MockSSLClientSocket::IsConnected() const { return transport_->socket()->IsConnected(); } +bool MockSSLClientSocket::WasEverUsed() const { + return transport_->socket()->WasEverUsed(); +} + int MockSSLClientSocket::Read(net::IOBuffer* buf, int buf_len, net::CompletionCallback* callback) { return transport_->socket()->Read(buf, buf_len, callback); |