Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: net/http/http_response_body_drainer_unittest.cc

Issue 498373002: Refactor pooling logic into a helper method Disable pooling when there are cert errors. Disable poo… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2125
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/quic/quic_client_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 callback_.Reset(); 204 callback_.Reset();
204 callback.Run(result); 205 callback.Run(result);
205 } 206 }
206 207
207 class HttpResponseBodyDrainerTest : public testing::Test { 208 class HttpResponseBodyDrainerTest : public testing::Test {
208 protected: 209 protected:
209 HttpResponseBodyDrainerTest() 210 HttpResponseBodyDrainerTest()
210 : proxy_service_(ProxyService::CreateDirect()), 211 : proxy_service_(ProxyService::CreateDirect()),
211 ssl_config_service_(new SSLConfigServiceDefaults), 212 ssl_config_service_(new SSLConfigServiceDefaults),
212 http_server_properties_(new HttpServerPropertiesImpl()), 213 http_server_properties_(new HttpServerPropertiesImpl()),
214 transport_security_state_(new TransportSecurityState()),
213 session_(CreateNetworkSession()), 215 session_(CreateNetworkSession()),
214 mock_stream_(new MockHttpStream(&result_waiter_)), 216 mock_stream_(new MockHttpStream(&result_waiter_)),
215 drainer_(new HttpResponseBodyDrainer(mock_stream_)) {} 217 drainer_(new HttpResponseBodyDrainer(mock_stream_)) {}
216 218
217 virtual ~HttpResponseBodyDrainerTest() {} 219 virtual ~HttpResponseBodyDrainerTest() {}
218 220
219 HttpNetworkSession* CreateNetworkSession() const { 221 HttpNetworkSession* CreateNetworkSession() const {
220 HttpNetworkSession::Params params; 222 HttpNetworkSession::Params params;
221 params.proxy_service = proxy_service_.get(); 223 params.proxy_service = proxy_service_.get();
222 params.ssl_config_service = ssl_config_service_.get(); 224 params.ssl_config_service = ssl_config_service_.get();
223 params.http_server_properties = http_server_properties_->GetWeakPtr(); 225 params.http_server_properties = http_server_properties_->GetWeakPtr();
226 params.transport_security_state = transport_security_state_.get();
224 return new HttpNetworkSession(params); 227 return new HttpNetworkSession(params);
225 } 228 }
226 229
227 scoped_ptr<ProxyService> proxy_service_; 230 scoped_ptr<ProxyService> proxy_service_;
228 scoped_refptr<SSLConfigService> ssl_config_service_; 231 scoped_refptr<SSLConfigService> ssl_config_service_;
229 scoped_ptr<HttpServerPropertiesImpl> http_server_properties_; 232 scoped_ptr<HttpServerPropertiesImpl> http_server_properties_;
233 scoped_ptr<TransportSecurityState> transport_security_state_;
230 const scoped_refptr<HttpNetworkSession> session_; 234 const scoped_refptr<HttpNetworkSession> session_;
231 CloseResultWaiter result_waiter_; 235 CloseResultWaiter result_waiter_;
232 MockHttpStream* const mock_stream_; // Owned by |drainer_|. 236 MockHttpStream* const mock_stream_; // Owned by |drainer_|.
233 HttpResponseBodyDrainer* const drainer_; // Deletes itself. 237 HttpResponseBodyDrainer* const drainer_; // Deletes itself.
234 }; 238 };
235 239
236 TEST_F(HttpResponseBodyDrainerTest, DrainBodySyncSingleOK) { 240 TEST_F(HttpResponseBodyDrainerTest, DrainBodySyncSingleOK) {
237 mock_stream_->set_num_chunks(1); 241 mock_stream_->set_num_chunks(1);
238 mock_stream_->set_sync(); 242 mock_stream_->set_sync();
239 drainer_->Start(session_.get()); 243 drainer_->Start(session_.get());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 too_many_chunks += 1; // Now it's too large. 302 too_many_chunks += 1; // Now it's too large.
299 303
300 mock_stream_->set_num_chunks(too_many_chunks); 304 mock_stream_->set_num_chunks(too_many_chunks);
301 drainer_->Start(session_.get()); 305 drainer_->Start(session_.get());
302 EXPECT_TRUE(result_waiter_.WaitForResult()); 306 EXPECT_TRUE(result_waiter_.WaitForResult());
303 } 307 }
304 308
305 } // namespace 309 } // namespace
306 310
307 } // namespace net 311 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/quic/quic_client_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698