| 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 14 matching lines...) Expand all Loading... |
| 25 #include "base/threading/platform_thread.h" | 25 #include "base/threading/platform_thread.h" |
| 26 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "base/values.h" | 27 #include "base/values.h" |
| 28 #include "net/base/load_timing_info.h" | 28 #include "net/base/load_timing_info.h" |
| 29 #include "net/base/load_timing_info_test_util.h" | 29 #include "net/base/load_timing_info_test_util.h" |
| 30 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| 31 #include "net/base/request_priority.h" | 31 #include "net/base/request_priority.h" |
| 32 #include "net/base/test_completion_callback.h" | 32 #include "net/base/test_completion_callback.h" |
| 33 #include "net/http/http_response_headers.h" | 33 #include "net/http/http_response_headers.h" |
| 34 #include "net/log/net_log.h" | 34 #include "net/log/net_log.h" |
| 35 #include "net/log/net_log_event_type.h" |
| 36 #include "net/log/net_log_source_type.h" |
| 35 #include "net/log/test_net_log.h" | 37 #include "net/log/test_net_log.h" |
| 36 #include "net/log/test_net_log_entry.h" | 38 #include "net/log/test_net_log_entry.h" |
| 37 #include "net/log/test_net_log_util.h" | 39 #include "net/log/test_net_log_util.h" |
| 38 #include "net/socket/client_socket_factory.h" | 40 #include "net/socket/client_socket_factory.h" |
| 39 #include "net/socket/client_socket_handle.h" | 41 #include "net/socket/client_socket_handle.h" |
| 40 #include "net/socket/socket_performance_watcher.h" | 42 #include "net/socket/socket_performance_watcher.h" |
| 41 #include "net/socket/socket_test_util.h" | 43 #include "net/socket/socket_test_util.h" |
| 42 #include "net/socket/ssl_client_socket.h" | 44 #include "net/socket/ssl_client_socket.h" |
| 43 #include "net/socket/stream_socket.h" | 45 #include "net/socket/stream_socket.h" |
| 44 #include "net/test/gtest_util.h" | 46 #include "net/test/gtest_util.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 friend class base::RefCounted<TestSocketParams>; | 120 friend class base::RefCounted<TestSocketParams>; |
| 119 ~TestSocketParams() {} | 121 ~TestSocketParams() {} |
| 120 }; | 122 }; |
| 121 typedef ClientSocketPoolBase<TestSocketParams> TestClientSocketPoolBase; | 123 typedef ClientSocketPoolBase<TestSocketParams> TestClientSocketPoolBase; |
| 122 | 124 |
| 123 class MockClientSocket : public StreamSocket { | 125 class MockClientSocket : public StreamSocket { |
| 124 public: | 126 public: |
| 125 explicit MockClientSocket(net::NetLog* net_log) | 127 explicit MockClientSocket(net::NetLog* net_log) |
| 126 : connected_(false), | 128 : connected_(false), |
| 127 has_unread_data_(false), | 129 has_unread_data_(false), |
| 128 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)), | 130 net_log_(BoundNetLog::Make(net_log, NetLogSourceType::SOCKET)), |
| 129 was_used_to_convey_data_(false) {} | 131 was_used_to_convey_data_(false) {} |
| 130 | 132 |
| 131 // Sets whether the socket has unread data. If true, the next call to Read() | 133 // Sets whether the socket has unread data. If true, the next call to Read() |
| 132 // will return 1 byte and IsConnectedAndIdle() will return false. | 134 // will return 1 byte and IsConnectedAndIdle() will return false. |
| 133 void set_has_unread_data(bool has_unread_data) { | 135 void set_has_unread_data(bool has_unread_data) { |
| 134 has_unread_data_ = has_unread_data; | 136 has_unread_data_ = has_unread_data; |
| 135 } | 137 } |
| 136 | 138 |
| 137 // Socket implementation. | 139 // Socket implementation. |
| 138 int Read(IOBuffer* /* buf */, | 140 int Read(IOBuffer* /* buf */, |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 const TestClientSocketPoolBase::Request& request, | 279 const TestClientSocketPoolBase::Request& request, |
| 278 base::TimeDelta timeout_duration, | 280 base::TimeDelta timeout_duration, |
| 279 ConnectJob::Delegate* delegate, | 281 ConnectJob::Delegate* delegate, |
| 280 MockClientSocketFactory* client_socket_factory, | 282 MockClientSocketFactory* client_socket_factory, |
| 281 NetLog* net_log) | 283 NetLog* net_log) |
| 282 : ConnectJob(group_name, | 284 : ConnectJob(group_name, |
| 283 timeout_duration, | 285 timeout_duration, |
| 284 request.priority(), | 286 request.priority(), |
| 285 request.respect_limits(), | 287 request.respect_limits(), |
| 286 delegate, | 288 delegate, |
| 287 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), | 289 BoundNetLog::Make(net_log, NetLogSourceType::CONNECT_JOB)), |
| 288 job_type_(job_type), | 290 job_type_(job_type), |
| 289 client_socket_factory_(client_socket_factory), | 291 client_socket_factory_(client_socket_factory), |
| 290 load_state_(LOAD_STATE_IDLE), | 292 load_state_(LOAD_STATE_IDLE), |
| 291 store_additional_error_state_(false), | 293 store_additional_error_state_(false), |
| 292 weak_factory_(this) {} | 294 weak_factory_(this) {} |
| 293 | 295 |
| 294 void Signal() { | 296 void Signal() { |
| 295 DoConnect(waiting_success_, true /* async */, false /* recoverable */); | 297 DoConnect(waiting_success_, true /* async */, false /* recoverable */); |
| 296 } | 298 } |
| 297 | 299 |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 &log); | 776 &log); |
| 775 ASSERT_THAT(job->Connect(), IsError(ERR_IO_PENDING)); | 777 ASSERT_THAT(job->Connect(), IsError(ERR_IO_PENDING)); |
| 776 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); | 778 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); |
| 777 EXPECT_THAT(delegate.WaitForResult(), IsError(ERR_TIMED_OUT)); | 779 EXPECT_THAT(delegate.WaitForResult(), IsError(ERR_TIMED_OUT)); |
| 778 | 780 |
| 779 TestNetLogEntry::List entries; | 781 TestNetLogEntry::List entries; |
| 780 log.GetEntries(&entries); | 782 log.GetEntries(&entries); |
| 781 | 783 |
| 782 EXPECT_EQ(6u, entries.size()); | 784 EXPECT_EQ(6u, entries.size()); |
| 783 EXPECT_TRUE(LogContainsBeginEvent( | 785 EXPECT_TRUE(LogContainsBeginEvent( |
| 784 entries, 0, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB)); | 786 entries, 0, NetLogEventType::SOCKET_POOL_CONNECT_JOB)); |
| 785 EXPECT_TRUE(LogContainsBeginEvent( | 787 EXPECT_TRUE(LogContainsBeginEvent( |
| 786 entries, 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT)); | 788 entries, 1, NetLogEventType::SOCKET_POOL_CONNECT_JOB_CONNECT)); |
| 787 EXPECT_TRUE(LogContainsEvent( | 789 EXPECT_TRUE(LogContainsEvent( |
| 788 entries, 2, NetLog::TYPE_CONNECT_JOB_SET_SOCKET, | 790 entries, 2, NetLogEventType::CONNECT_JOB_SET_SOCKET, |
| 789 NetLog::PHASE_NONE)); | 791 NetLogEventPhase::NONE)); |
| 790 EXPECT_TRUE(LogContainsEvent( | 792 EXPECT_TRUE(LogContainsEvent( |
| 791 entries, 3, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_TIMED_OUT, | 793 entries, 3, NetLogEventType::SOCKET_POOL_CONNECT_JOB_TIMED_OUT, |
| 792 NetLog::PHASE_NONE)); | 794 NetLogEventPhase::NONE)); |
| 793 EXPECT_TRUE(LogContainsEndEvent( | 795 EXPECT_TRUE(LogContainsEndEvent( |
| 794 entries, 4, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT)); | 796 entries, 4, NetLogEventType::SOCKET_POOL_CONNECT_JOB_CONNECT)); |
| 795 EXPECT_TRUE(LogContainsEndEvent( | 797 EXPECT_TRUE(LogContainsEndEvent( |
| 796 entries, 5, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB)); | 798 entries, 5, NetLogEventType::SOCKET_POOL_CONNECT_JOB)); |
| 797 } | 799 } |
| 798 | 800 |
| 799 TEST_F(ClientSocketPoolBaseTest, BasicSynchronous) { | 801 TEST_F(ClientSocketPoolBaseTest, BasicSynchronous) { |
| 800 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); | 802 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
| 801 | 803 |
| 802 TestCompletionCallback callback; | 804 TestCompletionCallback callback; |
| 803 ClientSocketHandle handle; | 805 ClientSocketHandle handle; |
| 804 BoundTestNetLog log; | 806 BoundTestNetLog log; |
| 805 TestLoadTimingInfoNotConnected(handle); | 807 TestLoadTimingInfoNotConnected(handle); |
| 806 | 808 |
| 807 EXPECT_EQ(OK, handle.Init("a", params_, DEFAULT_PRIORITY, | 809 EXPECT_EQ(OK, handle.Init("a", params_, DEFAULT_PRIORITY, |
| 808 ClientSocketPool::RespectLimits::ENABLED, | 810 ClientSocketPool::RespectLimits::ENABLED, |
| 809 callback.callback(), pool_.get(), log.bound())); | 811 callback.callback(), pool_.get(), log.bound())); |
| 810 EXPECT_TRUE(handle.is_initialized()); | 812 EXPECT_TRUE(handle.is_initialized()); |
| 811 EXPECT_TRUE(handle.socket()); | 813 EXPECT_TRUE(handle.socket()); |
| 812 TestLoadTimingInfoConnectedNotReused(handle); | 814 TestLoadTimingInfoConnectedNotReused(handle); |
| 813 | 815 |
| 814 handle.Reset(); | 816 handle.Reset(); |
| 815 TestLoadTimingInfoNotConnected(handle); | 817 TestLoadTimingInfoNotConnected(handle); |
| 816 | 818 |
| 817 TestNetLogEntry::List entries; | 819 TestNetLogEntry::List entries; |
| 818 log.GetEntries(&entries); | 820 log.GetEntries(&entries); |
| 819 | 821 |
| 820 EXPECT_EQ(4u, entries.size()); | 822 EXPECT_EQ(4u, entries.size()); |
| 821 EXPECT_TRUE(LogContainsBeginEvent( | 823 EXPECT_TRUE(LogContainsBeginEvent( |
| 822 entries, 0, NetLog::TYPE_SOCKET_POOL)); | 824 entries, 0, NetLogEventType::SOCKET_POOL)); |
| 823 EXPECT_TRUE(LogContainsEvent( | 825 EXPECT_TRUE(LogContainsEvent( |
| 824 entries, 1, NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, | 826 entries, 1, NetLogEventType::SOCKET_POOL_BOUND_TO_CONNECT_JOB, |
| 825 NetLog::PHASE_NONE)); | 827 NetLogEventPhase::NONE)); |
| 826 EXPECT_TRUE(LogContainsEvent( | 828 EXPECT_TRUE(LogContainsEvent( |
| 827 entries, 2, NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, | 829 entries, 2, NetLogEventType::SOCKET_POOL_BOUND_TO_SOCKET, |
| 828 NetLog::PHASE_NONE)); | 830 NetLogEventPhase::NONE)); |
| 829 EXPECT_TRUE(LogContainsEndEvent( | 831 EXPECT_TRUE(LogContainsEndEvent( |
| 830 entries, 3, NetLog::TYPE_SOCKET_POOL)); | 832 entries, 3, NetLogEventType::SOCKET_POOL)); |
| 831 } | 833 } |
| 832 | 834 |
| 833 TEST_F(ClientSocketPoolBaseTest, InitConnectionFailure) { | 835 TEST_F(ClientSocketPoolBaseTest, InitConnectionFailure) { |
| 834 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); | 836 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
| 835 | 837 |
| 836 connect_job_factory_->set_job_type(TestConnectJob::kMockFailingJob); | 838 connect_job_factory_->set_job_type(TestConnectJob::kMockFailingJob); |
| 837 BoundTestNetLog log; | 839 BoundTestNetLog log; |
| 838 | 840 |
| 839 ClientSocketHandle handle; | 841 ClientSocketHandle handle; |
| 840 TestCompletionCallback callback; | 842 TestCompletionCallback callback; |
| 841 // Set the additional error state members to ensure that they get cleared. | 843 // Set the additional error state members to ensure that they get cleared. |
| 842 handle.set_is_ssl_error(true); | 844 handle.set_is_ssl_error(true); |
| 843 HttpResponseInfo info; | 845 HttpResponseInfo info; |
| 844 info.headers = new HttpResponseHeaders(std::string()); | 846 info.headers = new HttpResponseHeaders(std::string()); |
| 845 handle.set_ssl_error_response_info(info); | 847 handle.set_ssl_error_response_info(info); |
| 846 EXPECT_EQ(ERR_CONNECTION_FAILED, | 848 EXPECT_EQ(ERR_CONNECTION_FAILED, |
| 847 handle.Init("a", params_, DEFAULT_PRIORITY, | 849 handle.Init("a", params_, DEFAULT_PRIORITY, |
| 848 ClientSocketPool::RespectLimits::ENABLED, | 850 ClientSocketPool::RespectLimits::ENABLED, |
| 849 callback.callback(), pool_.get(), log.bound())); | 851 callback.callback(), pool_.get(), log.bound())); |
| 850 EXPECT_FALSE(handle.socket()); | 852 EXPECT_FALSE(handle.socket()); |
| 851 EXPECT_FALSE(handle.is_ssl_error()); | 853 EXPECT_FALSE(handle.is_ssl_error()); |
| 852 EXPECT_TRUE(handle.ssl_error_response_info().headers.get() == NULL); | 854 EXPECT_TRUE(handle.ssl_error_response_info().headers.get() == NULL); |
| 853 TestLoadTimingInfoNotConnected(handle); | 855 TestLoadTimingInfoNotConnected(handle); |
| 854 | 856 |
| 855 TestNetLogEntry::List entries; | 857 TestNetLogEntry::List entries; |
| 856 log.GetEntries(&entries); | 858 log.GetEntries(&entries); |
| 857 | 859 |
| 858 EXPECT_EQ(3u, entries.size()); | 860 EXPECT_EQ(3u, entries.size()); |
| 859 EXPECT_TRUE(LogContainsBeginEvent( | 861 EXPECT_TRUE(LogContainsBeginEvent( |
| 860 entries, 0, NetLog::TYPE_SOCKET_POOL)); | 862 entries, 0, NetLogEventType::SOCKET_POOL)); |
| 861 EXPECT_TRUE(LogContainsEvent( | 863 EXPECT_TRUE(LogContainsEvent( |
| 862 entries, 1, NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, | 864 entries, 1, NetLogEventType::SOCKET_POOL_BOUND_TO_CONNECT_JOB, |
| 863 NetLog::PHASE_NONE)); | 865 NetLogEventPhase::NONE)); |
| 864 EXPECT_TRUE(LogContainsEndEvent( | 866 EXPECT_TRUE(LogContainsEndEvent( |
| 865 entries, 2, NetLog::TYPE_SOCKET_POOL)); | 867 entries, 2, NetLogEventType::SOCKET_POOL)); |
| 866 } | 868 } |
| 867 | 869 |
| 868 TEST_F(ClientSocketPoolBaseTest, TotalLimit) { | 870 TEST_F(ClientSocketPoolBaseTest, TotalLimit) { |
| 869 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); | 871 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
| 870 | 872 |
| 871 // TODO(eroman): Check that the NetLog contains this event. | 873 // TODO(eroman): Check that the NetLog contains this event. |
| 872 | 874 |
| 873 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsOk()); | 875 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsOk()); |
| 874 EXPECT_THAT(StartRequest("b", DEFAULT_PRIORITY), IsOk()); | 876 EXPECT_THAT(StartRequest("b", DEFAULT_PRIORITY), IsOk()); |
| 875 EXPECT_THAT(StartRequest("c", DEFAULT_PRIORITY), IsOk()); | 877 EXPECT_THAT(StartRequest("c", DEFAULT_PRIORITY), IsOk()); |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1601 TestLoadTimingInfoConnectedNotReused(handle); | 1603 TestLoadTimingInfoConnectedNotReused(handle); |
| 1602 | 1604 |
| 1603 handle.Reset(); | 1605 handle.Reset(); |
| 1604 TestLoadTimingInfoNotConnected(handle); | 1606 TestLoadTimingInfoNotConnected(handle); |
| 1605 | 1607 |
| 1606 TestNetLogEntry::List entries; | 1608 TestNetLogEntry::List entries; |
| 1607 log.GetEntries(&entries); | 1609 log.GetEntries(&entries); |
| 1608 | 1610 |
| 1609 EXPECT_EQ(4u, entries.size()); | 1611 EXPECT_EQ(4u, entries.size()); |
| 1610 EXPECT_TRUE(LogContainsBeginEvent( | 1612 EXPECT_TRUE(LogContainsBeginEvent( |
| 1611 entries, 0, NetLog::TYPE_SOCKET_POOL)); | 1613 entries, 0, NetLogEventType::SOCKET_POOL)); |
| 1612 EXPECT_TRUE(LogContainsEvent( | 1614 EXPECT_TRUE(LogContainsEvent( |
| 1613 entries, 1, NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, | 1615 entries, 1, NetLogEventType::SOCKET_POOL_BOUND_TO_CONNECT_JOB, |
| 1614 NetLog::PHASE_NONE)); | 1616 NetLogEventPhase::NONE)); |
| 1615 EXPECT_TRUE(LogContainsEvent( | 1617 EXPECT_TRUE(LogContainsEvent( |
| 1616 entries, 2, NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, | 1618 entries, 2, NetLogEventType::SOCKET_POOL_BOUND_TO_SOCKET, |
| 1617 NetLog::PHASE_NONE)); | 1619 NetLogEventPhase::NONE)); |
| 1618 EXPECT_TRUE(LogContainsEndEvent( | 1620 EXPECT_TRUE(LogContainsEndEvent( |
| 1619 entries, 3, NetLog::TYPE_SOCKET_POOL)); | 1621 entries, 3, NetLogEventType::SOCKET_POOL)); |
| 1620 } | 1622 } |
| 1621 | 1623 |
| 1622 TEST_F(ClientSocketPoolBaseTest, | 1624 TEST_F(ClientSocketPoolBaseTest, |
| 1623 InitConnectionAsynchronousFailure) { | 1625 InitConnectionAsynchronousFailure) { |
| 1624 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); | 1626 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
| 1625 | 1627 |
| 1626 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob); | 1628 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob); |
| 1627 ClientSocketHandle handle; | 1629 ClientSocketHandle handle; |
| 1628 TestCompletionCallback callback; | 1630 TestCompletionCallback callback; |
| 1629 BoundTestNetLog log; | 1631 BoundTestNetLog log; |
| 1630 // Set the additional error state members to ensure that they get cleared. | 1632 // Set the additional error state members to ensure that they get cleared. |
| 1631 handle.set_is_ssl_error(true); | 1633 handle.set_is_ssl_error(true); |
| 1632 HttpResponseInfo info; | 1634 HttpResponseInfo info; |
| 1633 info.headers = new HttpResponseHeaders(std::string()); | 1635 info.headers = new HttpResponseHeaders(std::string()); |
| 1634 handle.set_ssl_error_response_info(info); | 1636 handle.set_ssl_error_response_info(info); |
| 1635 EXPECT_EQ(ERR_IO_PENDING, | 1637 EXPECT_EQ(ERR_IO_PENDING, |
| 1636 handle.Init("a", params_, DEFAULT_PRIORITY, | 1638 handle.Init("a", params_, DEFAULT_PRIORITY, |
| 1637 ClientSocketPool::RespectLimits::ENABLED, | 1639 ClientSocketPool::RespectLimits::ENABLED, |
| 1638 callback.callback(), pool_.get(), log.bound())); | 1640 callback.callback(), pool_.get(), log.bound())); |
| 1639 EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", &handle)); | 1641 EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", &handle)); |
| 1640 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_CONNECTION_FAILED)); | 1642 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_CONNECTION_FAILED)); |
| 1641 EXPECT_FALSE(handle.is_ssl_error()); | 1643 EXPECT_FALSE(handle.is_ssl_error()); |
| 1642 EXPECT_TRUE(handle.ssl_error_response_info().headers.get() == NULL); | 1644 EXPECT_TRUE(handle.ssl_error_response_info().headers.get() == NULL); |
| 1643 | 1645 |
| 1644 TestNetLogEntry::List entries; | 1646 TestNetLogEntry::List entries; |
| 1645 log.GetEntries(&entries); | 1647 log.GetEntries(&entries); |
| 1646 | 1648 |
| 1647 EXPECT_EQ(3u, entries.size()); | 1649 EXPECT_EQ(3u, entries.size()); |
| 1648 EXPECT_TRUE(LogContainsBeginEvent( | 1650 EXPECT_TRUE(LogContainsBeginEvent( |
| 1649 entries, 0, NetLog::TYPE_SOCKET_POOL)); | 1651 entries, 0, NetLogEventType::SOCKET_POOL)); |
| 1650 EXPECT_TRUE(LogContainsEvent( | 1652 EXPECT_TRUE(LogContainsEvent( |
| 1651 entries, 1, NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, | 1653 entries, 1, NetLogEventType::SOCKET_POOL_BOUND_TO_CONNECT_JOB, |
| 1652 NetLog::PHASE_NONE)); | 1654 NetLogEventPhase::NONE)); |
| 1653 EXPECT_TRUE(LogContainsEndEvent( | 1655 EXPECT_TRUE(LogContainsEndEvent( |
| 1654 entries, 2, NetLog::TYPE_SOCKET_POOL)); | 1656 entries, 2, NetLogEventType::SOCKET_POOL)); |
| 1655 } | 1657 } |
| 1656 | 1658 |
| 1657 // Check that an async ConnectJob failure does not result in creation of a new | 1659 // Check that an async ConnectJob failure does not result in creation of a new |
| 1658 // ConnectJob when there's another pending request also waiting on its own | 1660 // ConnectJob when there's another pending request also waiting on its own |
| 1659 // ConnectJob. See http://crbug.com/463960. | 1661 // ConnectJob. See http://crbug.com/463960. |
| 1660 TEST_F(ClientSocketPoolBaseTest, AsyncFailureWithPendingRequestWithJob) { | 1662 TEST_F(ClientSocketPoolBaseTest, AsyncFailureWithPendingRequestWithJob) { |
| 1661 CreatePool(2, 2); | 1663 CreatePool(2, 2); |
| 1662 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob); | 1664 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob); |
| 1663 | 1665 |
| 1664 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsError(ERR_IO_PENDING)); | 1666 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsError(ERR_IO_PENDING)); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 EXPECT_TRUE(handle.is_reused()); | 2099 EXPECT_TRUE(handle.is_reused()); |
| 2098 TestLoadTimingInfoConnectedReused(handle); | 2100 TestLoadTimingInfoConnectedReused(handle); |
| 2099 | 2101 |
| 2100 ASSERT_TRUE(pool_->HasGroup("a")); | 2102 ASSERT_TRUE(pool_->HasGroup("a")); |
| 2101 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); | 2103 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); |
| 2102 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); | 2104 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); |
| 2103 | 2105 |
| 2104 TestNetLogEntry::List entries; | 2106 TestNetLogEntry::List entries; |
| 2105 log.GetEntries(&entries); | 2107 log.GetEntries(&entries); |
| 2106 EXPECT_TRUE(LogContainsEntryWithType( | 2108 EXPECT_TRUE(LogContainsEntryWithType( |
| 2107 entries, 1, NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET)); | 2109 entries, 1, NetLogEventType::SOCKET_POOL_REUSED_AN_EXISTING_SOCKET)); |
| 2108 } | 2110 } |
| 2109 | 2111 |
| 2110 #if defined(OS_IOS) | 2112 #if defined(OS_IOS) |
| 2111 // TODO(droger): Enable this test (crbug.com/512595). | 2113 // TODO(droger): Enable this test (crbug.com/512595). |
| 2112 #define MAYBE_CleanupTimedOutIdleSocketsNoReuse \ | 2114 #define MAYBE_CleanupTimedOutIdleSocketsNoReuse \ |
| 2113 DISABLED_CleanupTimedOutIdleSocketsNoReuse | 2115 DISABLED_CleanupTimedOutIdleSocketsNoReuse |
| 2114 #else | 2116 #else |
| 2115 #define MAYBE_CleanupTimedOutIdleSocketsNoReuse \ | 2117 #define MAYBE_CleanupTimedOutIdleSocketsNoReuse \ |
| 2116 CleanupTimedOutIdleSocketsNoReuse | 2118 CleanupTimedOutIdleSocketsNoReuse |
| 2117 #endif | 2119 #endif |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 EXPECT_FALSE(handle.is_reused()); | 2177 EXPECT_FALSE(handle.is_reused()); |
| 2176 | 2178 |
| 2177 // Make sure the idle socket is closed. | 2179 // Make sure the idle socket is closed. |
| 2178 ASSERT_TRUE(pool_->HasGroup("a")); | 2180 ASSERT_TRUE(pool_->HasGroup("a")); |
| 2179 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); | 2181 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); |
| 2180 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); | 2182 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); |
| 2181 | 2183 |
| 2182 TestNetLogEntry::List entries; | 2184 TestNetLogEntry::List entries; |
| 2183 log.GetEntries(&entries); | 2185 log.GetEntries(&entries); |
| 2184 EXPECT_FALSE(LogContainsEntryWithType( | 2186 EXPECT_FALSE(LogContainsEntryWithType( |
| 2185 entries, 1, NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET)); | 2187 entries, 1, NetLogEventType::SOCKET_POOL_REUSED_AN_EXISTING_SOCKET)); |
| 2186 } | 2188 } |
| 2187 | 2189 |
| 2188 // Make sure that we process all pending requests even when we're stalling | 2190 // Make sure that we process all pending requests even when we're stalling |
| 2189 // because of multiple releasing disconnected sockets. | 2191 // because of multiple releasing disconnected sockets. |
| 2190 TEST_F(ClientSocketPoolBaseTest, MultipleReleasingDisconnectedSockets) { | 2192 TEST_F(ClientSocketPoolBaseTest, MultipleReleasingDisconnectedSockets) { |
| 2191 CreatePoolWithIdleTimeouts( | 2193 CreatePoolWithIdleTimeouts( |
| 2192 kDefaultMaxSockets, kDefaultMaxSocketsPerGroup, | 2194 kDefaultMaxSockets, kDefaultMaxSocketsPerGroup, |
| 2193 base::TimeDelta(), // Time out unused sockets immediately. | 2195 base::TimeDelta(), // Time out unused sockets immediately. |
| 2194 base::TimeDelta::FromDays(1)); // Don't time out used sockets. | 2196 base::TimeDelta::FromDays(1)); // Don't time out used sockets. |
| 2195 | 2197 |
| (...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3766 request(1)->handle()->Reset(); | 3768 request(1)->handle()->Reset(); |
| 3767 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); | 3769 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); |
| 3768 | 3770 |
| 3769 EXPECT_THAT(request(2)->WaitForResult(), IsOk()); | 3771 EXPECT_THAT(request(2)->WaitForResult(), IsOk()); |
| 3770 EXPECT_FALSE(request(1)->have_result()); | 3772 EXPECT_FALSE(request(1)->have_result()); |
| 3771 } | 3773 } |
| 3772 | 3774 |
| 3773 } // namespace | 3775 } // namespace |
| 3774 | 3776 |
| 3775 } // namespace net | 3777 } // namespace net |
| OLD | NEW |