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

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

Issue 2647003: Do not attempt to reuse active sockets after a socket pool flush (usually a network change). (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Address eroman comments. Created 10 years, 6 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/socks_client_socket_pool.h » ('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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 303 }
304 304
305 virtual void CancelRequest( 305 virtual void CancelRequest(
306 const std::string& group_name, 306 const std::string& group_name,
307 const ClientSocketHandle* handle) { 307 const ClientSocketHandle* handle) {
308 base_.CancelRequest(group_name, handle); 308 base_.CancelRequest(group_name, handle);
309 } 309 }
310 310
311 virtual void ReleaseSocket( 311 virtual void ReleaseSocket(
312 const std::string& group_name, 312 const std::string& group_name,
313 ClientSocket* socket) { 313 ClientSocket* socket,
314 base_.ReleaseSocket(group_name, socket); 314 int id) {
315 base_.ReleaseSocket(group_name, socket, id);
316 }
317
318 virtual void Flush() {
319 base_.Flush();
315 } 320 }
316 321
317 virtual void CloseIdleSockets() { 322 virtual void CloseIdleSockets() {
318 base_.CloseIdleSockets(); 323 base_.CloseIdleSockets();
319 } 324 }
320 325
321 virtual int IdleSocketCount() const { return base_.idle_socket_count(); } 326 virtual int IdleSocketCount() const { return base_.idle_socket_count(); }
322 327
323 virtual int IdleSocketCountInGroup(const std::string& group_name) const { 328 virtual int IdleSocketCountInGroup(const std::string& group_name) const {
324 return base_.IdleSocketCountInGroup(group_name); 329 return base_.IdleSocketCountInGroup(group_name);
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 InitHandle(&handle, "a", kDefaultPriority, 1658 InitHandle(&handle, "a", kDefaultPriority,
1654 &callback, pool_, BoundNetLog())); 1659 &callback, pool_, BoundNetLog()));
1655 1660
1656 // Simulate flushing the pool. 1661 // Simulate flushing the pool.
1657 pool_ = NULL; 1662 pool_ = NULL;
1658 1663
1659 // We'll call back into this now. 1664 // We'll call back into this now.
1660 callback.WaitForResult(); 1665 callback.WaitForResult();
1661 } 1666 }
1662 1667
1668 TEST_F(ClientSocketPoolBaseTest, DoNotReuseSocketAfterFlush) {
1669 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
1670 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
1671
1672 ClientSocketHandle handle;
1673 TestCompletionCallback callback;
1674 EXPECT_EQ(ERR_IO_PENDING,
1675 InitHandle(&handle, "a", kDefaultPriority,
1676 &callback, pool_, BoundNetLog()));
1677 EXPECT_EQ(OK, callback.WaitForResult());
1678 EXPECT_EQ(ClientSocketHandle::UNUSED, handle.reuse_type());
1679
1680 pool_->Flush();
1681
1682 handle.Reset();
1683 MessageLoop::current()->RunAllPending();
1684
1685 EXPECT_EQ(ERR_IO_PENDING,
1686 InitHandle(&handle, "a", kDefaultPriority,
1687 &callback, pool_, BoundNetLog()));
1688 EXPECT_EQ(OK, callback.WaitForResult());
1689 EXPECT_EQ(ClientSocketHandle::UNUSED, handle.reuse_type());
1690 }
1691
1663 } // namespace 1692 } // namespace
1664 1693
1665 } // namespace net 1694 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/socks_client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698