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

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

Issue 981643002: Fix bug that would create unnecessary ConnectJobs in some cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix stuff Created 5 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
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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 EXPECT_EQ(3u, entries.size()); 1743 EXPECT_EQ(3u, entries.size());
1744 EXPECT_TRUE(LogContainsBeginEvent( 1744 EXPECT_TRUE(LogContainsBeginEvent(
1745 entries, 0, NetLog::TYPE_SOCKET_POOL)); 1745 entries, 0, NetLog::TYPE_SOCKET_POOL));
1746 EXPECT_TRUE(LogContainsEvent( 1746 EXPECT_TRUE(LogContainsEvent(
1747 entries, 1, NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, 1747 entries, 1, NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB,
1748 NetLog::PHASE_NONE)); 1748 NetLog::PHASE_NONE));
1749 EXPECT_TRUE(LogContainsEndEvent( 1749 EXPECT_TRUE(LogContainsEndEvent(
1750 entries, 2, NetLog::TYPE_SOCKET_POOL)); 1750 entries, 2, NetLog::TYPE_SOCKET_POOL));
1751 } 1751 }
1752 1752
1753 // Check that an async ConnectJob failure does not result in creation of a new
1754 // ConnectJob when there's another pending request also waiting on its own
1755 // ConnectJob. See http://crbug.com/463960.
1756 TEST_F(ClientSocketPoolBaseTest, AsyncFailureWithPendingRequestWithJob) {
1757 CreatePool(2, 2);
1758 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob);
1759
1760 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", DEFAULT_PRIORITY));
1761 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", DEFAULT_PRIORITY));
1762
1763 EXPECT_EQ(ERR_CONNECTION_FAILED, request(0)->WaitForResult());
1764 EXPECT_EQ(ERR_CONNECTION_FAILED, request(1)->WaitForResult());
1765
1766 EXPECT_EQ(2, client_socket_factory_.allocation_count());
1767 }
1768
1753 TEST_F(ClientSocketPoolBaseTest, TwoRequestsCancelOne) { 1769 TEST_F(ClientSocketPoolBaseTest, TwoRequestsCancelOne) {
1754 // TODO(eroman): Add back the log expectations! Removed them because the 1770 // TODO(eroman): Add back the log expectations! Removed them because the
1755 // ordering is difficult, and some may fire during destructor. 1771 // ordering is difficult, and some may fire during destructor.
1756 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); 1772 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
1757 1773
1758 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob); 1774 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
1759 ClientSocketHandle handle; 1775 ClientSocketHandle handle;
1760 TestCompletionCallback callback; 1776 TestCompletionCallback callback;
1761 ClientSocketHandle handle2; 1777 ClientSocketHandle handle2;
1762 TestCompletionCallback callback2; 1778 TestCompletionCallback callback2;
(...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after
4094 request(1)->handle()->Reset(); 4110 request(1)->handle()->Reset();
4095 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); 4111 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a"));
4096 4112
4097 EXPECT_EQ(OK, request(2)->WaitForResult()); 4113 EXPECT_EQ(OK, request(2)->WaitForResult());
4098 EXPECT_FALSE(request(1)->have_result()); 4114 EXPECT_FALSE(request(1)->have_result());
4099 } 4115 }
4100 4116
4101 } // namespace 4117 } // namespace
4102 4118
4103 } // namespace net 4119 } // namespace net
OLDNEW
« net/socket/client_socket_pool_base.cc ('K') | « 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