OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/callback.h" | 7 #include "base/callback.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 BoundNetLog()); | 972 BoundNetLog()); |
973 EXPECT_EQ(ERR_IO_PENDING, rv); | 973 EXPECT_EQ(ERR_IO_PENDING, rv); |
974 EXPECT_FALSE(handle.is_initialized()); | 974 EXPECT_FALSE(handle.is_initialized()); |
975 EXPECT_FALSE(handle.socket()); | 975 EXPECT_FALSE(handle.socket()); |
976 | 976 |
977 // Create the first socket, set the timer. | 977 // Create the first socket, set the timer. |
978 MessageLoop::current()->RunAllPending(); | 978 MessageLoop::current()->RunAllPending(); |
979 | 979 |
980 if (index == CANCEL_AFTER_WAIT) { | 980 if (index == CANCEL_AFTER_WAIT) { |
981 // Wait for the backup socket timer to fire. | 981 // Wait for the backup socket timer to fire. |
982 base::PlatformThread::Sleep(ClientSocketPool::kMaxConnectRetryIntervalMs); | 982 base::PlatformThread::Sleep( |
| 983 ClientSocketPool::kMaxConnectRetryIntervalMs / 2 * 3); |
983 } | 984 } |
984 | 985 |
985 // Let the appropriate socket connect. | 986 // Let the appropriate socket connect. |
986 MessageLoop::current()->RunAllPending(); | 987 MessageLoop::current()->RunAllPending(); |
987 | 988 |
988 handle.Reset(); | 989 handle.Reset(); |
989 | 990 |
990 EXPECT_FALSE(callback.have_result()); | 991 EXPECT_FALSE(callback.have_result()); |
991 EXPECT_FALSE(handle.is_initialized()); | 992 EXPECT_FALSE(handle.is_initialized()); |
992 EXPECT_FALSE(handle.socket()); | 993 EXPECT_FALSE(handle.socket()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 ClientSocketHandle handle; | 1027 ClientSocketHandle handle; |
1027 int rv = handle.Init("b", low_params_, LOW, &callback, &pool_, BoundNetLog()); | 1028 int rv = handle.Init("b", low_params_, LOW, &callback, &pool_, BoundNetLog()); |
1028 EXPECT_EQ(ERR_IO_PENDING, rv); | 1029 EXPECT_EQ(ERR_IO_PENDING, rv); |
1029 EXPECT_FALSE(handle.is_initialized()); | 1030 EXPECT_FALSE(handle.is_initialized()); |
1030 EXPECT_FALSE(handle.socket()); | 1031 EXPECT_FALSE(handle.socket()); |
1031 | 1032 |
1032 // Create the first socket, set the timer. | 1033 // Create the first socket, set the timer. |
1033 MessageLoop::current()->RunAllPending(); | 1034 MessageLoop::current()->RunAllPending(); |
1034 | 1035 |
1035 // Wait for the backup socket timer to fire. | 1036 // Wait for the backup socket timer to fire. |
1036 base::PlatformThread::Sleep(ClientSocketPool::kMaxConnectRetryIntervalMs); | 1037 base::PlatformThread::Sleep( |
| 1038 ClientSocketPool::kMaxConnectRetryIntervalMs / 2 * 3); |
1037 | 1039 |
1038 // Let the second connect be synchronous. Otherwise, the emulated | 1040 // Let the second connect be synchronous. Otherwise, the emulated |
1039 // host resolution takes an extra trip through the message loop. | 1041 // host resolution takes an extra trip through the message loop. |
1040 host_resolver_->set_synchronous_mode(true); | 1042 host_resolver_->set_synchronous_mode(true); |
1041 | 1043 |
1042 // Let the appropriate socket connect. | 1044 // Let the appropriate socket connect. |
1043 MessageLoop::current()->RunAllPending(); | 1045 MessageLoop::current()->RunAllPending(); |
1044 | 1046 |
1045 EXPECT_EQ(ERR_CONNECTION_FAILED, callback.WaitForResult()); | 1047 EXPECT_EQ(ERR_CONNECTION_FAILED, callback.WaitForResult()); |
1046 EXPECT_FALSE(handle.is_initialized()); | 1048 EXPECT_FALSE(handle.is_initialized()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 ClientSocketHandle handle; | 1080 ClientSocketHandle handle; |
1079 int rv = handle.Init("b", low_params_, LOW, &callback, &pool_, BoundNetLog()); | 1081 int rv = handle.Init("b", low_params_, LOW, &callback, &pool_, BoundNetLog()); |
1080 EXPECT_EQ(ERR_IO_PENDING, rv); | 1082 EXPECT_EQ(ERR_IO_PENDING, rv); |
1081 EXPECT_FALSE(handle.is_initialized()); | 1083 EXPECT_FALSE(handle.is_initialized()); |
1082 EXPECT_FALSE(handle.socket()); | 1084 EXPECT_FALSE(handle.socket()); |
1083 | 1085 |
1084 // Create the first socket, set the timer. | 1086 // Create the first socket, set the timer. |
1085 MessageLoop::current()->RunAllPending(); | 1087 MessageLoop::current()->RunAllPending(); |
1086 | 1088 |
1087 // Wait for the backup socket timer to fire. | 1089 // Wait for the backup socket timer to fire. |
1088 base::PlatformThread::Sleep(ClientSocketPool::kMaxConnectRetryIntervalMs); | 1090 base::PlatformThread::Sleep( |
| 1091 ClientSocketPool::kMaxConnectRetryIntervalMs / 2 * 3); |
1089 | 1092 |
1090 // Let the second connect be synchronous. Otherwise, the emulated | 1093 // Let the second connect be synchronous. Otherwise, the emulated |
1091 // host resolution takes an extra trip through the message loop. | 1094 // host resolution takes an extra trip through the message loop. |
1092 host_resolver_->set_synchronous_mode(true); | 1095 host_resolver_->set_synchronous_mode(true); |
1093 | 1096 |
1094 // Let the appropriate socket connect. | 1097 // Let the appropriate socket connect. |
1095 MessageLoop::current()->RunAllPending(); | 1098 MessageLoop::current()->RunAllPending(); |
1096 | 1099 |
1097 EXPECT_EQ(ERR_CONNECTION_FAILED, callback.WaitForResult()); | 1100 EXPECT_EQ(ERR_CONNECTION_FAILED, callback.WaitForResult()); |
1098 EXPECT_FALSE(handle.is_initialized()); | 1101 EXPECT_FALSE(handle.is_initialized()); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 EXPECT_TRUE(handle.socket()); | 1253 EXPECT_TRUE(handle.socket()); |
1251 IPEndPoint endpoint; | 1254 IPEndPoint endpoint; |
1252 handle.socket()->GetLocalAddress(&endpoint); | 1255 handle.socket()->GetLocalAddress(&endpoint); |
1253 EXPECT_EQ(kIPv4AddressSize, endpoint.address().size()); | 1256 EXPECT_EQ(kIPv4AddressSize, endpoint.address().size()); |
1254 EXPECT_EQ(1, client_socket_factory_.allocation_count()); | 1257 EXPECT_EQ(1, client_socket_factory_.allocation_count()); |
1255 } | 1258 } |
1256 | 1259 |
1257 } // namespace | 1260 } // namespace |
1258 | 1261 |
1259 } // namespace net | 1262 } // namespace net |
OLD | NEW |