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

Unified Diff: net/socket/client_socket_pool_base_unittest.cc

Issue 1091793002: Report the connect status of the oldest connection in the socket pool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed typo Created 5 years, 8 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') | no next file » | 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
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 391fb61e6d0557b28932f96059d13bf8db2b30ff..ecabdd163e2c9211956a286d6fedb761bc0490c7 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -1955,48 +1955,63 @@ TEST_F(ClientSocketPoolBaseTest, LoadStateOneRequest) {
}
// Test GetLoadState in the case there are two socket requests.
+// Only the first connection in the pool should affect the pool's load status.
TEST_F(ClientSocketPoolBaseTest, LoadStateTwoRequests) {
CreatePool(2, 2);
connect_job_factory_->set_job_type(TestConnectJob::kMockWaitingJob);
ClientSocketHandle handle;
TestCompletionCallback callback;
- int rv = handle.Init("a",
- params_,
- DEFAULT_PRIORITY,
- callback.callback(),
- pool_.get(),
- BoundNetLog());
+ int rv = handle.Init("a", params_, DEFAULT_PRIORITY, callback.callback(),
+ pool_.get(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
+ client_socket_factory_.SetJobLoadState(0, LOAD_STATE_RESOLVING_HOST);
ClientSocketHandle handle2;
TestCompletionCallback callback2;
- rv = handle2.Init("a",
- params_,
- DEFAULT_PRIORITY,
- callback2.callback(),
- pool_.get(),
- BoundNetLog());
+ rv = handle2.Init("a", params_, DEFAULT_PRIORITY, callback2.callback(),
+ pool_.get(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
+ client_socket_factory_.SetJobLoadState(1, LOAD_STATE_RESOLVING_HOST);
- // If the first Job is in an earlier state than the second, the state of
- // the second job should be used for both handles.
- client_socket_factory_.SetJobLoadState(0, LOAD_STATE_RESOLVING_HOST);
+ // Check that both handles report the state of the first job.
+ EXPECT_EQ(LOAD_STATE_RESOLVING_HOST, handle.GetLoadState());
+ EXPECT_EQ(LOAD_STATE_RESOLVING_HOST, handle2.GetLoadState());
+
+ client_socket_factory_.SetJobLoadState(0, LOAD_STATE_CONNECTING);
+
+ // Check that both handles change to LOAD_STATE_CONNECTING.
EXPECT_EQ(LOAD_STATE_CONNECTING, handle.GetLoadState());
EXPECT_EQ(LOAD_STATE_CONNECTING, handle2.GetLoadState());
+}
- // If the second Job is in an earlier state than the second, the state of
- // the first job should be used for both handles.
- client_socket_factory_.SetJobLoadState(0, LOAD_STATE_SSL_HANDSHAKE);
- // One request is farther
- EXPECT_EQ(LOAD_STATE_SSL_HANDSHAKE, handle.GetLoadState());
- EXPECT_EQ(LOAD_STATE_SSL_HANDSHAKE, handle2.GetLoadState());
+// Test that the second connection request does not affect the pool's load
+// status.
+TEST_F(ClientSocketPoolBaseTest, LoadStateTwoRequestsChangeSecondRequestState) {
+ CreatePool(2, 2);
+ connect_job_factory_->set_job_type(TestConnectJob::kMockWaitingJob);
+
+ ClientSocketHandle handle;
+ TestCompletionCallback callback;
+ int rv = handle.Init("a", params_, DEFAULT_PRIORITY, callback.callback(),
+ pool_.get(), BoundNetLog());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
- // Farthest along job connects and the first request gets the socket. The
+ ClientSocketHandle handle2;
+ TestCompletionCallback callback2;
+ rv = handle2.Init("a", params_, DEFAULT_PRIORITY, callback2.callback(),
+ pool_.get(), BoundNetLog());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+ client_socket_factory_.SetJobLoadState(1, LOAD_STATE_RESOLVING_HOST);
+
+ EXPECT_EQ(LOAD_STATE_CONNECTING, handle.GetLoadState());
+ EXPECT_EQ(LOAD_STATE_CONNECTING, handle2.GetLoadState());
+
+ // First job connects and the first request gets the socket. The
// second handle switches to the state of the remaining ConnectJob.
client_socket_factory_.SignalJob(0);
EXPECT_EQ(OK, callback.WaitForResult());
- EXPECT_EQ(LOAD_STATE_CONNECTING, handle2.GetLoadState());
+ EXPECT_EQ(LOAD_STATE_RESOLVING_HOST, handle2.GetLoadState());
}
// Test GetLoadState in the case the per-group limit is reached.
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698