Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: net/socket/client_socket_pool_base_unittest.cc

Issue 12886034: Remove experimental code to pick the "warmest" socket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync, fix conflict Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/socket_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/client_socket_pool_base_unittest.cc
===================================================================
--- net/socket/client_socket_pool_base_unittest.cc (revision 191149)
+++ net/socket/client_socket_pool_base_unittest.cc (working copy)
@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
-#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
@@ -119,16 +118,14 @@
explicit MockClientSocket(net::NetLog* net_log)
: connected_(false),
net_log_(BoundNetLog::Make(net_log, net::NetLog::SOURCE_SOCKET)),
- was_used_to_convey_data_(false),
- num_bytes_read_(0) {
+ was_used_to_convey_data_(false) {
}
// Socket implementation.
virtual int Read(
IOBuffer* /* buf */, int len,
const CompletionCallback& /* callback */) OVERRIDE {
- num_bytes_read_ += len;
- return len;
+ return ERR_UNEXPECTED;
}
virtual int Write(
@@ -165,15 +162,9 @@
virtual void SetSubresourceSpeculation() OVERRIDE {}
virtual void SetOmniboxSpeculation() OVERRIDE {}
virtual bool WasEverUsed() const OVERRIDE {
- return was_used_to_convey_data_ || num_bytes_read_ > 0;
+ return was_used_to_convey_data_;
}
virtual bool UsingTCPFastOpen() const OVERRIDE { return false; }
- virtual int64 NumBytesRead() const OVERRIDE { return num_bytes_read_; }
- virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE {
- static const base::TimeDelta kDummyConnectTimeMicros =
- base::TimeDelta::FromMicroseconds(10);
- return kDummyConnectTimeMicros; // Dummy value.
- }
virtual bool WasNpnNegotiated() const OVERRIDE {
return false;
}
@@ -188,7 +179,6 @@
bool connected_;
BoundNetLog net_log_;
bool was_used_to_convey_data_;
- int num_bytes_read_;
DISALLOW_COPY_AND_ASSIGN(MockClientSocket);
};
@@ -745,71 +735,6 @@
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, CompletionCallback());
- }
-
- 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, CompletionCallback());
- }
-
- 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) {
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/socket_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698