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

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

Issue 10690104: DeterministicSocketDataProvider should not be RefCounted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more leak fix Created 8 years, 5 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 | Annotate | Revision Log
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_proxy_client_socket_pool.h" 5 #include "net/http/http_proxy_client_socket_pool.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 DeterministicMockClientSocketFactory& socket_factory() { 149 DeterministicMockClientSocketFactory& socket_factory() {
150 return socket_factory_; 150 return socket_factory_;
151 } 151 }
152 152
153 void Initialize(MockRead* reads, size_t reads_count, 153 void Initialize(MockRead* reads, size_t reads_count,
154 MockWrite* writes, size_t writes_count, 154 MockWrite* writes, size_t writes_count,
155 MockRead* spdy_reads, size_t spdy_reads_count, 155 MockRead* spdy_reads, size_t spdy_reads_count,
156 MockWrite* spdy_writes, size_t spdy_writes_count) { 156 MockWrite* spdy_writes, size_t spdy_writes_count) {
157 if (GetParam() == SPDY) 157 if (GetParam() == SPDY) {
158 data_ = new DeterministicSocketData(spdy_reads, spdy_reads_count, 158 data_.reset(new DeterministicSocketData(spdy_reads, spdy_reads_count,
159 spdy_writes, spdy_writes_count); 159 spdy_writes, spdy_writes_count));
160 else 160 } else {
161 data_ = new DeterministicSocketData(reads, reads_count, writes, 161 data_.reset(new DeterministicSocketData(reads, reads_count, writes,
162 writes_count); 162 writes_count));
163 }
163 164
164 data_->set_connect_data(MockConnect(SYNCHRONOUS, OK)); 165 data_->set_connect_data(MockConnect(SYNCHRONOUS, OK));
165 data_->StopAfter(2); // Request / Response 166 data_->StopAfter(2); // Request / Response
166 167
167 socket_factory_.AddSocketDataProvider(data_.get()); 168 socket_factory_.AddSocketDataProvider(data_.get());
168 169
169 if (GetParam() != HTTP) { 170 if (GetParam() != HTTP) {
170 ssl_data_.reset(new SSLSocketDataProvider(SYNCHRONOUS, OK)); 171 ssl_data_.reset(new SSLSocketDataProvider(SYNCHRONOUS, OK));
171 if (GetParam() == SPDY) { 172 if (GetParam() == SPDY) {
172 InitializeSpdySsl(); 173 InitializeSpdySsl();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 SSLClientSocketPool ssl_socket_pool_; 211 SSLClientSocketPool ssl_socket_pool_;
211 212
212 const scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; 213 const scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_;
213 HttpServerPropertiesImpl http_server_properties_; 214 HttpServerPropertiesImpl http_server_properties_;
214 const scoped_refptr<HttpNetworkSession> session_; 215 const scoped_refptr<HttpNetworkSession> session_;
215 ClientSocketPoolHistograms http_proxy_histograms_; 216 ClientSocketPoolHistograms http_proxy_histograms_;
216 SpdyTestStateHelper spdy_state_; 217 SpdyTestStateHelper spdy_state_;
217 218
218 protected: 219 protected:
219 scoped_ptr<SSLSocketDataProvider> ssl_data_; 220 scoped_ptr<SSLSocketDataProvider> ssl_data_;
220 scoped_refptr<DeterministicSocketData> data_; 221 scoped_ptr<DeterministicSocketData> data_;
221 HttpProxyClientSocketPool pool_; 222 HttpProxyClientSocketPool pool_;
222 ClientSocketHandle handle_; 223 ClientSocketHandle handle_;
223 TestCompletionCallback callback_; 224 TestCompletionCallback callback_;
224 }; 225 };
225 226
226 //----------------------------------------------------------------------------- 227 //-----------------------------------------------------------------------------
227 // All tests are run with three different proxy types: HTTP, HTTPS (non-SPDY) 228 // All tests are run with three different proxy types: HTTP, HTTPS (non-SPDY)
228 // and SPDY. 229 // and SPDY.
229 INSTANTIATE_TEST_CASE_P(HttpProxyClientSocketPoolSpdy2Tests, 230 INSTANTIATE_TEST_CASE_P(HttpProxyClientSocketPoolSpdy2Tests,
230 HttpProxyClientSocketPoolSpdy2Test, 231 HttpProxyClientSocketPoolSpdy2Test,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 EXPECT_EQ(OK, callback_.WaitForResult()); 379 EXPECT_EQ(OK, callback_.WaitForResult());
379 EXPECT_TRUE(handle_.is_initialized()); 380 EXPECT_TRUE(handle_.is_initialized());
380 ASSERT_TRUE(handle_.socket()); 381 ASSERT_TRUE(handle_.socket());
381 HttpProxyClientSocket* tunnel_socket = 382 HttpProxyClientSocket* tunnel_socket =
382 static_cast<HttpProxyClientSocket*>(handle_.socket()); 383 static_cast<HttpProxyClientSocket*>(handle_.socket());
383 EXPECT_TRUE(tunnel_socket->IsConnected()); 384 EXPECT_TRUE(tunnel_socket->IsConnected());
384 } 385 }
385 386
386 TEST_P(HttpProxyClientSocketPoolSpdy2Test, TCPError) { 387 TEST_P(HttpProxyClientSocketPoolSpdy2Test, TCPError) {
387 if (GetParam() == SPDY) return; 388 if (GetParam() == SPDY) return;
388 data_ = new DeterministicSocketData(NULL, 0, NULL, 0); 389 data_.reset(new DeterministicSocketData(NULL, 0, NULL, 0));
389 data_->set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_CLOSED)); 390 data_->set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_CLOSED));
390 391
391 socket_factory().AddSocketDataProvider(data_.get()); 392 socket_factory().AddSocketDataProvider(data_.get());
392 393
393 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(), 394 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(),
394 &pool_, BoundNetLog()); 395 &pool_, BoundNetLog());
395 EXPECT_EQ(ERR_IO_PENDING, rv); 396 EXPECT_EQ(ERR_IO_PENDING, rv);
396 EXPECT_FALSE(handle_.is_initialized()); 397 EXPECT_FALSE(handle_.is_initialized());
397 EXPECT_FALSE(handle_.socket()); 398 EXPECT_FALSE(handle_.socket());
398 399
399 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, callback_.WaitForResult()); 400 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, callback_.WaitForResult());
400 401
401 EXPECT_FALSE(handle_.is_initialized()); 402 EXPECT_FALSE(handle_.is_initialized());
402 EXPECT_FALSE(handle_.socket()); 403 EXPECT_FALSE(handle_.socket());
403 } 404 }
404 405
405 TEST_P(HttpProxyClientSocketPoolSpdy2Test, SSLError) { 406 TEST_P(HttpProxyClientSocketPoolSpdy2Test, SSLError) {
406 if (GetParam() == HTTP) return; 407 if (GetParam() == HTTP) return;
407 data_ = new DeterministicSocketData(NULL, 0, NULL, 0); 408 data_.reset(new DeterministicSocketData(NULL, 0, NULL, 0));
408 data_->set_connect_data(MockConnect(ASYNC, OK)); 409 data_->set_connect_data(MockConnect(ASYNC, OK));
409 socket_factory().AddSocketDataProvider(data_.get()); 410 socket_factory().AddSocketDataProvider(data_.get());
410 411
411 ssl_data_.reset(new SSLSocketDataProvider(ASYNC, 412 ssl_data_.reset(new SSLSocketDataProvider(ASYNC,
412 ERR_CERT_AUTHORITY_INVALID)); 413 ERR_CERT_AUTHORITY_INVALID));
413 if (GetParam() == SPDY) { 414 if (GetParam() == SPDY) {
414 InitializeSpdySsl(); 415 InitializeSpdySsl();
415 } 416 }
416 socket_factory().AddSSLSocketDataProvider(ssl_data_.get()); 417 socket_factory().AddSSLSocketDataProvider(ssl_data_.get());
417 418
418 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(), 419 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(),
419 &pool_, BoundNetLog()); 420 &pool_, BoundNetLog());
420 EXPECT_EQ(ERR_IO_PENDING, rv); 421 EXPECT_EQ(ERR_IO_PENDING, rv);
421 EXPECT_FALSE(handle_.is_initialized()); 422 EXPECT_FALSE(handle_.is_initialized());
422 EXPECT_FALSE(handle_.socket()); 423 EXPECT_FALSE(handle_.socket());
423 424
424 EXPECT_EQ(ERR_PROXY_CERTIFICATE_INVALID, callback_.WaitForResult()); 425 EXPECT_EQ(ERR_PROXY_CERTIFICATE_INVALID, callback_.WaitForResult());
425 426
426 EXPECT_FALSE(handle_.is_initialized()); 427 EXPECT_FALSE(handle_.is_initialized());
427 EXPECT_FALSE(handle_.socket()); 428 EXPECT_FALSE(handle_.socket());
428 } 429 }
429 430
430 TEST_P(HttpProxyClientSocketPoolSpdy2Test, SslClientAuth) { 431 TEST_P(HttpProxyClientSocketPoolSpdy2Test, SslClientAuth) {
431 if (GetParam() == HTTP) return; 432 if (GetParam() == HTTP) return;
432 data_ = new DeterministicSocketData(NULL, 0, NULL, 0); 433 data_.reset(new DeterministicSocketData(NULL, 0, NULL, 0));
433 data_->set_connect_data(MockConnect(ASYNC, OK)); 434 data_->set_connect_data(MockConnect(ASYNC, OK));
434 socket_factory().AddSocketDataProvider(data_.get()); 435 socket_factory().AddSocketDataProvider(data_.get());
435 436
436 ssl_data_.reset(new SSLSocketDataProvider(ASYNC, 437 ssl_data_.reset(new SSLSocketDataProvider(ASYNC,
437 ERR_SSL_CLIENT_AUTH_CERT_NEEDED)); 438 ERR_SSL_CLIENT_AUTH_CERT_NEEDED));
438 if (GetParam() == SPDY) { 439 if (GetParam() == SPDY) {
439 InitializeSpdySsl(); 440 InitializeSpdySsl();
440 } 441 }
441 socket_factory().AddSSLSocketDataProvider(ssl_data_.get()); 442 socket_factory().AddSSLSocketDataProvider(ssl_data_.get());
442 443
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // HTTPS or SPDY Proxy CONNECT responses are trustworthy 538 // HTTPS or SPDY Proxy CONNECT responses are trustworthy
538 EXPECT_EQ(ERR_HTTPS_PROXY_TUNNEL_RESPONSE, rv); 539 EXPECT_EQ(ERR_HTTPS_PROXY_TUNNEL_RESPONSE, rv);
539 EXPECT_TRUE(handle_.is_initialized()); 540 EXPECT_TRUE(handle_.is_initialized());
540 EXPECT_TRUE(handle_.socket()); 541 EXPECT_TRUE(handle_.socket());
541 } 542 }
542 } 543 }
543 544
544 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. 545 // It would be nice to also test the timeouts in HttpProxyClientSocketPool.
545 546
546 } // namespace net 547 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_pipelined_network_transaction_unittest.cc ('k') | net/http/http_proxy_client_socket_pool_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698