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

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

Issue 1120007: Disable backup connect jobs for all pools except TCPClientSocketPool (Closed)
Patch Set: Created 10 years, 9 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/tcp_client_socket_pool.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) 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 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 TestSocketRequest req(&request_order_, &completion_count_); 1120 TestSocketRequest req(&request_order_, &completion_count_);
1121 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); 1121 CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
1122 int rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_.get(), log.bound()) ; 1122 int rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_.get(), log.bound()) ;
1123 EXPECT_EQ(ERR_IO_PENDING, rv); 1123 EXPECT_EQ(ERR_IO_PENDING, rv);
1124 EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req.handle())); 1124 EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req.handle()));
1125 EXPECT_EQ(OK, req.WaitForResult()); 1125 EXPECT_EQ(OK, req.WaitForResult());
1126 EXPECT_TRUE(req.handle()->is_initialized()); 1126 EXPECT_TRUE(req.handle()->is_initialized());
1127 EXPECT_TRUE(req.handle()->socket()); 1127 EXPECT_TRUE(req.handle()->socket());
1128 req.handle()->Reset(); 1128 req.handle()->Reset();
1129 1129
1130 EXPECT_EQ(7u, log.entries().size()); 1130 EXPECT_EQ(5u, log.entries().size());
1131 EXPECT_TRUE(LogContainsBeginEvent( 1131 EXPECT_TRUE(LogContainsBeginEvent(
1132 log.entries(), 0, NetLog::TYPE_SOCKET_POOL)); 1132 log.entries(), 0, NetLog::TYPE_SOCKET_POOL));
1133 EXPECT_TRUE(LogContainsBeginEvent( 1133 EXPECT_TRUE(LogContainsBeginEvent(
1134 log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB)); 1134 log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
1135 EXPECT_TRUE(LogContainsEndEvent( 1135 EXPECT_TRUE(LogContainsEndEvent(
1136 log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB)); 1136 log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
1137 EXPECT_TRUE(LogContainsEvent(
1138 log.entries(), 3, NetLog::TYPE_CANCELLED, NetLog::PHASE_NONE));
1139 EXPECT_TRUE(LogContainsEndEvent( 1137 EXPECT_TRUE(LogContainsEndEvent(
1140 log.entries(), 4, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB)); 1138 log.entries(), 4, NetLog::TYPE_SOCKET_POOL));
1141 EXPECT_TRUE(LogContainsEndEvent(
1142 log.entries(), 6, NetLog::TYPE_SOCKET_POOL));
1143 } 1139 }
1144 1140
1145 TEST_F(ClientSocketPoolBaseTest, 1141 TEST_F(ClientSocketPoolBaseTest,
1146 InitConnectionAsynchronousFailure) { 1142 InitConnectionAsynchronousFailure) {
1147 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); 1143 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
1148 1144
1149 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob); 1145 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob);
1150 TestSocketRequest req(&request_order_, &completion_count_); 1146 TestSocketRequest req(&request_order_, &completion_count_);
1151 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); 1147 CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
1152 EXPECT_EQ(ERR_IO_PENDING, 1148 EXPECT_EQ(ERR_IO_PENDING,
1153 InitHandle(req.handle(), "a", kDefaultPriority, &req, 1149 InitHandle(req.handle(), "a", kDefaultPriority, &req,
1154 pool_.get(), log.bound())); 1150 pool_.get(), log.bound()));
1155 EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req.handle())); 1151 EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req.handle()));
1156 EXPECT_EQ(ERR_CONNECTION_FAILED, req.WaitForResult()); 1152 EXPECT_EQ(ERR_CONNECTION_FAILED, req.WaitForResult());
1157 1153
1158 EXPECT_EQ(7u, log.entries().size()); 1154 EXPECT_EQ(5u, log.entries().size());
1159 EXPECT_TRUE(LogContainsBeginEvent( 1155 EXPECT_TRUE(LogContainsBeginEvent(
1160 log.entries(), 0, NetLog::TYPE_SOCKET_POOL)); 1156 log.entries(), 0, NetLog::TYPE_SOCKET_POOL));
1161 EXPECT_TRUE(LogContainsBeginEvent( 1157 EXPECT_TRUE(LogContainsBeginEvent(
1162 log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB)); 1158 log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
1163 EXPECT_TRUE(LogContainsEndEvent( 1159 EXPECT_TRUE(LogContainsEndEvent(
1164 log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB)); 1160 log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
1165 EXPECT_TRUE(LogContainsEvent(
1166 log.entries(), 3, NetLog::TYPE_CANCELLED, NetLog::PHASE_NONE));
1167 EXPECT_TRUE(LogContainsEndEvent( 1161 EXPECT_TRUE(LogContainsEndEvent(
1168 log.entries(), 4, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB)); 1162 log.entries(), 4, NetLog::TYPE_SOCKET_POOL));
1169 EXPECT_TRUE(LogContainsEndEvent(
1170 log.entries(), 6, NetLog::TYPE_SOCKET_POOL));
1171 } 1163 }
1172 1164
1173 TEST_F(ClientSocketPoolBaseTest, TwoRequestsCancelOne) { 1165 TEST_F(ClientSocketPoolBaseTest, TwoRequestsCancelOne) {
1174 // TODO(eroman): Add back the log expectations! Removed them because the 1166 // TODO(eroman): Add back the log expectations! Removed them because the
1175 // ordering is difficult, and some may fire during destructor. 1167 // ordering is difficult, and some may fire during destructor.
1176 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); 1168 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
1177 1169
1178 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob); 1170 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
1179 TestSocketRequest req(&request_order_, &completion_count_); 1171 TestSocketRequest req(&request_order_, &completion_count_);
1180 TestSocketRequest req2(&request_order_, &completion_count_); 1172 TestSocketRequest req2(&request_order_, &completion_count_);
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 EXPECT_EQ(ERR_IO_PENDING, 1488 EXPECT_EQ(ERR_IO_PENDING,
1497 InitHandle(request.handle(), "a", kDefaultPriority, &request, 1489 InitHandle(request.handle(), "a", kDefaultPriority, &request,
1498 pool_.get(), NULL)); 1490 pool_.get(), NULL));
1499 1491
1500 EXPECT_EQ(OK, request.WaitForResult()); 1492 EXPECT_EQ(OK, request.WaitForResult());
1501 } 1493 }
1502 1494
1503 } // namespace 1495 } // namespace
1504 1496
1505 } // namespace net 1497 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/tcp_client_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698