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

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

Issue 165217: Revert 22811 - Merge 21988 Fix crash in client_socket_pool_base.cc.... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Reverse-merged /trunk/src/net/socket/client_socket_pool_base_unittest.cc:r21988
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/scoped_vector.h" 9 #include "base/scoped_vector.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 EXPECT_FALSE(req2.handle.socket()); 818 EXPECT_FALSE(req2.handle.socket());
819 client_socket_factory_.SignalJobs(); 819 client_socket_factory_.SignalJobs();
820 EXPECT_EQ(OK, req2.WaitForResult()); 820 EXPECT_EQ(OK, req2.WaitForResult());
821 821
822 ASSERT_EQ(2U, request_order_.size()); 822 ASSERT_EQ(2U, request_order_.size());
823 EXPECT_EQ(&req1, request_order_[0]); 823 EXPECT_EQ(&req1, request_order_[0]);
824 EXPECT_EQ(&req2, request_order_[1]); 824 EXPECT_EQ(&req2, request_order_[1]);
825 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); 825 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a"));
826 } 826 }
827 827
828 // Regression test for http://crbug.com/17985.
829 TEST_F(ClientSocketPoolBaseTest, GroupWithPendingRequestsIsNotEmpty) {
830 const int kMaxSockets = 3;
831 const int kMaxSocketsPerGroup = 2;
832 CreatePool(kMaxSockets, kMaxSocketsPerGroup);
833
834 const int kHighPriority = kDefaultPriority + 100;
835
836 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
837 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
838
839 // This is going to be a pending request in an otherwise empty group.
840 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority));
841
842 // Reach the maximum socket limit.
843 EXPECT_EQ(OK, StartRequest("b", kDefaultPriority));
844
845 // Create a stalled group with high priorities.
846 EXPECT_EQ(ERR_IO_PENDING, StartRequest("c", kHighPriority));
847 EXPECT_EQ(ERR_IO_PENDING, StartRequest("c", kHighPriority));
848 EXPECT_TRUE(pool_->base()->may_have_stalled_group());
849
850 // Release the first two sockets from "a", which will make room
851 // for requests from "c". After that "a" will have no active sockets
852 // and one pending request.
853 EXPECT_TRUE(ReleaseOneConnection(KEEP_ALIVE));
854 EXPECT_TRUE(ReleaseOneConnection(KEEP_ALIVE));
855
856 // Closing idle sockets should not get us into trouble, but in the bug
857 // we were hitting a CHECK here.
858 EXPECT_EQ(2, pool_->IdleSocketCountInGroup("a"));
859 pool_->CloseIdleSockets();
860 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a"));
861 }
862
863 class ClientSocketPoolBaseTest_LateBinding : public ClientSocketPoolBaseTest { 828 class ClientSocketPoolBaseTest_LateBinding : public ClientSocketPoolBaseTest {
864 protected: 829 protected:
865 virtual void SetUp() { 830 virtual void SetUp() {
866 ClientSocketPoolBaseTest::SetUp(); 831 ClientSocketPoolBaseTest::SetUp();
867 ClientSocketPoolBase::EnableLateBindingOfSockets(true); 832 ClientSocketPoolBase::EnableLateBindingOfSockets(true);
868 } 833 }
869 }; 834 };
870 835
871 TEST_F(ClientSocketPoolBaseTest_LateBinding, BasicSynchronous) { 836 TEST_F(ClientSocketPoolBaseTest_LateBinding, BasicSynchronous) {
872 CreatePool(kDefaultMaxSocketsPerGroup); 837 CreatePool(kDefaultMaxSocketsPerGroup);
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 1216
1252 MessageLoop::current()->RunAllPending(); 1217 MessageLoop::current()->RunAllPending();
1253 1218
1254 TestSocketRequest req2(pool_.get(), &request_order_); 1219 TestSocketRequest req2(pool_.get(), &request_order_);
1255 rv = req2.handle.Init("a", ignored_request_info_, 5, &req2); 1220 rv = req2.handle.Init("a", ignored_request_info_, 5, &req2);
1256 EXPECT_EQ(ERR_IO_PENDING, rv); 1221 EXPECT_EQ(ERR_IO_PENDING, rv);
1257 EXPECT_EQ(LOAD_STATE_WAITING_FOR_CACHE, req1.handle.GetLoadState()); 1222 EXPECT_EQ(LOAD_STATE_WAITING_FOR_CACHE, req1.handle.GetLoadState());
1258 EXPECT_EQ(LOAD_STATE_WAITING_FOR_CACHE, req2.handle.GetLoadState()); 1223 EXPECT_EQ(LOAD_STATE_WAITING_FOR_CACHE, req2.handle.GetLoadState());
1259 } 1224 }
1260 1225
1261 // Regression test for http://crbug.com/17985.
1262 TEST_F(ClientSocketPoolBaseTest_LateBinding,
1263 GroupWithPendingRequestsIsNotEmpty) {
1264 const int kMaxSockets = 3;
1265 const int kMaxSocketsPerGroup = 2;
1266 CreatePool(kMaxSockets, kMaxSocketsPerGroup);
1267
1268 const int kHighPriority = kDefaultPriority + 100;
1269
1270 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
1271 EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
1272
1273 // This is going to be a pending request in an otherwise empty group.
1274 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority));
1275
1276 // Reach the maximum socket limit.
1277 EXPECT_EQ(OK, StartRequest("b", kDefaultPriority));
1278
1279 // Create a stalled group with high priorities.
1280 EXPECT_EQ(ERR_IO_PENDING, StartRequest("c", kHighPriority));
1281 EXPECT_EQ(ERR_IO_PENDING, StartRequest("c", kHighPriority));
1282 EXPECT_TRUE(pool_->base()->may_have_stalled_group());
1283
1284 // Release the first two sockets from "a", which will make room
1285 // for requests from "c". After that "a" will have no active sockets
1286 // and one pending request.
1287 EXPECT_TRUE(ReleaseOneConnection(KEEP_ALIVE));
1288 EXPECT_TRUE(ReleaseOneConnection(KEEP_ALIVE));
1289
1290 // Closing idle sockets should not get us into trouble, but in the bug
1291 // we were hitting a CHECK here.
1292 EXPECT_EQ(2, pool_->IdleSocketCountInGroup("a"));
1293 pool_->CloseIdleSockets();
1294 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a"));
1295 }
1296
1297 } // namespace 1226 } // namespace
1298 1227
1299 } // namespace net 1228 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698