summaryrefslogtreecommitdiffstats
path: root/net/socket/client_socket_pool_base_unittest.cc
diff options
context:
space:
mode:
authordimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 18:21:37 +0000
committerdimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 18:21:37 +0000
commitea678b000451e01b4dec557132f34deaa15eac1f (patch)
tree8f3d2505710dc34ebc26143b6c15f3292b03a8c7 /net/socket/client_socket_pool_base_unittest.cc
parentc6ce4f6569569fb21745b698adc9ce4abb132980 (diff)
downloadchromium_src-ea678b000451e01b4dec557132f34deaa15eac1f.zip
chromium_src-ea678b000451e01b4dec557132f34deaa15eac1f.tar.gz
chromium_src-ea678b000451e01b4dec557132f34deaa15eac1f.tar.bz2
Revert 90373 - 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. Caused layout tests http/tests/loading/redirect-methods.html and http/tests/security/xss-DENIED-iframe-src-alias.html fail on deps WebKit bots, and caused http://code.google.com/p/chromium/issues/detail?id=87423 Deps bots failures: http://test-results.appspot.com/dashboards/flakiness_dashboard.html#group=%40ToT%20-%20chromium.org&tests=http%2Ftests%2Floading%2Fredirect-methods.html%2Chttp%2Ftests%2Fsecurity%2Fxss-DENIED-iframe-src-alias.html 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 TBR=gagansingh@google.com Review URL: http://codereview.chromium.org/7255002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90389 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.cc84
1 files changed, 4 insertions, 80 deletions
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 6cdbdd3..4864001 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -45,14 +45,12 @@ typedef ClientSocketPoolBase<TestSocketParams> TestClientSocketPoolBase;
class MockClientSocket : public StreamSocket {
public:
- MockClientSocket() : connected_(false), was_used_to_convey_data_(false),
- num_bytes_read_(0) {}
+ MockClientSocket() : connected_(false), was_used_to_convey_data_(false) {}
// Socket methods:
virtual int Read(
- IOBuffer* /* buf */, int len, CompletionCallback* /* callback */) {
- num_bytes_read_ += len;
- return len;
+ IOBuffer* /* buf */, int /* len */, CompletionCallback* /* callback */) {
+ return ERR_UNEXPECTED;
}
virtual int Write(
@@ -88,22 +86,13 @@ class MockClientSocket : public StreamSocket {
virtual void SetSubresourceSpeculation() {}
virtual void SetOmniboxSpeculation() {}
- virtual bool WasEverUsed() const {
- return was_used_to_convey_data_ || num_bytes_read_ > 0;
- }
+ virtual bool WasEverUsed() const { return was_used_to_convey_data_; }
virtual bool UsingTCPFastOpen() const { return false; }
- virtual int64 NumBytesRead() const { return num_bytes_read_; }
- virtual base::TimeDelta GetConnectTimeMicros() const {
- static const base::TimeDelta kDummyConnectTimeMicros =
- base::TimeDelta::FromMicroseconds(10);
- return kDummyConnectTimeMicros; // Dummy value.
- }
private:
bool connected_;
BoundNetLog net_log_;
bool was_used_to_convey_data_;
- int num_bytes_read_;
DISALLOW_COPY_AND_ASSIGN(MockClientSocket);
};
@@ -615,71 +604,6 @@ class ClientSocketPoolBaseTest : public testing::Test {
ClientSocketPoolTest test_base_;
};
-TEST_F(ClientSocketPoolBaseTest, AssignIdleSocketToGroup_WarmestSocket) {
- CreatePool(4, 4);
- net::SetSocketReusePolicy(0);
-
- EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
-
- std::map<int, StreamSocket*> sockets_;
- for (size_t i = 0; i < test_base_.requests_size(); i++) {
- TestSocketRequest* req = test_base_.request(i);
- StreamSocket* s = req->handle()->socket();
- MockClientSocket* sock = static_cast<MockClientSocket*>(s);
- CHECK(sock);
- sockets_[i] = sock;
- sock->Read(NULL, 1024 - i, NULL);
- }
-
- ReleaseAllConnections(ClientSocketPoolTest::KEEP_ALIVE);
-
- EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- TestSocketRequest* req = test_base_.request(test_base_.requests_size() - 1);
-
- // First socket is warmest.
- EXPECT_EQ(sockets_[0], req->handle()->socket());
-
- // Test that NumBytes are as expected.
- EXPECT_EQ(1024, sockets_[0]->NumBytesRead());
- EXPECT_EQ(1023, sockets_[1]->NumBytesRead());
- EXPECT_EQ(1022, sockets_[2]->NumBytesRead());
- EXPECT_EQ(1021, sockets_[3]->NumBytesRead());
-
- ReleaseAllConnections(ClientSocketPoolTest::NO_KEEP_ALIVE);
-}
-
-TEST_F(ClientSocketPoolBaseTest, AssignIdleSocketToGroup_LastAccessedSocket) {
- CreatePool(4, 4);
- net::SetSocketReusePolicy(2);
-
- EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
-
- std::map<int, StreamSocket*> sockets_;
- for (size_t i = 0; i < test_base_.requests_size(); i++) {
- TestSocketRequest* req = test_base_.request(i);
- StreamSocket* s = req->handle()->socket();
- MockClientSocket* sock = static_cast<MockClientSocket*>(s);
- CHECK(sock);
- sockets_[i] = sock;
- sock->Read(NULL, 1024 - i, NULL);
- }
-
- ReleaseAllConnections(ClientSocketPoolTest::KEEP_ALIVE);
-
- EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- TestSocketRequest* req = test_base_.request(test_base_.requests_size() - 1);
-
- // Last socket is most recently accessed.
- EXPECT_EQ(sockets_[3], req->handle()->socket());
- ReleaseAllConnections(ClientSocketPoolTest::NO_KEEP_ALIVE);
-}
-
// Even though a timeout is specified, it doesn't time out on a synchronous
// completion.
TEST_F(ClientSocketPoolBaseTest, ConnectJob_NoTimeoutOnSynchronousCompletion) {