| 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/client_socket_pool_base.h" | 5 #include "net/socket/client_socket_pool_base.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 int id) override { | 548 int id) override { |
| 549 base_.ReleaseSocket(group_name, std::move(socket), id); | 549 base_.ReleaseSocket(group_name, std::move(socket), id); |
| 550 } | 550 } |
| 551 | 551 |
| 552 void FlushWithError(int error) override { base_.FlushWithError(error); } | 552 void FlushWithError(int error) override { base_.FlushWithError(error); } |
| 553 | 553 |
| 554 bool IsStalled() const override { return base_.IsStalled(); } | 554 bool IsStalled() const override { return base_.IsStalled(); } |
| 555 | 555 |
| 556 void CloseIdleSockets() override { base_.CloseIdleSockets(); } | 556 void CloseIdleSockets() override { base_.CloseIdleSockets(); } |
| 557 | 557 |
| 558 void CloseIdleSocketsInGroup(const std::string& group_name) override { |
| 559 base_.CloseIdleSocketsInGroup(group_name); |
| 560 } |
| 561 |
| 558 int IdleSocketCount() const override { return base_.idle_socket_count(); } | 562 int IdleSocketCount() const override { return base_.idle_socket_count(); } |
| 559 | 563 |
| 560 int IdleSocketCountInGroup(const std::string& group_name) const override { | 564 int IdleSocketCountInGroup(const std::string& group_name) const override { |
| 561 return base_.IdleSocketCountInGroup(group_name); | 565 return base_.IdleSocketCountInGroup(group_name); |
| 562 } | 566 } |
| 563 | 567 |
| 564 LoadState GetLoadState(const std::string& group_name, | 568 LoadState GetLoadState(const std::string& group_name, |
| 565 const ClientSocketHandle* handle) const override { | 569 const ClientSocketHandle* handle) const override { |
| 566 return base_.GetLoadState(group_name, handle); | 570 return base_.GetLoadState(group_name, handle); |
| 567 } | 571 } |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 callback.callback(), pool_.get(), log.bound()); | 1726 callback.callback(), pool_.get(), log.bound()); |
| 1723 EXPECT_THAT(rv, IsOk()); | 1727 EXPECT_THAT(rv, IsOk()); |
| 1724 handle.Reset(); | 1728 handle.Reset(); |
| 1725 EXPECT_EQ(1, pool_->IdleSocketCount()); | 1729 EXPECT_EQ(1, pool_->IdleSocketCount()); |
| 1726 pool_->CloseIdleSockets(); | 1730 pool_->CloseIdleSockets(); |
| 1727 EXPECT_THAT(histograms.GetAllSamples(kIdleSocketFateHistogram), | 1731 EXPECT_THAT(histograms.GetAllSamples(kIdleSocketFateHistogram), |
| 1728 testing::ElementsAre( | 1732 testing::ElementsAre( |
| 1729 base::Bucket(/*IDLE_SOCKET_FATE_CLEAN_UP_FORCED=*/4, 1))); | 1733 base::Bucket(/*IDLE_SOCKET_FATE_CLEAN_UP_FORCED=*/4, 1))); |
| 1730 } | 1734 } |
| 1731 | 1735 |
| 1736 TEST_F(ClientSocketPoolBaseTest, CloseIdleSocketsInGroupForced) { |
| 1737 base::HistogramTester histograms; |
| 1738 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
| 1739 TestCompletionCallback callback; |
| 1740 BoundTestNetLog log; |
| 1741 ClientSocketHandle handle1; |
| 1742 int rv = handle1.Init("a", params_, LOWEST, |
| 1743 ClientSocketPool::RespectLimits::ENABLED, |
| 1744 callback.callback(), pool_.get(), log.bound()); |
| 1745 EXPECT_THAT(rv, IsOk()); |
| 1746 ClientSocketHandle handle2; |
| 1747 rv = handle2.Init("a", params_, LOWEST, |
| 1748 ClientSocketPool::RespectLimits::ENABLED, |
| 1749 callback.callback(), pool_.get(), log.bound()); |
| 1750 ClientSocketHandle handle3; |
| 1751 rv = handle3.Init("b", params_, LOWEST, |
| 1752 ClientSocketPool::RespectLimits::ENABLED, |
| 1753 callback.callback(), pool_.get(), log.bound()); |
| 1754 EXPECT_THAT(rv, IsOk()); |
| 1755 handle1.Reset(); |
| 1756 handle2.Reset(); |
| 1757 handle3.Reset(); |
| 1758 EXPECT_EQ(3, pool_->IdleSocketCount()); |
| 1759 pool_->CloseIdleSocketsInGroup("a"); |
| 1760 EXPECT_EQ(1, pool_->IdleSocketCount()); |
| 1761 EXPECT_THAT(histograms.GetAllSamples(kIdleSocketFateHistogram), |
| 1762 testing::ElementsAre( |
| 1763 base::Bucket(/*IDLE_SOCKET_FATE_CLEAN_UP_FORCED=*/4, 2))); |
| 1764 } |
| 1765 |
| 1732 TEST_F(ClientSocketPoolBaseTest, CleanUpUnusableIdleSockets) { | 1766 TEST_F(ClientSocketPoolBaseTest, CleanUpUnusableIdleSockets) { |
| 1733 base::HistogramTester histograms; | 1767 base::HistogramTester histograms; |
| 1734 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); | 1768 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
| 1735 ClientSocketHandle handle; | 1769 ClientSocketHandle handle; |
| 1736 TestCompletionCallback callback; | 1770 TestCompletionCallback callback; |
| 1737 BoundTestNetLog log; | 1771 BoundTestNetLog log; |
| 1738 int rv = handle.Init("a", params_, LOWEST, | 1772 int rv = handle.Init("a", params_, LOWEST, |
| 1739 ClientSocketPool::RespectLimits::ENABLED, | 1773 ClientSocketPool::RespectLimits::ENABLED, |
| 1740 callback.callback(), pool_.get(), log.bound()); | 1774 callback.callback(), pool_.get(), log.bound()); |
| 1741 EXPECT_THAT(rv, IsOk()); | 1775 EXPECT_THAT(rv, IsOk()); |
| (...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4041 request(1)->handle()->Reset(); | 4075 request(1)->handle()->Reset(); |
| 4042 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); | 4076 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); |
| 4043 | 4077 |
| 4044 EXPECT_THAT(request(2)->WaitForResult(), IsOk()); | 4078 EXPECT_THAT(request(2)->WaitForResult(), IsOk()); |
| 4045 EXPECT_FALSE(request(1)->have_result()); | 4079 EXPECT_FALSE(request(1)->have_result()); |
| 4046 } | 4080 } |
| 4047 | 4081 |
| 4048 } // namespace | 4082 } // namespace |
| 4049 | 4083 |
| 4050 } // namespace net | 4084 } // namespace net |
| OLD | NEW |