| 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" |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 EXPECT_EQ(2 * kDefaultMaxSockets, client_socket_factory_.allocation_count()); | 828 EXPECT_EQ(2 * kDefaultMaxSockets, client_socket_factory_.allocation_count()); |
| 829 EXPECT_EQ(0, pool_->IdleSocketCount()); | 829 EXPECT_EQ(0, pool_->IdleSocketCount()); |
| 830 | 830 |
| 831 // Before the next round of DoReleaseSocket tasks run, we will hit the | 831 // Before the next round of DoReleaseSocket tasks run, we will hit the |
| 832 // socket limit. | 832 // socket limit. |
| 833 | 833 |
| 834 EXPECT_EQ(ERR_IO_PENDING, | 834 EXPECT_EQ(ERR_IO_PENDING, |
| 835 InitHandle(&handle, "foo", kDefaultPriority, &callback, pool_, | 835 InitHandle(&handle, "foo", kDefaultPriority, &callback, pool_, |
| 836 NULL)); | 836 NULL)); |
| 837 | 837 |
| 838 // But if we wait for it, the released idle sockets will be closed in | 838 // But if we wait for it, the released idle sockets will be closed in |
| 839 // preference of the waiting request. | 839 // preference of the waiting request. |
| 840 | 840 |
| 841 EXPECT_EQ(OK, callback.WaitForResult()); | 841 EXPECT_EQ(OK, callback.WaitForResult()); |
| 842 } | 842 } |
| 843 | 843 |
| 844 TEST_F(ClientSocketPoolBaseTest, PendingRequests) { | 844 TEST_F(ClientSocketPoolBaseTest, PendingRequests) { |
| 845 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); | 845 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
| 846 | 846 |
| 847 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority)); | 847 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority)); |
| 848 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority)); | 848 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority)); |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 | 1400 |
| 1401 // Invoke the idle socket cleanup check. Only one socket should be left, the | 1401 // Invoke the idle socket cleanup check. Only one socket should be left, the |
| 1402 // used socket. Request it to make sure that it's used. | 1402 // used socket. Request it to make sure that it's used. |
| 1403 | 1403 |
| 1404 pool_->CleanupTimedOutIdleSockets(); | 1404 pool_->CleanupTimedOutIdleSockets(); |
| 1405 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 1405 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
| 1406 rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_, log.bound()); | 1406 rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_, log.bound()); |
| 1407 EXPECT_EQ(OK, rv); | 1407 EXPECT_EQ(OK, rv); |
| 1408 EXPECT_TRUE(req.handle()->is_reused()); | 1408 EXPECT_TRUE(req.handle()->is_reused()); |
| 1409 EXPECT_TRUE(LogContainsEntryWithType( | 1409 EXPECT_TRUE(LogContainsEntryWithType( |
| 1410 log.entries(), 1, NetLog::Entry::TYPE_STRING_LITERAL)); | 1410 log.entries(), 1, NetLog::TYPE_TODO_STRING_LITERAL)); |
| 1411 } | 1411 } |
| 1412 | 1412 |
| 1413 // Make sure that we process all pending requests even when we're stalling | 1413 // Make sure that we process all pending requests even when we're stalling |
| 1414 // because of multiple releasing disconnected sockets. | 1414 // because of multiple releasing disconnected sockets. |
| 1415 TEST_F(ClientSocketPoolBaseTest, MultipleReleasingDisconnectedSockets) { | 1415 TEST_F(ClientSocketPoolBaseTest, MultipleReleasingDisconnectedSockets) { |
| 1416 CreatePoolWithIdleTimeouts( | 1416 CreatePoolWithIdleTimeouts( |
| 1417 kDefaultMaxSockets, kDefaultMaxSocketsPerGroup, | 1417 kDefaultMaxSockets, kDefaultMaxSocketsPerGroup, |
| 1418 base::TimeDelta(), // Time out unused sockets immediately. | 1418 base::TimeDelta(), // Time out unused sockets immediately. |
| 1419 base::TimeDelta::FromDays(1)); // Don't time out used sockets. | 1419 base::TimeDelta::FromDays(1)); // Don't time out used sockets. |
| 1420 | 1420 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 TestReleasingSocketRequest request(pool_.get()); | 1530 TestReleasingSocketRequest request(pool_.get()); |
| 1531 EXPECT_EQ(ERR_IO_PENDING, InitHandle(request.handle(), "a", kDefaultPriority, | 1531 EXPECT_EQ(ERR_IO_PENDING, InitHandle(request.handle(), "a", kDefaultPriority, |
| 1532 &request, pool_, NULL)); | 1532 &request, pool_, NULL)); |
| 1533 | 1533 |
| 1534 EXPECT_EQ(OK, request.WaitForResult()); | 1534 EXPECT_EQ(OK, request.WaitForResult()); |
| 1535 } | 1535 } |
| 1536 | 1536 |
| 1537 } // namespace | 1537 } // namespace |
| 1538 | 1538 |
| 1539 } // namespace net | 1539 } // namespace net |
| OLD | NEW |