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/http/http_response_body_drainer.h" | 5 #include "net/http/http_response_body_drainer.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
16 #include "net/http/http_network_session.h" | 16 #include "net/http/http_network_session.h" |
17 #include "net/http/http_server_properties_impl.h" | 17 #include "net/http/http_server_properties_impl.h" |
18 #include "net/http/http_stream.h" | 18 #include "net/http/http_stream.h" |
| 19 #include "net/http/transport_security_state.h" |
19 #include "net/proxy/proxy_service.h" | 20 #include "net/proxy/proxy_service.h" |
20 #include "net/ssl/ssl_config_service_defaults.h" | 21 #include "net/ssl/ssl_config_service_defaults.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 namespace net { | 24 namespace net { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 const int kMagicChunkSize = 1024; | 28 const int kMagicChunkSize = 1024; |
28 COMPILE_ASSERT( | 29 COMPILE_ASSERT( |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 mock_stream_(new MockHttpStream(&result_waiter_)), | 215 mock_stream_(new MockHttpStream(&result_waiter_)), |
215 drainer_(new HttpResponseBodyDrainer(mock_stream_)) {} | 216 drainer_(new HttpResponseBodyDrainer(mock_stream_)) {} |
216 | 217 |
217 virtual ~HttpResponseBodyDrainerTest() {} | 218 virtual ~HttpResponseBodyDrainerTest() {} |
218 | 219 |
219 HttpNetworkSession* CreateNetworkSession() const { | 220 HttpNetworkSession* CreateNetworkSession() const { |
220 HttpNetworkSession::Params params; | 221 HttpNetworkSession::Params params; |
221 params.proxy_service = proxy_service_.get(); | 222 params.proxy_service = proxy_service_.get(); |
222 params.ssl_config_service = ssl_config_service_.get(); | 223 params.ssl_config_service = ssl_config_service_.get(); |
223 params.http_server_properties = http_server_properties_->GetWeakPtr(); | 224 params.http_server_properties = http_server_properties_->GetWeakPtr(); |
| 225 params.transport_security_state = new TransportSecurityState(); |
224 return new HttpNetworkSession(params); | 226 return new HttpNetworkSession(params); |
225 } | 227 } |
226 | 228 |
227 scoped_ptr<ProxyService> proxy_service_; | 229 scoped_ptr<ProxyService> proxy_service_; |
228 scoped_refptr<SSLConfigService> ssl_config_service_; | 230 scoped_refptr<SSLConfigService> ssl_config_service_; |
229 scoped_ptr<HttpServerPropertiesImpl> http_server_properties_; | 231 scoped_ptr<HttpServerPropertiesImpl> http_server_properties_; |
230 const scoped_refptr<HttpNetworkSession> session_; | 232 const scoped_refptr<HttpNetworkSession> session_; |
231 CloseResultWaiter result_waiter_; | 233 CloseResultWaiter result_waiter_; |
232 MockHttpStream* const mock_stream_; // Owned by |drainer_|. | 234 MockHttpStream* const mock_stream_; // Owned by |drainer_|. |
233 HttpResponseBodyDrainer* const drainer_; // Deletes itself. | 235 HttpResponseBodyDrainer* const drainer_; // Deletes itself. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 too_many_chunks += 1; // Now it's too large. | 300 too_many_chunks += 1; // Now it's too large. |
299 | 301 |
300 mock_stream_->set_num_chunks(too_many_chunks); | 302 mock_stream_->set_num_chunks(too_many_chunks); |
301 drainer_->Start(session_.get()); | 303 drainer_->Start(session_.get()); |
302 EXPECT_TRUE(result_waiter_.WaitForResult()); | 304 EXPECT_TRUE(result_waiter_.WaitForResult()); |
303 } | 305 } |
304 | 306 |
305 } // namespace | 307 } // namespace |
306 | 308 |
307 } // namespace net | 309 } // namespace net |
OLD | NEW |