| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 Observer* observer_; | 65 Observer* observer_; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class HttpPipelinedNetworkTransactionTest : public testing::Test { | 68 class HttpPipelinedNetworkTransactionTest : public testing::Test { |
| 69 public: | 69 public: |
| 70 HttpPipelinedNetworkTransactionTest() | 70 HttpPipelinedNetworkTransactionTest() |
| 71 : histograms_("a"), | 71 : histograms_("a"), |
| 72 pool_(1, 1, &histograms_, &factory_) { | 72 pool_(1, 1, &histograms_, &factory_) { |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual void SetUp() OVERRIDE { | |
| 76 default_pipelining_enabled_ = HttpStreamFactory::http_pipelining_enabled(); | |
| 77 HttpStreamFactory::set_http_pipelining_enabled(true); | |
| 78 } | |
| 79 | |
| 80 virtual void TearDown() OVERRIDE { | |
| 81 MessageLoop::current()->RunAllPending(); | |
| 82 HttpStreamFactory::set_http_pipelining_enabled(default_pipelining_enabled_); | |
| 83 } | |
| 84 | |
| 85 void Initialize(bool force_http_pipelining) { | 75 void Initialize(bool force_http_pipelining) { |
| 86 // Normally, this code could just go in SetUp(). For a few of these tests, | 76 // Normally, this code could just go in SetUp(). For a few of these tests, |
| 87 // we change the default number of sockets per group. That needs to be done | 77 // we change the default number of sockets per group. That needs to be done |
| 88 // before we construct the HttpNetworkSession. | 78 // before we construct the HttpNetworkSession. |
| 89 proxy_config_service_ = new SimpleProxyConfigService(); | 79 proxy_config_service_ = new SimpleProxyConfigService(); |
| 90 proxy_service_.reset(new ProxyService(proxy_config_service_, NULL, NULL)); | 80 proxy_service_.reset(new ProxyService(proxy_config_service_, NULL, NULL)); |
| 91 ssl_config_ = new SSLConfigServiceDefaults; | 81 ssl_config_ = new SSLConfigServiceDefaults; |
| 92 auth_handler_factory_.reset(new HttpAuthHandlerMock::Factory()); | 82 auth_handler_factory_.reset(new HttpAuthHandlerMock::Factory()); |
| 93 | 83 |
| 94 HttpNetworkSession::Params session_params; | 84 HttpNetworkSession::Params session_params; |
| 95 session_params.client_socket_factory = &factory_; | 85 session_params.client_socket_factory = &factory_; |
| 96 session_params.proxy_service = proxy_service_.get(); | 86 session_params.proxy_service = proxy_service_.get(); |
| 97 session_params.host_resolver = &mock_resolver_; | 87 session_params.host_resolver = &mock_resolver_; |
| 98 session_params.ssl_config_service = ssl_config_.get(); | 88 session_params.ssl_config_service = ssl_config_.get(); |
| 99 session_params.http_auth_handler_factory = auth_handler_factory_.get(); | 89 session_params.http_auth_handler_factory = auth_handler_factory_.get(); |
| 100 session_params.http_server_properties = &http_server_properties_; | 90 session_params.http_server_properties = &http_server_properties_; |
| 101 session_params.force_http_pipelining = force_http_pipelining; | 91 session_params.force_http_pipelining = force_http_pipelining; |
| 92 session_params.http_pipelining_enabled = true; |
| 102 session_ = new HttpNetworkSession(session_params); | 93 session_ = new HttpNetworkSession(session_params); |
| 103 } | 94 } |
| 104 | 95 |
| 105 void AddExpectedConnection(MockRead* reads, size_t reads_count, | 96 void AddExpectedConnection(MockRead* reads, size_t reads_count, |
| 106 MockWrite* writes, size_t writes_count) { | 97 MockWrite* writes, size_t writes_count) { |
| 107 DeterministicSocketData* data = new DeterministicSocketData( | 98 DeterministicSocketData* data = new DeterministicSocketData( |
| 108 reads, reads_count, writes, writes_count); | 99 reads, reads_count, writes, writes_count); |
| 109 data->set_connect_data(MockConnect(SYNCHRONOUS, OK)); | 100 data->set_connect_data(MockConnect(SYNCHRONOUS, OK)); |
| 110 if (reads_count || writes_count) { | 101 if (reads_count || writes_count) { |
| 111 data->StopAfter(reads_count + writes_count); | 102 data->StopAfter(reads_count + writes_count); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 EXPECT_EQ(OK, four_callback.WaitForResult()); | 215 EXPECT_EQ(OK, four_callback.WaitForResult()); |
| 225 ExpectResponse("four.html", four_transaction, SYNCHRONOUS); | 216 ExpectResponse("four.html", four_transaction, SYNCHRONOUS); |
| 226 } | 217 } |
| 227 | 218 |
| 228 DeterministicMockClientSocketFactory factory_; | 219 DeterministicMockClientSocketFactory factory_; |
| 229 ClientSocketPoolHistograms histograms_; | 220 ClientSocketPoolHistograms histograms_; |
| 230 MockTransportClientSocketPool pool_; | 221 MockTransportClientSocketPool pool_; |
| 231 ScopedVector<DeterministicSocketData> data_vector_; | 222 ScopedVector<DeterministicSocketData> data_vector_; |
| 232 TestCompletionCallback callback_; | 223 TestCompletionCallback callback_; |
| 233 ScopedVector<HttpRequestInfo> request_info_vector_; | 224 ScopedVector<HttpRequestInfo> request_info_vector_; |
| 234 bool default_pipelining_enabled_; | |
| 235 | 225 |
| 236 SimpleProxyConfigService* proxy_config_service_; | 226 SimpleProxyConfigService* proxy_config_service_; |
| 237 scoped_ptr<ProxyService> proxy_service_; | 227 scoped_ptr<ProxyService> proxy_service_; |
| 238 MockHostResolver mock_resolver_; | 228 MockHostResolver mock_resolver_; |
| 239 scoped_refptr<SSLConfigService> ssl_config_; | 229 scoped_refptr<SSLConfigService> ssl_config_; |
| 240 scoped_ptr<HttpAuthHandlerMock::Factory> auth_handler_factory_; | 230 scoped_ptr<HttpAuthHandlerMock::Factory> auth_handler_factory_; |
| 241 HttpServerPropertiesImpl http_server_properties_; | 231 HttpServerPropertiesImpl http_server_properties_; |
| 242 scoped_refptr<HttpNetworkSession> session_; | 232 scoped_refptr<HttpNetworkSession> session_; |
| 243 }; | 233 }; |
| 244 | 234 |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 EXPECT_EQ(ERR_PIPELINE_EVICTION, two_callback.WaitForResult()); | 1022 EXPECT_EQ(ERR_PIPELINE_EVICTION, two_callback.WaitForResult()); |
| 1033 two_transaction.reset(); | 1023 two_transaction.reset(); |
| 1034 EXPECT_EQ(ERR_PIPELINE_EVICTION, three_callback.WaitForResult()); | 1024 EXPECT_EQ(ERR_PIPELINE_EVICTION, three_callback.WaitForResult()); |
| 1035 three_transaction.reset(); | 1025 three_transaction.reset(); |
| 1036 EXPECT_EQ(ERR_PIPELINE_EVICTION, four_callback.WaitForResult()); | 1026 EXPECT_EQ(ERR_PIPELINE_EVICTION, four_callback.WaitForResult()); |
| 1037 } | 1027 } |
| 1038 | 1028 |
| 1039 } // anonymous namespace | 1029 } // anonymous namespace |
| 1040 | 1030 |
| 1041 } // namespace net | 1031 } // namespace net |
| OLD | NEW |