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/client_socket_pool_base.h" | 5 #include "net/socket/client_socket_pool_base.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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/stringprintf.h" |
12 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
13 #include "base/string_util.h" | |
14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
16 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
17 #include "net/base/net_log_unittest.h" | 17 #include "net/base/net_log_unittest.h" |
18 #include "net/base/request_priority.h" | 18 #include "net/base/request_priority.h" |
19 #include "net/base/test_completion_callback.h" | 19 #include "net/base/test_completion_callback.h" |
20 #include "net/http/http_response_headers.h" | 20 #include "net/http/http_response_headers.h" |
21 #include "net/socket/client_socket_factory.h" | 21 #include "net/socket/client_socket_factory.h" |
22 #include "net/socket/client_socket_handle.h" | 22 #include "net/socket/client_socket_handle.h" |
23 #include "net/socket/client_socket_pool_histograms.h" | 23 #include "net/socket/client_socket_pool_histograms.h" |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 TEST_F(ClientSocketPoolBaseTest, WaitForStalledSocketAtSocketLimit) { | 1064 TEST_F(ClientSocketPoolBaseTest, WaitForStalledSocketAtSocketLimit) { |
1065 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); | 1065 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
1066 connect_job_factory_->set_job_type(TestConnectJob::kMockJob); | 1066 connect_job_factory_->set_job_type(TestConnectJob::kMockJob); |
1067 | 1067 |
1068 ClientSocketHandle stalled_handle; | 1068 ClientSocketHandle stalled_handle; |
1069 TestCompletionCallback callback; | 1069 TestCompletionCallback callback; |
1070 { | 1070 { |
1071 ClientSocketHandle handles[kDefaultMaxSockets]; | 1071 ClientSocketHandle handles[kDefaultMaxSockets]; |
1072 for (int i = 0; i < kDefaultMaxSockets; ++i) { | 1072 for (int i = 0; i < kDefaultMaxSockets; ++i) { |
1073 TestCompletionCallback callback; | 1073 TestCompletionCallback callback; |
1074 EXPECT_EQ(OK, handles[i].Init(base::StringPrintf("Take 2: %d", i), | 1074 EXPECT_EQ(OK, handles[i].Init(base::StringPrintf( |
1075 params_, | 1075 "Take 2: %d", i), |
1076 kDefaultPriority, | 1076 params_, |
1077 &callback, | 1077 kDefaultPriority, |
1078 pool_.get(), | 1078 &callback, |
1079 BoundNetLog())); | 1079 pool_.get(), |
| 1080 BoundNetLog())); |
1080 } | 1081 } |
1081 | 1082 |
1082 EXPECT_EQ(kDefaultMaxSockets, client_socket_factory_.allocation_count()); | 1083 EXPECT_EQ(kDefaultMaxSockets, client_socket_factory_.allocation_count()); |
1083 EXPECT_EQ(0, pool_->IdleSocketCount()); | 1084 EXPECT_EQ(0, pool_->IdleSocketCount()); |
1084 | 1085 |
1085 // Now we will hit the socket limit. | 1086 // Now we will hit the socket limit. |
1086 EXPECT_EQ(ERR_IO_PENDING, stalled_handle.Init("foo", | 1087 EXPECT_EQ(ERR_IO_PENDING, stalled_handle.Init("foo", |
1087 params_, | 1088 params_, |
1088 kDefaultPriority, | 1089 kDefaultPriority, |
1089 &callback, | 1090 &callback, |
(...skipping 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3213 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob); | 3214 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob); |
3214 ASSERT_EQ(OK, callback1.WaitForResult()); | 3215 ASSERT_EQ(OK, callback1.WaitForResult()); |
3215 handle1.socket()->Disconnect(); | 3216 handle1.socket()->Disconnect(); |
3216 handle1.Reset(); | 3217 handle1.Reset(); |
3217 ASSERT_EQ(OK, callback2.WaitForResult()); | 3218 ASSERT_EQ(OK, callback2.WaitForResult()); |
3218 } | 3219 } |
3219 | 3220 |
3220 } // namespace | 3221 } // namespace |
3221 | 3222 |
3222 } // namespace net | 3223 } // namespace net |
OLD | NEW |