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