summaryrefslogtreecommitdiffstats
path: root/net/socket/client_socket_pool_base_unittest.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-02 16:09:01 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-02 16:09:01 +0000
commit0f873e8291deea212112dc7d6b48b0f0450522c2 (patch)
treed888b57c8ff0e55d322e450d9df2d1f5eb36d283 /net/socket/client_socket_pool_base_unittest.cc
parenteb7ce94497639ec1e9a7a1549dc941d8e28e98ba (diff)
downloadchromium_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/client_socket_pool_base_unittest.cc')
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 006d4e81..b196168 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -42,7 +42,7 @@ typedef ClientSocketPoolBase<TestSocketParams> TestClientSocketPoolBase;
class MockClientSocket : public ClientSocket {
public:
- MockClientSocket() : connected_(false) {}
+ MockClientSocket() : connected_(false), was_used_to_convey_data_(false) {}
// Socket methods:
virtual int Read(
@@ -51,8 +51,9 @@ class MockClientSocket : public ClientSocket {
}
virtual int Write(
- IOBuffer* /* buf */, int /* len */, CompletionCallback* /* callback */) {
- return ERR_UNEXPECTED;
+ IOBuffer* /* buf */, int len, CompletionCallback* /* callback */) {
+ was_used_to_convey_data_ = true;
+ return len;
}
virtual bool SetReceiveBufferSize(int32 size) { return true; }
virtual bool SetSendBufferSize(int32 size) { return true; }
@@ -78,10 +79,12 @@ class MockClientSocket : public ClientSocket {
virtual void SetSubresourceSpeculation() {}
virtual void SetOmniboxSpeculation() {}
+ virtual bool WasEverUsed() const { return was_used_to_convey_data_; }
private:
bool connected_;
BoundNetLog net_log_;
+ bool was_used_to_convey_data_;
DISALLOW_COPY_AND_ASSIGN(MockClientSocket);
};
@@ -1669,6 +1672,8 @@ TEST_F(ClientSocketPoolBaseTest, CleanupTimedOutIdleSockets) {
req.handle()->Reset();
EXPECT_EQ(OK, req2.WaitForResult());
+ // Use the socket.
+ EXPECT_EQ(1, req2.handle()->socket()->Write(NULL, 1, NULL));
req2.handle()->Reset();
// We post all of our delayed tasks with a 2ms delay. I.e. they don't