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/transport_client_socket_pool.h" | 5 #include "net/socket/transport_client_socket_pool.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 | 976 |
977 EXPECT_EQ(OK, callback.WaitForResult()); | 977 EXPECT_EQ(OK, callback.WaitForResult()); |
978 EXPECT_TRUE(handle.is_initialized()); | 978 EXPECT_TRUE(handle.is_initialized()); |
979 EXPECT_TRUE(handle.socket()); | 979 EXPECT_TRUE(handle.socket()); |
980 | 980 |
981 // One socket is stalled, the other is active. | 981 // One socket is stalled, the other is active. |
982 EXPECT_EQ(0, pool_.IdleSocketCount()); | 982 EXPECT_EQ(0, pool_.IdleSocketCount()); |
983 handle.Reset(); | 983 handle.Reset(); |
984 | 984 |
985 // Close all pending connect jobs and existing sockets. | 985 // Close all pending connect jobs and existing sockets. |
986 pool_.Flush(); | 986 pool_.FlushWithError(ERR_NETWORK_CHANGED); |
987 } | 987 } |
988 } | 988 } |
989 | 989 |
990 // Test the case where a socket took long enough to start the creation | 990 // Test the case where a socket took long enough to start the creation |
991 // of the backup socket, but then we cancelled the request after that. | 991 // of the backup socket, but then we cancelled the request after that. |
992 TEST_F(TransportClientSocketPoolTest, BackupSocketCancel) { | 992 TEST_F(TransportClientSocketPoolTest, BackupSocketCancel) { |
993 client_socket_factory_.set_client_socket_type( | 993 client_socket_factory_.set_client_socket_type( |
994 MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET); | 994 MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET); |
995 | 995 |
996 enum { CANCEL_BEFORE_WAIT, CANCEL_AFTER_WAIT }; | 996 enum { CANCEL_BEFORE_WAIT, CANCEL_AFTER_WAIT }; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 EXPECT_TRUE(handle.socket()); | 1274 EXPECT_TRUE(handle.socket()); |
1275 IPEndPoint endpoint; | 1275 IPEndPoint endpoint; |
1276 handle.socket()->GetLocalAddress(&endpoint); | 1276 handle.socket()->GetLocalAddress(&endpoint); |
1277 EXPECT_EQ(kIPv4AddressSize, endpoint.address().size()); | 1277 EXPECT_EQ(kIPv4AddressSize, endpoint.address().size()); |
1278 EXPECT_EQ(1, client_socket_factory_.allocation_count()); | 1278 EXPECT_EQ(1, client_socket_factory_.allocation_count()); |
1279 } | 1279 } |
1280 | 1280 |
1281 } // namespace | 1281 } // namespace |
1282 | 1282 |
1283 } // namespace net | 1283 } // namespace net |
OLD | NEW |