| OLD | NEW |
| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 DoConnect(waiting_success_, true /* async */, false /* recoverable */); | 267 DoConnect(waiting_success_, true /* async */, false /* recoverable */); |
| 268 } | 268 } |
| 269 | 269 |
| 270 virtual LoadState GetLoadState() const OVERRIDE { return load_state_; } | 270 virtual LoadState GetLoadState() const OVERRIDE { return load_state_; } |
| 271 | 271 |
| 272 virtual void GetAdditionalErrorState(ClientSocketHandle* handle) OVERRIDE { | 272 virtual void GetAdditionalErrorState(ClientSocketHandle* handle) OVERRIDE { |
| 273 if (store_additional_error_state_) { | 273 if (store_additional_error_state_) { |
| 274 // Set all of the additional error state fields in some way. | 274 // Set all of the additional error state fields in some way. |
| 275 handle->set_is_ssl_error(true); | 275 handle->set_is_ssl_error(true); |
| 276 HttpResponseInfo info; | 276 HttpResponseInfo info; |
| 277 info.headers = new HttpResponseHeaders(""); | 277 info.headers = new HttpResponseHeaders(std::string()); |
| 278 handle->set_ssl_error_response_info(info); | 278 handle->set_ssl_error_response_info(info); |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 | 281 |
| 282 private: | 282 private: |
| 283 // ConnectJob implementation. | 283 // ConnectJob implementation. |
| 284 | 284 |
| 285 virtual int ConnectInternal() OVERRIDE { | 285 virtual int ConnectInternal() OVERRIDE { |
| 286 AddressList ignored; | 286 AddressList ignored; |
| 287 client_socket_factory_->CreateTransportClientSocket( | 287 client_socket_factory_->CreateTransportClientSocket( |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); | 839 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
| 840 | 840 |
| 841 connect_job_factory_->set_job_type(TestConnectJob::kMockFailingJob); | 841 connect_job_factory_->set_job_type(TestConnectJob::kMockFailingJob); |
| 842 CapturingBoundNetLog log; | 842 CapturingBoundNetLog log; |
| 843 | 843 |
| 844 ClientSocketHandle handle; | 844 ClientSocketHandle handle; |
| 845 TestCompletionCallback callback; | 845 TestCompletionCallback callback; |
| 846 // Set the additional error state members to ensure that they get cleared. | 846 // Set the additional error state members to ensure that they get cleared. |
| 847 handle.set_is_ssl_error(true); | 847 handle.set_is_ssl_error(true); |
| 848 HttpResponseInfo info; | 848 HttpResponseInfo info; |
| 849 info.headers = new HttpResponseHeaders(""); | 849 info.headers = new HttpResponseHeaders(std::string()); |
| 850 handle.set_ssl_error_response_info(info); | 850 handle.set_ssl_error_response_info(info); |
| 851 EXPECT_EQ(ERR_CONNECTION_FAILED, | 851 EXPECT_EQ(ERR_CONNECTION_FAILED, |
| 852 handle.Init("a", | 852 handle.Init("a", |
| 853 params_, | 853 params_, |
| 854 kDefaultPriority, | 854 kDefaultPriority, |
| 855 callback.callback(), | 855 callback.callback(), |
| 856 pool_.get(), | 856 pool_.get(), |
| 857 log.bound())); | 857 log.bound())); |
| 858 EXPECT_FALSE(handle.socket()); | 858 EXPECT_FALSE(handle.socket()); |
| 859 EXPECT_FALSE(handle.is_ssl_error()); | 859 EXPECT_FALSE(handle.is_ssl_error()); |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 InitConnectionAsynchronousFailure) { | 1713 InitConnectionAsynchronousFailure) { |
| 1714 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); | 1714 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); |
| 1715 | 1715 |
| 1716 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob); | 1716 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob); |
| 1717 ClientSocketHandle handle; | 1717 ClientSocketHandle handle; |
| 1718 TestCompletionCallback callback; | 1718 TestCompletionCallback callback; |
| 1719 CapturingBoundNetLog log; | 1719 CapturingBoundNetLog log; |
| 1720 // Set the additional error state members to ensure that they get cleared. | 1720 // Set the additional error state members to ensure that they get cleared. |
| 1721 handle.set_is_ssl_error(true); | 1721 handle.set_is_ssl_error(true); |
| 1722 HttpResponseInfo info; | 1722 HttpResponseInfo info; |
| 1723 info.headers = new HttpResponseHeaders(""); | 1723 info.headers = new HttpResponseHeaders(std::string()); |
| 1724 handle.set_ssl_error_response_info(info); | 1724 handle.set_ssl_error_response_info(info); |
| 1725 EXPECT_EQ(ERR_IO_PENDING, handle.Init("a", | 1725 EXPECT_EQ(ERR_IO_PENDING, handle.Init("a", |
| 1726 params_, | 1726 params_, |
| 1727 kDefaultPriority, | 1727 kDefaultPriority, |
| 1728 callback.callback(), | 1728 callback.callback(), |
| 1729 pool_.get(), | 1729 pool_.get(), |
| 1730 log.bound())); | 1730 log.bound())); |
| 1731 EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", &handle)); | 1731 EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", &handle)); |
| 1732 EXPECT_EQ(ERR_CONNECTION_FAILED, callback.WaitForResult()); | 1732 EXPECT_EQ(ERR_CONNECTION_FAILED, callback.WaitForResult()); |
| 1733 EXPECT_FALSE(handle.is_ssl_error()); | 1733 EXPECT_FALSE(handle.is_ssl_error()); |
| (...skipping 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3558 // complete. | 3558 // complete. |
| 3559 EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a")); | 3559 EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a")); |
| 3560 EXPECT_EQ(0, pool_->NumUnassignedConnectJobsInGroup("a")); | 3560 EXPECT_EQ(0, pool_->NumUnassignedConnectJobsInGroup("a")); |
| 3561 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); | 3561 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); |
| 3562 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); | 3562 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); |
| 3563 } | 3563 } |
| 3564 | 3564 |
| 3565 } // namespace | 3565 } // namespace |
| 3566 | 3566 |
| 3567 } // namespace net | 3567 } // namespace net |
| OLD | NEW |