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

Side by Side 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: Use a list instead of a set. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/client_socket_pool_base.h" 5 #include "net/socket/client_socket_pool_base.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 ClientSocketHandle handle2; 1972 ClientSocketHandle handle2;
1973 TestCompletionCallback callback2; 1973 TestCompletionCallback callback2;
1974 rv = handle2.Init("a", 1974 rv = handle2.Init("a",
1975 params_, 1975 params_,
1976 DEFAULT_PRIORITY, 1976 DEFAULT_PRIORITY,
1977 callback2.callback(), 1977 callback2.callback(),
1978 pool_.get(), 1978 pool_.get(),
1979 BoundNetLog()); 1979 BoundNetLog());
1980 EXPECT_EQ(ERR_IO_PENDING, rv); 1980 EXPECT_EQ(ERR_IO_PENDING, rv);
1981 1981
1982 // If the first Job is in an earlier state than the second, the state of
1983 // the second job should be used for both handles.
1984 client_socket_factory_.SetJobLoadState(0, LOAD_STATE_RESOLVING_HOST);
1985 EXPECT_EQ(LOAD_STATE_CONNECTING, handle.GetLoadState());
1986 EXPECT_EQ(LOAD_STATE_CONNECTING, handle2.GetLoadState()); 1982 EXPECT_EQ(LOAD_STATE_CONNECTING, handle2.GetLoadState());
mmenke 2015/04/20 14:49:16 This seems a little weird now. Suggest moving the
mmenke 2015/04/20 20:32:16 Actually, going backwards in general seems a littl
haavardm 2015/04/21 13:28:36 Done.
1987 1983
1988 // If the second Job is in an earlier state than the second, the state of 1984 // Check that both handles report the state of the first job.
1989 // the first job should be used for both handles. 1985 client_socket_factory_.SetJobLoadState(0, LOAD_STATE_RESOLVING_HOST);
1990 client_socket_factory_.SetJobLoadState(0, LOAD_STATE_SSL_HANDSHAKE); 1986 EXPECT_EQ(LOAD_STATE_RESOLVING_HOST, handle.GetLoadState());
1991 // One request is farther 1987 EXPECT_EQ(LOAD_STATE_RESOLVING_HOST, handle2.GetLoadState());
mmenke 2015/04/20 14:49:16 I'm paranoid: Could you have another test just li
haavardm 2015/04/21 13:28:36 Done.
1992 EXPECT_EQ(LOAD_STATE_SSL_HANDSHAKE, handle.GetLoadState());
1993 EXPECT_EQ(LOAD_STATE_SSL_HANDSHAKE, handle2.GetLoadState());
1994 1988
1995 // Farthest along job connects and the first request gets the socket. The 1989 // Farthest along job connects and the first request gets the socket. The
1996 // second handle switches to the state of the remaining ConnectJob. 1990 // second handle switches to the state of the remaining ConnectJob.
mmenke 2015/04/20 14:49:16 This comment is no longer accurate (It's the one t
haavardm 2015/04/21 13:28:36 Done.
1997 client_socket_factory_.SignalJob(0); 1991 client_socket_factory_.SignalJob(0);
1998 EXPECT_EQ(OK, callback.WaitForResult()); 1992 EXPECT_EQ(OK, callback.WaitForResult());
1999 EXPECT_EQ(LOAD_STATE_CONNECTING, handle2.GetLoadState()); 1993 EXPECT_EQ(LOAD_STATE_CONNECTING, handle2.GetLoadState());
2000 } 1994 }
2001 1995
2002 // Test GetLoadState in the case the per-group limit is reached. 1996 // Test GetLoadState in the case the per-group limit is reached.
2003 TEST_F(ClientSocketPoolBaseTest, LoadStateGroupLimit) { 1997 TEST_F(ClientSocketPoolBaseTest, LoadStateGroupLimit) {
2004 CreatePool(2, 1); 1998 CreatePool(2, 1);
2005 connect_job_factory_->set_job_type(TestConnectJob::kMockWaitingJob); 1999 connect_job_factory_->set_job_type(TestConnectJob::kMockWaitingJob);
2006 2000
(...skipping 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after
4104 request(1)->handle()->Reset(); 4098 request(1)->handle()->Reset();
4105 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); 4099 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a"));
4106 4100
4107 EXPECT_EQ(OK, request(2)->WaitForResult()); 4101 EXPECT_EQ(OK, request(2)->WaitForResult());
4108 EXPECT_FALSE(request(1)->have_result()); 4102 EXPECT_FALSE(request(1)->have_result());
4109 } 4103 }
4110 4104
4111 } // namespace 4105 } // namespace
4112 4106
4113 } // namespace net 4107 } // namespace net
OLDNEW
« net/socket/client_socket_pool_base.cc ('K') | « 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