OLD | NEW |
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 Loading... |
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()); |
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()); |
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. |
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) { |
(...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |