| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 unused_idle_socket_timeout, used_idle_socket_timeout, | 418 unused_idle_socket_timeout, used_idle_socket_timeout, |
| 419 connect_job_factory) {} | 419 connect_job_factory) {} |
| 420 | 420 |
| 421 virtual ~TestClientSocketPool() {} | 421 virtual ~TestClientSocketPool() {} |
| 422 | 422 |
| 423 virtual int RequestSocket( | 423 virtual int RequestSocket( |
| 424 const std::string& group_name, | 424 const std::string& group_name, |
| 425 const void* params, | 425 const void* params, |
| 426 net::RequestPriority priority, | 426 net::RequestPriority priority, |
| 427 ClientSocketHandle* handle, | 427 ClientSocketHandle* handle, |
| 428 OldCompletionCallback* callback, | 428 const CompletionCallback& callback, |
| 429 const BoundNetLog& net_log) OVERRIDE { | 429 const BoundNetLog& net_log) OVERRIDE { |
| 430 const scoped_refptr<TestSocketParams>* casted_socket_params = | 430 const scoped_refptr<TestSocketParams>* casted_socket_params = |
| 431 static_cast<const scoped_refptr<TestSocketParams>*>(params); | 431 static_cast<const scoped_refptr<TestSocketParams>*>(params); |
| 432 return base_.RequestSocket(group_name, *casted_socket_params, priority, | 432 return base_.RequestSocket(group_name, *casted_socket_params, priority, |
| 433 handle, callback, net_log); | 433 handle, callback, net_log); |
| 434 } | 434 } |
| 435 | 435 |
| 436 virtual void RequestSockets(const std::string& group_name, | 436 virtual void RequestSockets(const std::string& group_name, |
| 437 const void* params, | 437 const void* params, |
| 438 int num_sockets, | 438 int num_sockets, |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 EXPECT_EQ(sockets_[3], req->handle()->socket()); | 721 EXPECT_EQ(sockets_[3], req->handle()->socket()); |
| 722 ReleaseAllConnections(ClientSocketPoolTest::NO_KEEP_ALIVE); | 722 ReleaseAllConnections(ClientSocketPoolTest::NO_KEEP_ALIVE); |
| 723 } | 723 } |
| 724 | 724 |
| 725 // Even though a timeout is specified, it doesn't time out on a synchronous | 725 // Even though a timeout is specified, it doesn't time out on a synchronous |
| 726 // completion. | 726 // completion. |
| 727 TEST_F(ClientSocketPoolBaseTest, ConnectJob_NoTimeoutOnSynchronousCompletion) { | 727 TEST_F(ClientSocketPoolBaseTest, ConnectJob_NoTimeoutOnSynchronousCompletion) { |
| 728 TestConnectJobDelegate delegate; | 728 TestConnectJobDelegate delegate; |
| 729 ClientSocketHandle ignored; | 729 ClientSocketHandle ignored; |
| 730 TestClientSocketPoolBase::Request request( | 730 TestClientSocketPoolBase::Request request( |
| 731 &ignored, NULL, kDefaultPriority, | 731 &ignored, CompletionCallback(), kDefaultPriority, |
| 732 internal::ClientSocketPoolBaseHelper::NORMAL, | 732 internal::ClientSocketPoolBaseHelper::NORMAL, |
| 733 false, params_, BoundNetLog()); | 733 false, params_, BoundNetLog()); |
| 734 scoped_ptr<TestConnectJob> job( | 734 scoped_ptr<TestConnectJob> job( |
| 735 new TestConnectJob(TestConnectJob::kMockJob, | 735 new TestConnectJob(TestConnectJob::kMockJob, |
| 736 "a", | 736 "a", |
| 737 request, | 737 request, |
| 738 base::TimeDelta::FromMicroseconds(1), | 738 base::TimeDelta::FromMicroseconds(1), |
| 739 &delegate, | 739 &delegate, |
| 740 &client_socket_factory_, | 740 &client_socket_factory_, |
| 741 NULL)); | 741 NULL)); |
| 742 EXPECT_EQ(OK, job->Connect()); | 742 EXPECT_EQ(OK, job->Connect()); |
| 743 } | 743 } |
| 744 | 744 |
| 745 TEST_F(ClientSocketPoolBaseTest, ConnectJob_TimedOut) { | 745 TEST_F(ClientSocketPoolBaseTest, ConnectJob_TimedOut) { |
| 746 TestConnectJobDelegate delegate; | 746 TestConnectJobDelegate delegate; |
| 747 ClientSocketHandle ignored; | 747 ClientSocketHandle ignored; |
| 748 CapturingNetLog log(CapturingNetLog::kUnbounded); | 748 CapturingNetLog log(CapturingNetLog::kUnbounded); |
| 749 | 749 |
| 750 TestClientSocketPoolBase::Request request( | 750 TestClientSocketPoolBase::Request request( |
| 751 &ignored, NULL, kDefaultPriority, | 751 &ignored, CompletionCallback(), kDefaultPriority, |
| 752 internal::ClientSocketPoolBaseHelper::NORMAL, | 752 internal::ClientSocketPoolBaseHelper::NORMAL, |
| 753 false, params_, BoundNetLog()); | 753 false, params_, BoundNetLog()); |
| 754 // Deleted by TestConnectJobDelegate. | 754 // Deleted by TestConnectJobDelegate. |
| 755 TestConnectJob* job = | 755 TestConnectJob* job = |
| 756 new TestConnectJob(TestConnectJob::kMockPendingJob, | 756 new TestConnectJob(TestConnectJob::kMockPendingJob, |
| 757 "a", | 757 "a", |
| 758 request, | 758 request, |
| 759 base::TimeDelta::FromMicroseconds(1), | 759 base::TimeDelta::FromMicroseconds(1), |
| 760 &delegate, | 760 &delegate, |
| 761 &client_socket_factory_, | 761 &client_socket_factory_, |
| (...skipping 2742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3504 params_, | 3504 params_, |
| 3505 kDefaultPriority, | 3505 kDefaultPriority, |
| 3506 callback.callback(), | 3506 callback.callback(), |
| 3507 pool_.get(), | 3507 pool_.get(), |
| 3508 BoundNetLog())); | 3508 BoundNetLog())); |
| 3509 } | 3509 } |
| 3510 | 3510 |
| 3511 } // namespace | 3511 } // namespace |
| 3512 | 3512 |
| 3513 } // namespace net | 3513 } // namespace net |
| OLD | NEW |