| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/platform_thread.h" | 10 #include "base/platform_thread.h" |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/scoped_vector.h" | 12 #include "base/scoped_vector.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "net/base/net_errors.h" |
| 15 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
| 16 #include "net/base/net_log_unittest.h" | 17 #include "net/base/net_log_unittest.h" |
| 17 #include "net/base/net_errors.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.h" | 21 #include "net/socket/client_socket.h" |
| 22 #include "net/socket/client_socket_factory.h" | 22 #include "net/socket/client_socket_factory.h" |
| 23 #include "net/socket/client_socket_handle.h" | 23 #include "net/socket/client_socket_handle.h" |
| 24 #include "net/socket/client_socket_pool_histograms.h" | 24 #include "net/socket/client_socket_pool_histograms.h" |
| 25 #include "net/socket/socket_test_util.h" | 25 #include "net/socket/socket_test_util.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 27 |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 TEST_F(ClientSocketPoolBaseTest, WaitForStalledSocketAtSocketLimit) { | 980 TEST_F(ClientSocketPoolBaseTest, WaitForStalledSocketAtSocketLimit) { |
| 981 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); | 981 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
| 982 connect_job_factory_->set_job_type(TestConnectJob::kMockJob); | 982 connect_job_factory_->set_job_type(TestConnectJob::kMockJob); |
| 983 | 983 |
| 984 ClientSocketHandle stalled_handle; | 984 ClientSocketHandle stalled_handle; |
| 985 TestCompletionCallback callback; | 985 TestCompletionCallback callback; |
| 986 { | 986 { |
| 987 ClientSocketHandle handles[kDefaultMaxSockets]; | 987 ClientSocketHandle handles[kDefaultMaxSockets]; |
| 988 for (int i = 0; i < kDefaultMaxSockets; ++i) { | 988 for (int i = 0; i < kDefaultMaxSockets; ++i) { |
| 989 TestCompletionCallback callback; | 989 TestCompletionCallback callback; |
| 990 EXPECT_EQ(OK, handles[i].Init(StringPrintf("Take 2: %d", i), params_, | 990 EXPECT_EQ(OK, handles[i].Init(base::StringPrintf("Take 2: %d", i), |
| 991 kDefaultPriority, &callback, pool_, | 991 params_, kDefaultPriority, &callback, |
| 992 BoundNetLog())); | 992 pool_, BoundNetLog())); |
| 993 } | 993 } |
| 994 | 994 |
| 995 EXPECT_EQ(kDefaultMaxSockets, client_socket_factory_.allocation_count()); | 995 EXPECT_EQ(kDefaultMaxSockets, client_socket_factory_.allocation_count()); |
| 996 EXPECT_EQ(0, pool_->IdleSocketCount()); | 996 EXPECT_EQ(0, pool_->IdleSocketCount()); |
| 997 | 997 |
| 998 // Now we will hit the socket limit. | 998 // Now we will hit the socket limit. |
| 999 EXPECT_EQ(ERR_IO_PENDING, stalled_handle.Init("foo", params_, | 999 EXPECT_EQ(ERR_IO_PENDING, stalled_handle.Init("foo", params_, |
| 1000 kDefaultPriority, &callback, | 1000 kDefaultPriority, &callback, |
| 1001 pool_, BoundNetLog())); | 1001 pool_, BoundNetLog())); |
| 1002 | 1002 |
| (...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2234 EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a")); | 2234 EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a")); |
| 2235 | 2235 |
| 2236 EXPECT_EQ(ERR_CONNECTION_FAILED, callback1.WaitForResult()); | 2236 EXPECT_EQ(ERR_CONNECTION_FAILED, callback1.WaitForResult()); |
| 2237 EXPECT_EQ(ERR_CONNECTION_FAILED, callback2.WaitForResult()); | 2237 EXPECT_EQ(ERR_CONNECTION_FAILED, callback2.WaitForResult()); |
| 2238 EXPECT_FALSE(pool_->HasGroup("a")); | 2238 EXPECT_FALSE(pool_->HasGroup("a")); |
| 2239 } | 2239 } |
| 2240 | 2240 |
| 2241 } // namespace | 2241 } // namespace |
| 2242 | 2242 |
| 2243 } // namespace net | 2243 } // namespace net |
| OLD | NEW |