Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: net/socket/client_socket_pool_base_unittest.cc

Issue 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Ran "git cl format" on code. Much formatting ensued. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/fuzzed_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 &client_socket_factory_, 775 &client_socket_factory_,
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());
785 EXPECT_TRUE(LogContainsBeginEvent(entries, 0,
786 NetLogEventType::SOCKET_POOL_CONNECT_JOB));
783 EXPECT_TRUE(LogContainsBeginEvent( 787 EXPECT_TRUE(LogContainsBeginEvent(
784 entries, 0, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB)); 788 entries, 1, NetLogEventType::SOCKET_POOL_CONNECT_JOB_CONNECT));
785 EXPECT_TRUE(LogContainsBeginEvent( 789 EXPECT_TRUE(LogContainsEvent(entries, 2,
786 entries, 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT)); 790 NetLogEventType::CONNECT_JOB_SET_SOCKET,
791 NetLogEventPhase::NONE));
787 EXPECT_TRUE(LogContainsEvent( 792 EXPECT_TRUE(LogContainsEvent(
788 entries, 2, NetLog::TYPE_CONNECT_JOB_SET_SOCKET, 793 entries, 3, NetLogEventType::SOCKET_POOL_CONNECT_JOB_TIMED_OUT,
789 NetLog::PHASE_NONE)); 794 NetLogEventPhase::NONE));
790 EXPECT_TRUE(LogContainsEvent(
791 entries, 3, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_TIMED_OUT,
792 NetLog::PHASE_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(entries, 5,
796 entries, 5, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB)); 798 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(entries, 0, NetLogEventType::SOCKET_POOL));
822 entries, 0, NetLog::TYPE_SOCKET_POOL));
823 EXPECT_TRUE(LogContainsEvent( 824 EXPECT_TRUE(LogContainsEvent(
824 entries, 1, NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, 825 entries, 1, NetLogEventType::SOCKET_POOL_BOUND_TO_CONNECT_JOB,
825 NetLog::PHASE_NONE)); 826 NetLogEventPhase::NONE));
826 EXPECT_TRUE(LogContainsEvent( 827 EXPECT_TRUE(LogContainsEvent(entries, 2,
827 entries, 2, NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, 828 NetLogEventType::SOCKET_POOL_BOUND_TO_SOCKET,
828 NetLog::PHASE_NONE)); 829 NetLogEventPhase::NONE));
829 EXPECT_TRUE(LogContainsEndEvent( 830 EXPECT_TRUE(LogContainsEndEvent(entries, 3, NetLogEventType::SOCKET_POOL));
830 entries, 3, NetLog::TYPE_SOCKET_POOL));
831 } 831 }
832 832
833 TEST_F(ClientSocketPoolBaseTest, InitConnectionFailure) { 833 TEST_F(ClientSocketPoolBaseTest, InitConnectionFailure) {
834 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); 834 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
835 835
836 connect_job_factory_->set_job_type(TestConnectJob::kMockFailingJob); 836 connect_job_factory_->set_job_type(TestConnectJob::kMockFailingJob);
837 BoundTestNetLog log; 837 BoundTestNetLog log;
838 838
839 ClientSocketHandle handle; 839 ClientSocketHandle handle;
840 TestCompletionCallback callback; 840 TestCompletionCallback callback;
841 // Set the additional error state members to ensure that they get cleared. 841 // Set the additional error state members to ensure that they get cleared.
842 handle.set_is_ssl_error(true); 842 handle.set_is_ssl_error(true);
843 HttpResponseInfo info; 843 HttpResponseInfo info;
844 info.headers = new HttpResponseHeaders(std::string()); 844 info.headers = new HttpResponseHeaders(std::string());
845 handle.set_ssl_error_response_info(info); 845 handle.set_ssl_error_response_info(info);
846 EXPECT_EQ(ERR_CONNECTION_FAILED, 846 EXPECT_EQ(ERR_CONNECTION_FAILED,
847 handle.Init("a", params_, DEFAULT_PRIORITY, 847 handle.Init("a", params_, DEFAULT_PRIORITY,
848 ClientSocketPool::RespectLimits::ENABLED, 848 ClientSocketPool::RespectLimits::ENABLED,
849 callback.callback(), pool_.get(), log.bound())); 849 callback.callback(), pool_.get(), log.bound()));
850 EXPECT_FALSE(handle.socket()); 850 EXPECT_FALSE(handle.socket());
851 EXPECT_FALSE(handle.is_ssl_error()); 851 EXPECT_FALSE(handle.is_ssl_error());
852 EXPECT_TRUE(handle.ssl_error_response_info().headers.get() == NULL); 852 EXPECT_TRUE(handle.ssl_error_response_info().headers.get() == NULL);
853 TestLoadTimingInfoNotConnected(handle); 853 TestLoadTimingInfoNotConnected(handle);
854 854
855 TestNetLogEntry::List entries; 855 TestNetLogEntry::List entries;
856 log.GetEntries(&entries); 856 log.GetEntries(&entries);
857 857
858 EXPECT_EQ(3u, entries.size()); 858 EXPECT_EQ(3u, entries.size());
859 EXPECT_TRUE(LogContainsBeginEvent( 859 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, NetLogEventType::SOCKET_POOL));
860 entries, 0, NetLog::TYPE_SOCKET_POOL));
861 EXPECT_TRUE(LogContainsEvent( 860 EXPECT_TRUE(LogContainsEvent(
862 entries, 1, NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, 861 entries, 1, NetLogEventType::SOCKET_POOL_BOUND_TO_CONNECT_JOB,
863 NetLog::PHASE_NONE)); 862 NetLogEventPhase::NONE));
864 EXPECT_TRUE(LogContainsEndEvent( 863 EXPECT_TRUE(LogContainsEndEvent(entries, 2, NetLogEventType::SOCKET_POOL));
865 entries, 2, NetLog::TYPE_SOCKET_POOL));
866 } 864 }
867 865
868 TEST_F(ClientSocketPoolBaseTest, TotalLimit) { 866 TEST_F(ClientSocketPoolBaseTest, TotalLimit) {
869 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); 867 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
870 868
871 // TODO(eroman): Check that the NetLog contains this event. 869 // TODO(eroman): Check that the NetLog contains this event.
872 870
873 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsOk()); 871 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsOk());
874 EXPECT_THAT(StartRequest("b", DEFAULT_PRIORITY), IsOk()); 872 EXPECT_THAT(StartRequest("b", DEFAULT_PRIORITY), IsOk());
875 EXPECT_THAT(StartRequest("c", DEFAULT_PRIORITY), IsOk()); 873 EXPECT_THAT(StartRequest("c", DEFAULT_PRIORITY), IsOk());
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 EXPECT_TRUE(handle.socket()); 1598 EXPECT_TRUE(handle.socket());
1601 TestLoadTimingInfoConnectedNotReused(handle); 1599 TestLoadTimingInfoConnectedNotReused(handle);
1602 1600
1603 handle.Reset(); 1601 handle.Reset();
1604 TestLoadTimingInfoNotConnected(handle); 1602 TestLoadTimingInfoNotConnected(handle);
1605 1603
1606 TestNetLogEntry::List entries; 1604 TestNetLogEntry::List entries;
1607 log.GetEntries(&entries); 1605 log.GetEntries(&entries);
1608 1606
1609 EXPECT_EQ(4u, entries.size()); 1607 EXPECT_EQ(4u, entries.size());
1610 EXPECT_TRUE(LogContainsBeginEvent( 1608 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, NetLogEventType::SOCKET_POOL));
1611 entries, 0, NetLog::TYPE_SOCKET_POOL));
1612 EXPECT_TRUE(LogContainsEvent( 1609 EXPECT_TRUE(LogContainsEvent(
1613 entries, 1, NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, 1610 entries, 1, NetLogEventType::SOCKET_POOL_BOUND_TO_CONNECT_JOB,
1614 NetLog::PHASE_NONE)); 1611 NetLogEventPhase::NONE));
1615 EXPECT_TRUE(LogContainsEvent( 1612 EXPECT_TRUE(LogContainsEvent(entries, 2,
1616 entries, 2, NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, 1613 NetLogEventType::SOCKET_POOL_BOUND_TO_SOCKET,
1617 NetLog::PHASE_NONE)); 1614 NetLogEventPhase::NONE));
1618 EXPECT_TRUE(LogContainsEndEvent( 1615 EXPECT_TRUE(LogContainsEndEvent(entries, 3, NetLogEventType::SOCKET_POOL));
1619 entries, 3, NetLog::TYPE_SOCKET_POOL));
1620 } 1616 }
1621 1617
1622 TEST_F(ClientSocketPoolBaseTest, 1618 TEST_F(ClientSocketPoolBaseTest,
1623 InitConnectionAsynchronousFailure) { 1619 InitConnectionAsynchronousFailure) {
1624 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); 1620 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
1625 1621
1626 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob); 1622 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob);
1627 ClientSocketHandle handle; 1623 ClientSocketHandle handle;
1628 TestCompletionCallback callback; 1624 TestCompletionCallback callback;
1629 BoundTestNetLog log; 1625 BoundTestNetLog log;
1630 // Set the additional error state members to ensure that they get cleared. 1626 // Set the additional error state members to ensure that they get cleared.
1631 handle.set_is_ssl_error(true); 1627 handle.set_is_ssl_error(true);
1632 HttpResponseInfo info; 1628 HttpResponseInfo info;
1633 info.headers = new HttpResponseHeaders(std::string()); 1629 info.headers = new HttpResponseHeaders(std::string());
1634 handle.set_ssl_error_response_info(info); 1630 handle.set_ssl_error_response_info(info);
1635 EXPECT_EQ(ERR_IO_PENDING, 1631 EXPECT_EQ(ERR_IO_PENDING,
1636 handle.Init("a", params_, DEFAULT_PRIORITY, 1632 handle.Init("a", params_, DEFAULT_PRIORITY,
1637 ClientSocketPool::RespectLimits::ENABLED, 1633 ClientSocketPool::RespectLimits::ENABLED,
1638 callback.callback(), pool_.get(), log.bound())); 1634 callback.callback(), pool_.get(), log.bound()));
1639 EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", &handle)); 1635 EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", &handle));
1640 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_CONNECTION_FAILED)); 1636 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_CONNECTION_FAILED));
1641 EXPECT_FALSE(handle.is_ssl_error()); 1637 EXPECT_FALSE(handle.is_ssl_error());
1642 EXPECT_TRUE(handle.ssl_error_response_info().headers.get() == NULL); 1638 EXPECT_TRUE(handle.ssl_error_response_info().headers.get() == NULL);
1643 1639
1644 TestNetLogEntry::List entries; 1640 TestNetLogEntry::List entries;
1645 log.GetEntries(&entries); 1641 log.GetEntries(&entries);
1646 1642
1647 EXPECT_EQ(3u, entries.size()); 1643 EXPECT_EQ(3u, entries.size());
1648 EXPECT_TRUE(LogContainsBeginEvent( 1644 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, NetLogEventType::SOCKET_POOL));
1649 entries, 0, NetLog::TYPE_SOCKET_POOL));
1650 EXPECT_TRUE(LogContainsEvent( 1645 EXPECT_TRUE(LogContainsEvent(
1651 entries, 1, NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, 1646 entries, 1, NetLogEventType::SOCKET_POOL_BOUND_TO_CONNECT_JOB,
1652 NetLog::PHASE_NONE)); 1647 NetLogEventPhase::NONE));
1653 EXPECT_TRUE(LogContainsEndEvent( 1648 EXPECT_TRUE(LogContainsEndEvent(entries, 2, NetLogEventType::SOCKET_POOL));
1654 entries, 2, NetLog::TYPE_SOCKET_POOL));
1655 } 1649 }
1656 1650
1657 // Check that an async ConnectJob failure does not result in creation of a new 1651 // 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 1652 // ConnectJob when there's another pending request also waiting on its own
1659 // ConnectJob. See http://crbug.com/463960. 1653 // ConnectJob. See http://crbug.com/463960.
1660 TEST_F(ClientSocketPoolBaseTest, AsyncFailureWithPendingRequestWithJob) { 1654 TEST_F(ClientSocketPoolBaseTest, AsyncFailureWithPendingRequestWithJob) {
1661 CreatePool(2, 2); 1655 CreatePool(2, 2);
1662 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob); 1656 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob);
1663 1657
1664 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsError(ERR_IO_PENDING)); 1658 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsError(ERR_IO_PENDING));
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 EXPECT_TRUE(handle.is_reused()); 2091 EXPECT_TRUE(handle.is_reused());
2098 TestLoadTimingInfoConnectedReused(handle); 2092 TestLoadTimingInfoConnectedReused(handle);
2099 2093
2100 ASSERT_TRUE(pool_->HasGroup("a")); 2094 ASSERT_TRUE(pool_->HasGroup("a"));
2101 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); 2095 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a"));
2102 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); 2096 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a"));
2103 2097
2104 TestNetLogEntry::List entries; 2098 TestNetLogEntry::List entries;
2105 log.GetEntries(&entries); 2099 log.GetEntries(&entries);
2106 EXPECT_TRUE(LogContainsEntryWithType( 2100 EXPECT_TRUE(LogContainsEntryWithType(
2107 entries, 1, NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET)); 2101 entries, 1, NetLogEventType::SOCKET_POOL_REUSED_AN_EXISTING_SOCKET));
2108 } 2102 }
2109 2103
2110 #if defined(OS_IOS) 2104 #if defined(OS_IOS)
2111 // TODO(droger): Enable this test (crbug.com/512595). 2105 // TODO(droger): Enable this test (crbug.com/512595).
2112 #define MAYBE_CleanupTimedOutIdleSocketsNoReuse \ 2106 #define MAYBE_CleanupTimedOutIdleSocketsNoReuse \
2113 DISABLED_CleanupTimedOutIdleSocketsNoReuse 2107 DISABLED_CleanupTimedOutIdleSocketsNoReuse
2114 #else 2108 #else
2115 #define MAYBE_CleanupTimedOutIdleSocketsNoReuse \ 2109 #define MAYBE_CleanupTimedOutIdleSocketsNoReuse \
2116 CleanupTimedOutIdleSocketsNoReuse 2110 CleanupTimedOutIdleSocketsNoReuse
2117 #endif 2111 #endif
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 EXPECT_FALSE(handle.is_reused()); 2169 EXPECT_FALSE(handle.is_reused());
2176 2170
2177 // Make sure the idle socket is closed. 2171 // Make sure the idle socket is closed.
2178 ASSERT_TRUE(pool_->HasGroup("a")); 2172 ASSERT_TRUE(pool_->HasGroup("a"));
2179 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); 2173 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a"));
2180 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); 2174 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a"));
2181 2175
2182 TestNetLogEntry::List entries; 2176 TestNetLogEntry::List entries;
2183 log.GetEntries(&entries); 2177 log.GetEntries(&entries);
2184 EXPECT_FALSE(LogContainsEntryWithType( 2178 EXPECT_FALSE(LogContainsEntryWithType(
2185 entries, 1, NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET)); 2179 entries, 1, NetLogEventType::SOCKET_POOL_REUSED_AN_EXISTING_SOCKET));
2186 } 2180 }
2187 2181
2188 // Make sure that we process all pending requests even when we're stalling 2182 // Make sure that we process all pending requests even when we're stalling
2189 // because of multiple releasing disconnected sockets. 2183 // because of multiple releasing disconnected sockets.
2190 TEST_F(ClientSocketPoolBaseTest, MultipleReleasingDisconnectedSockets) { 2184 TEST_F(ClientSocketPoolBaseTest, MultipleReleasingDisconnectedSockets) {
2191 CreatePoolWithIdleTimeouts( 2185 CreatePoolWithIdleTimeouts(
2192 kDefaultMaxSockets, kDefaultMaxSocketsPerGroup, 2186 kDefaultMaxSockets, kDefaultMaxSocketsPerGroup,
2193 base::TimeDelta(), // Time out unused sockets immediately. 2187 base::TimeDelta(), // Time out unused sockets immediately.
2194 base::TimeDelta::FromDays(1)); // Don't time out used sockets. 2188 base::TimeDelta::FromDays(1)); // Don't time out used sockets.
2195 2189
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
3766 request(1)->handle()->Reset(); 3760 request(1)->handle()->Reset();
3767 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); 3761 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a"));
3768 3762
3769 EXPECT_THAT(request(2)->WaitForResult(), IsOk()); 3763 EXPECT_THAT(request(2)->WaitForResult(), IsOk());
3770 EXPECT_FALSE(request(1)->have_result()); 3764 EXPECT_FALSE(request(1)->have_result());
3771 } 3765 }
3772 3766
3773 } // namespace 3767 } // namespace
3774 3768
3775 } // namespace net 3769 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/fuzzed_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698