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

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

Issue 8572041: Make ClientSocketPoolManager into an interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix some straggler renames. Created 9 years, 1 month 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_peer.cc ('k') | net/http/http_stream_factory_impl_job.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 27 matching lines...) Expand all
38 #include "net/http/http_network_session.h" 38 #include "net/http/http_network_session.h"
39 #include "net/http/http_network_session_peer.h" 39 #include "net/http/http_network_session_peer.h"
40 #include "net/http/http_server_properties_impl.h" 40 #include "net/http/http_server_properties_impl.h"
41 #include "net/http/http_stream.h" 41 #include "net/http/http_stream.h"
42 #include "net/http/http_stream_factory.h" 42 #include "net/http/http_stream_factory.h"
43 #include "net/http/http_transaction_unittest.h" 43 #include "net/http/http_transaction_unittest.h"
44 #include "net/proxy/proxy_config_service_fixed.h" 44 #include "net/proxy/proxy_config_service_fixed.h"
45 #include "net/proxy/proxy_resolver.h" 45 #include "net/proxy/proxy_resolver.h"
46 #include "net/proxy/proxy_service.h" 46 #include "net/proxy/proxy_service.h"
47 #include "net/socket/client_socket_factory.h" 47 #include "net/socket/client_socket_factory.h"
48 #include "net/socket/mock_client_socket_pool_manager.h"
48 #include "net/socket/socket_test_util.h" 49 #include "net/socket/socket_test_util.h"
49 #include "net/socket/ssl_client_socket.h" 50 #include "net/socket/ssl_client_socket.h"
50 #include "net/spdy/spdy_framer.h" 51 #include "net/spdy/spdy_framer.h"
51 #include "net/spdy/spdy_session.h" 52 #include "net/spdy/spdy_session.h"
52 #include "net/spdy/spdy_session_pool.h" 53 #include "net/spdy/spdy_session_pool.h"
53 #include "net/spdy/spdy_test_util.h" 54 #include "net/spdy/spdy_test_util.h"
54 #include "testing/gtest/include/gtest/gtest.h" 55 #include "testing/gtest/include/gtest/gtest.h"
55 #include "testing/platform_test.h" 56 #include "testing/platform_test.h"
56 57
57 //----------------------------------------------------------------------------- 58 //-----------------------------------------------------------------------------
(...skipping 3241 matching lines...) Expand 10 before | Expand all | Expand 10 after
3299 3300
3300 const HttpResponseInfo* response = trans->GetResponseInfo(); 3301 const HttpResponseInfo* response = trans->GetResponseInfo();
3301 EXPECT_TRUE(response == NULL); 3302 EXPECT_TRUE(response == NULL);
3302 3303
3303 // Empty the current queue. This is necessary because idle sockets are 3304 // Empty the current queue. This is necessary because idle sockets are
3304 // added to the connection pool asynchronously with a PostTask. 3305 // added to the connection pool asynchronously with a PostTask.
3305 MessageLoop::current()->RunAllPending(); 3306 MessageLoop::current()->RunAllPending();
3306 3307
3307 // We now check to make sure the TCPClientSocket was not added back to 3308 // We now check to make sure the TCPClientSocket was not added back to
3308 // the pool. 3309 // the pool.
3309 EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); 3310 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount());
3310 trans.reset(); 3311 trans.reset();
3311 MessageLoop::current()->RunAllPending(); 3312 MessageLoop::current()->RunAllPending();
3312 // Make sure that the socket didn't get recycled after calling the destructor. 3313 // Make sure that the socket didn't get recycled after calling the destructor.
3313 EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); 3314 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount());
3314 } 3315 }
3315 3316
3316 // Make sure that we recycle a socket after reading all of the response body. 3317 // Make sure that we recycle a socket after reading all of the response body.
3317 TEST_F(HttpNetworkTransactionTest, RecycleSocket) { 3318 TEST_F(HttpNetworkTransactionTest, RecycleSocket) {
3318 HttpRequestInfo request; 3319 HttpRequestInfo request;
3319 request.method = "GET"; 3320 request.method = "GET";
3320 request.url = GURL("http://www.google.com/"); 3321 request.url = GURL("http://www.google.com/");
3321 request.load_flags = 0; 3322 request.load_flags = 0;
3322 3323
3323 SessionDependencies session_deps; 3324 SessionDependencies session_deps;
(...skipping 22 matching lines...) Expand all
3346 rv = callback.WaitForResult(); 3347 rv = callback.WaitForResult();
3347 EXPECT_EQ(OK, rv); 3348 EXPECT_EQ(OK, rv);
3348 3349
3349 const HttpResponseInfo* response = trans->GetResponseInfo(); 3350 const HttpResponseInfo* response = trans->GetResponseInfo();
3350 ASSERT_TRUE(response != NULL); 3351 ASSERT_TRUE(response != NULL);
3351 3352
3352 EXPECT_TRUE(response->headers != NULL); 3353 EXPECT_TRUE(response->headers != NULL);
3353 std::string status_line = response->headers->GetStatusLine(); 3354 std::string status_line = response->headers->GetStatusLine();
3354 EXPECT_EQ("HTTP/1.1 200 OK", status_line); 3355 EXPECT_EQ("HTTP/1.1 200 OK", status_line);
3355 3356
3356 EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); 3357 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount());
3357 3358
3358 std::string response_data; 3359 std::string response_data;
3359 rv = ReadTransaction(trans.get(), &response_data); 3360 rv = ReadTransaction(trans.get(), &response_data);
3360 EXPECT_EQ(OK, rv); 3361 EXPECT_EQ(OK, rv);
3361 EXPECT_EQ("hello world", response_data); 3362 EXPECT_EQ("hello world", response_data);
3362 3363
3363 // Empty the current queue. This is necessary because idle sockets are 3364 // Empty the current queue. This is necessary because idle sockets are
3364 // added to the connection pool asynchronously with a PostTask. 3365 // added to the connection pool asynchronously with a PostTask.
3365 MessageLoop::current()->RunAllPending(); 3366 MessageLoop::current()->RunAllPending();
3366 3367
3367 // We now check to make sure the socket was added back to the pool. 3368 // We now check to make sure the socket was added back to the pool.
3368 EXPECT_EQ(1, session->transport_socket_pool()->IdleSocketCount()); 3369 EXPECT_EQ(1, session->GetTransportSocketPool()->IdleSocketCount());
3369 } 3370 }
3370 3371
3371 // Make sure that we recycle a SSL socket after reading all of the response 3372 // Make sure that we recycle a SSL socket after reading all of the response
3372 // body. 3373 // body.
3373 TEST_F(HttpNetworkTransactionTest, RecycleSSLSocket) { 3374 TEST_F(HttpNetworkTransactionTest, RecycleSSLSocket) {
3374 SessionDependencies session_deps; 3375 SessionDependencies session_deps;
3375 HttpRequestInfo request; 3376 HttpRequestInfo request;
3376 request.method = "GET"; 3377 request.method = "GET";
3377 request.url = GURL("https://www.google.com/"); 3378 request.url = GURL("https://www.google.com/");
3378 request.load_flags = 0; 3379 request.load_flags = 0;
(...skipping 26 matching lines...) Expand all
3405 int rv = trans->Start(&request, &callback, BoundNetLog()); 3406 int rv = trans->Start(&request, &callback, BoundNetLog());
3406 3407
3407 EXPECT_EQ(ERR_IO_PENDING, rv); 3408 EXPECT_EQ(ERR_IO_PENDING, rv);
3408 EXPECT_EQ(OK, callback.WaitForResult()); 3409 EXPECT_EQ(OK, callback.WaitForResult());
3409 3410
3410 const HttpResponseInfo* response = trans->GetResponseInfo(); 3411 const HttpResponseInfo* response = trans->GetResponseInfo();
3411 ASSERT_TRUE(response != NULL); 3412 ASSERT_TRUE(response != NULL);
3412 ASSERT_TRUE(response->headers != NULL); 3413 ASSERT_TRUE(response->headers != NULL);
3413 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 3414 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
3414 3415
3415 EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); 3416 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount());
3416 3417
3417 std::string response_data; 3418 std::string response_data;
3418 rv = ReadTransaction(trans.get(), &response_data); 3419 rv = ReadTransaction(trans.get(), &response_data);
3419 EXPECT_EQ(OK, rv); 3420 EXPECT_EQ(OK, rv);
3420 EXPECT_EQ("hello world", response_data); 3421 EXPECT_EQ("hello world", response_data);
3421 3422
3422 // Empty the current queue. This is necessary because idle sockets are 3423 // Empty the current queue. This is necessary because idle sockets are
3423 // added to the connection pool asynchronously with a PostTask. 3424 // added to the connection pool asynchronously with a PostTask.
3424 MessageLoop::current()->RunAllPending(); 3425 MessageLoop::current()->RunAllPending();
3425 3426
3426 // We now check to make sure the socket was added back to the pool. 3427 // We now check to make sure the socket was added back to the pool.
3427 EXPECT_EQ(1, session->ssl_socket_pool()->IdleSocketCount()); 3428 EXPECT_EQ(1, session->GetSSLSocketPool()->IdleSocketCount());
3428 } 3429 }
3429 3430
3430 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it 3431 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it
3431 // from the pool and make sure that we recover okay. 3432 // from the pool and make sure that we recover okay.
3432 TEST_F(HttpNetworkTransactionTest, RecycleDeadSSLSocket) { 3433 TEST_F(HttpNetworkTransactionTest, RecycleDeadSSLSocket) {
3433 SessionDependencies session_deps; 3434 SessionDependencies session_deps;
3434 HttpRequestInfo request; 3435 HttpRequestInfo request;
3435 request.method = "GET"; 3436 request.method = "GET";
3436 request.url = GURL("https://www.google.com/"); 3437 request.url = GURL("https://www.google.com/");
3437 request.load_flags = 0; 3438 request.load_flags = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3473 int rv = trans->Start(&request, &callback, BoundNetLog()); 3474 int rv = trans->Start(&request, &callback, BoundNetLog());
3474 3475
3475 EXPECT_EQ(ERR_IO_PENDING, rv); 3476 EXPECT_EQ(ERR_IO_PENDING, rv);
3476 EXPECT_EQ(OK, callback.WaitForResult()); 3477 EXPECT_EQ(OK, callback.WaitForResult());
3477 3478
3478 const HttpResponseInfo* response = trans->GetResponseInfo(); 3479 const HttpResponseInfo* response = trans->GetResponseInfo();
3479 ASSERT_TRUE(response != NULL); 3480 ASSERT_TRUE(response != NULL);
3480 ASSERT_TRUE(response->headers != NULL); 3481 ASSERT_TRUE(response->headers != NULL);
3481 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 3482 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
3482 3483
3483 EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); 3484 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount());
3484 3485
3485 std::string response_data; 3486 std::string response_data;
3486 rv = ReadTransaction(trans.get(), &response_data); 3487 rv = ReadTransaction(trans.get(), &response_data);
3487 EXPECT_EQ(OK, rv); 3488 EXPECT_EQ(OK, rv);
3488 EXPECT_EQ("hello world", response_data); 3489 EXPECT_EQ("hello world", response_data);
3489 3490
3490 // Empty the current queue. This is necessary because idle sockets are 3491 // Empty the current queue. This is necessary because idle sockets are
3491 // added to the connection pool asynchronously with a PostTask. 3492 // added to the connection pool asynchronously with a PostTask.
3492 MessageLoop::current()->RunAllPending(); 3493 MessageLoop::current()->RunAllPending();
3493 3494
3494 // We now check to make sure the socket was added back to the pool. 3495 // We now check to make sure the socket was added back to the pool.
3495 EXPECT_EQ(1, session->ssl_socket_pool()->IdleSocketCount()); 3496 EXPECT_EQ(1, session->GetSSLSocketPool()->IdleSocketCount());
3496 3497
3497 // Now start the second transaction, which should reuse the previous socket. 3498 // Now start the second transaction, which should reuse the previous socket.
3498 3499
3499 trans.reset(new HttpNetworkTransaction(session)); 3500 trans.reset(new HttpNetworkTransaction(session));
3500 3501
3501 rv = trans->Start(&request, &callback, BoundNetLog()); 3502 rv = trans->Start(&request, &callback, BoundNetLog());
3502 3503
3503 EXPECT_EQ(ERR_IO_PENDING, rv); 3504 EXPECT_EQ(ERR_IO_PENDING, rv);
3504 EXPECT_EQ(OK, callback.WaitForResult()); 3505 EXPECT_EQ(OK, callback.WaitForResult());
3505 3506
3506 response = trans->GetResponseInfo(); 3507 response = trans->GetResponseInfo();
3507 ASSERT_TRUE(response != NULL); 3508 ASSERT_TRUE(response != NULL);
3508 ASSERT_TRUE(response->headers != NULL); 3509 ASSERT_TRUE(response->headers != NULL);
3509 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 3510 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
3510 3511
3511 EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); 3512 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount());
3512 3513
3513 rv = ReadTransaction(trans.get(), &response_data); 3514 rv = ReadTransaction(trans.get(), &response_data);
3514 EXPECT_EQ(OK, rv); 3515 EXPECT_EQ(OK, rv);
3515 EXPECT_EQ("hello world", response_data); 3516 EXPECT_EQ("hello world", response_data);
3516 3517
3517 // Empty the current queue. This is necessary because idle sockets are 3518 // Empty the current queue. This is necessary because idle sockets are
3518 // added to the connection pool asynchronously with a PostTask. 3519 // added to the connection pool asynchronously with a PostTask.
3519 MessageLoop::current()->RunAllPending(); 3520 MessageLoop::current()->RunAllPending();
3520 3521
3521 // We now check to make sure the socket was added back to the pool. 3522 // We now check to make sure the socket was added back to the pool.
3522 EXPECT_EQ(1, session->ssl_socket_pool()->IdleSocketCount()); 3523 EXPECT_EQ(1, session->GetSSLSocketPool()->IdleSocketCount());
3523 } 3524 }
3524 3525
3525 // Make sure that we recycle a socket after a zero-length response. 3526 // Make sure that we recycle a socket after a zero-length response.
3526 // http://crbug.com/9880 3527 // http://crbug.com/9880
3527 TEST_F(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) { 3528 TEST_F(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) {
3528 HttpRequestInfo request; 3529 HttpRequestInfo request;
3529 request.method = "GET"; 3530 request.method = "GET";
3530 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&" 3531 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&"
3531 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" 3532 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&"
3532 "e=17259,18167,19592,19773,19981,20133,20173,20233&" 3533 "e=17259,18167,19592,19773,19981,20133,20173,20233&"
(...skipping 24 matching lines...) Expand all
3557 rv = callback.WaitForResult(); 3558 rv = callback.WaitForResult();
3558 EXPECT_EQ(OK, rv); 3559 EXPECT_EQ(OK, rv);
3559 3560
3560 const HttpResponseInfo* response = trans->GetResponseInfo(); 3561 const HttpResponseInfo* response = trans->GetResponseInfo();
3561 ASSERT_TRUE(response != NULL); 3562 ASSERT_TRUE(response != NULL);
3562 3563
3563 EXPECT_TRUE(response->headers != NULL); 3564 EXPECT_TRUE(response->headers != NULL);
3564 std::string status_line = response->headers->GetStatusLine(); 3565 std::string status_line = response->headers->GetStatusLine();
3565 EXPECT_EQ("HTTP/1.1 204 No Content", status_line); 3566 EXPECT_EQ("HTTP/1.1 204 No Content", status_line);
3566 3567
3567 EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); 3568 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount());
3568 3569
3569 std::string response_data; 3570 std::string response_data;
3570 rv = ReadTransaction(trans.get(), &response_data); 3571 rv = ReadTransaction(trans.get(), &response_data);
3571 EXPECT_EQ(OK, rv); 3572 EXPECT_EQ(OK, rv);
3572 EXPECT_EQ("", response_data); 3573 EXPECT_EQ("", response_data);
3573 3574
3574 // Empty the current queue. This is necessary because idle sockets are 3575 // Empty the current queue. This is necessary because idle sockets are
3575 // added to the connection pool asynchronously with a PostTask. 3576 // added to the connection pool asynchronously with a PostTask.
3576 MessageLoop::current()->RunAllPending(); 3577 MessageLoop::current()->RunAllPending();
3577 3578
3578 // We now check to make sure the socket was added back to the pool. 3579 // We now check to make sure the socket was added back to the pool.
3579 EXPECT_EQ(1, session->transport_socket_pool()->IdleSocketCount()); 3580 EXPECT_EQ(1, session->GetTransportSocketPool()->IdleSocketCount());
3580 } 3581 }
3581 3582
3582 TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) { 3583 TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) {
3583 HttpRequestInfo request[2]; 3584 HttpRequestInfo request[2];
3584 // Transaction 1: a GET request that succeeds. The socket is recycled 3585 // Transaction 1: a GET request that succeeds. The socket is recycled
3585 // after use. 3586 // after use.
3586 request[0].method = "GET"; 3587 request[0].method = "GET";
3587 request[0].url = GURL("http://www.google.com/"); 3588 request[0].url = GURL("http://www.google.com/");
3588 request[0].load_flags = 0; 3589 request[0].load_flags = 0;
3589 // Transaction 2: a POST request. Reuses the socket kept alive from 3590 // Transaction 2: a POST request. Reuses the socket kept alive from
(...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after
5619 5620
5620 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 5621 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
5621 SessionDependencies session_deps( 5622 SessionDependencies session_deps(
5622 ProxyService::CreateFixed(tests[i].proxy_server)); 5623 ProxyService::CreateFixed(tests[i].proxy_server));
5623 scoped_refptr<HttpNetworkSession> session( 5624 scoped_refptr<HttpNetworkSession> session(
5624 SetupSessionForGroupNameTests(&session_deps)); 5625 SetupSessionForGroupNameTests(&session_deps));
5625 5626
5626 HttpNetworkSessionPeer peer(session); 5627 HttpNetworkSessionPeer peer(session);
5627 CaptureGroupNameTransportSocketPool* transport_conn_pool = 5628 CaptureGroupNameTransportSocketPool* transport_conn_pool =
5628 new CaptureGroupNameTransportSocketPool(NULL, NULL); 5629 new CaptureGroupNameTransportSocketPool(NULL, NULL);
5629 peer.SetTransportSocketPool(transport_conn_pool);
5630 CaptureGroupNameSSLSocketPool* ssl_conn_pool = 5630 CaptureGroupNameSSLSocketPool* ssl_conn_pool =
5631 new CaptureGroupNameSSLSocketPool(NULL, NULL); 5631 new CaptureGroupNameSSLSocketPool(NULL, NULL);
5632 peer.SetSSLSocketPool(ssl_conn_pool); 5632 MockClientSocketPoolManager* mock_pool_manager =
5633 new MockClientSocketPoolManager;
5634 mock_pool_manager->SetTransportSocketPool(transport_conn_pool);
5635 mock_pool_manager->SetSSLSocketPool(ssl_conn_pool);
5636 peer.SetClientSocketPoolManager(mock_pool_manager);
5633 5637
5634 EXPECT_EQ(ERR_IO_PENDING, 5638 EXPECT_EQ(ERR_IO_PENDING,
5635 GroupNameTransactionHelper(tests[i].url, session)); 5639 GroupNameTransactionHelper(tests[i].url, session));
5636 if (tests[i].ssl) 5640 if (tests[i].ssl)
5637 EXPECT_EQ(tests[i].expected_group_name, 5641 EXPECT_EQ(tests[i].expected_group_name,
5638 ssl_conn_pool->last_group_name_received()); 5642 ssl_conn_pool->last_group_name_received());
5639 else 5643 else
5640 EXPECT_EQ(tests[i].expected_group_name, 5644 EXPECT_EQ(tests[i].expected_group_name,
5641 transport_conn_pool->last_group_name_received()); 5645 transport_conn_pool->last_group_name_received());
5642 } 5646 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5675 SessionDependencies session_deps( 5679 SessionDependencies session_deps(
5676 ProxyService::CreateFixed(tests[i].proxy_server)); 5680 ProxyService::CreateFixed(tests[i].proxy_server));
5677 scoped_refptr<HttpNetworkSession> session( 5681 scoped_refptr<HttpNetworkSession> session(
5678 SetupSessionForGroupNameTests(&session_deps)); 5682 SetupSessionForGroupNameTests(&session_deps));
5679 5683
5680 HttpNetworkSessionPeer peer(session); 5684 HttpNetworkSessionPeer peer(session);
5681 5685
5682 HostPortPair proxy_host("http_proxy", 80); 5686 HostPortPair proxy_host("http_proxy", 80);
5683 CaptureGroupNameHttpProxySocketPool* http_proxy_pool = 5687 CaptureGroupNameHttpProxySocketPool* http_proxy_pool =
5684 new CaptureGroupNameHttpProxySocketPool(NULL, NULL); 5688 new CaptureGroupNameHttpProxySocketPool(NULL, NULL);
5685 peer.SetSocketPoolForHTTPProxy(proxy_host, http_proxy_pool);
5686 CaptureGroupNameSSLSocketPool* ssl_conn_pool = 5689 CaptureGroupNameSSLSocketPool* ssl_conn_pool =
5687 new CaptureGroupNameSSLSocketPool(NULL, NULL); 5690 new CaptureGroupNameSSLSocketPool(NULL, NULL);
5688 peer.SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); 5691
5692 MockClientSocketPoolManager* mock_pool_manager =
5693 new MockClientSocketPoolManager;
5694 mock_pool_manager->SetSocketPoolForHTTPProxy(proxy_host, http_proxy_pool);
5695 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool);
5696 peer.SetClientSocketPoolManager(mock_pool_manager);
5689 5697
5690 EXPECT_EQ(ERR_IO_PENDING, 5698 EXPECT_EQ(ERR_IO_PENDING,
5691 GroupNameTransactionHelper(tests[i].url, session)); 5699 GroupNameTransactionHelper(tests[i].url, session));
5692 if (tests[i].ssl) 5700 if (tests[i].ssl)
5693 EXPECT_EQ(tests[i].expected_group_name, 5701 EXPECT_EQ(tests[i].expected_group_name,
5694 ssl_conn_pool->last_group_name_received()); 5702 ssl_conn_pool->last_group_name_received());
5695 else 5703 else
5696 EXPECT_EQ(tests[i].expected_group_name, 5704 EXPECT_EQ(tests[i].expected_group_name,
5697 http_proxy_pool->last_group_name_received()); 5705 http_proxy_pool->last_group_name_received());
5698 } 5706 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5743 SessionDependencies session_deps( 5751 SessionDependencies session_deps(
5744 ProxyService::CreateFixed(tests[i].proxy_server)); 5752 ProxyService::CreateFixed(tests[i].proxy_server));
5745 scoped_refptr<HttpNetworkSession> session( 5753 scoped_refptr<HttpNetworkSession> session(
5746 SetupSessionForGroupNameTests(&session_deps)); 5754 SetupSessionForGroupNameTests(&session_deps));
5747 5755
5748 HttpNetworkSessionPeer peer(session); 5756 HttpNetworkSessionPeer peer(session);
5749 5757
5750 HostPortPair proxy_host("socks_proxy", 1080); 5758 HostPortPair proxy_host("socks_proxy", 1080);
5751 CaptureGroupNameSOCKSSocketPool* socks_conn_pool = 5759 CaptureGroupNameSOCKSSocketPool* socks_conn_pool =
5752 new CaptureGroupNameSOCKSSocketPool(NULL, NULL); 5760 new CaptureGroupNameSOCKSSocketPool(NULL, NULL);
5753 peer.SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool);
5754 CaptureGroupNameSSLSocketPool* ssl_conn_pool = 5761 CaptureGroupNameSSLSocketPool* ssl_conn_pool =
5755 new CaptureGroupNameSSLSocketPool(NULL, NULL); 5762 new CaptureGroupNameSSLSocketPool(NULL, NULL);
5756 peer.SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); 5763
5764 MockClientSocketPoolManager* mock_pool_manager =
5765 new MockClientSocketPoolManager;
5766 mock_pool_manager->SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool);
5767 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool);
5768 peer.SetClientSocketPoolManager(mock_pool_manager);
5757 5769
5758 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); 5770 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
5759 5771
5760 EXPECT_EQ(ERR_IO_PENDING, 5772 EXPECT_EQ(ERR_IO_PENDING,
5761 GroupNameTransactionHelper(tests[i].url, session)); 5773 GroupNameTransactionHelper(tests[i].url, session));
5762 if (tests[i].ssl) 5774 if (tests[i].ssl)
5763 EXPECT_EQ(tests[i].expected_group_name, 5775 EXPECT_EQ(tests[i].expected_group_name,
5764 ssl_conn_pool->last_group_name_received()); 5776 ssl_conn_pool->last_group_name_received());
5765 else 5777 else
5766 EXPECT_EQ(tests[i].expected_group_name, 5778 EXPECT_EQ(tests[i].expected_group_name,
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
7262 session->spdy_session_pool()->Get(pair, BoundNetLog()); 7274 session->spdy_session_pool()->Get(pair, BoundNetLog());
7263 scoped_refptr<TransportSocketParams> transport_params( 7275 scoped_refptr<TransportSocketParams> transport_params(
7264 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); 7276 new TransportSocketParams(host_port_pair, MEDIUM, false, false));
7265 7277
7266 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 7278 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
7267 EXPECT_EQ(ERR_IO_PENDING, 7279 EXPECT_EQ(ERR_IO_PENDING,
7268 connection->Init(host_port_pair.ToString(), 7280 connection->Init(host_port_pair.ToString(),
7269 transport_params, 7281 transport_params,
7270 LOWEST, 7282 LOWEST,
7271 &callback, 7283 &callback,
7272 session->transport_socket_pool(), 7284 session->GetTransportSocketPool(),
7273 BoundNetLog())); 7285 BoundNetLog()));
7274 EXPECT_EQ(OK, callback.WaitForResult()); 7286 EXPECT_EQ(OK, callback.WaitForResult());
7275 7287
7276 SSLConfig ssl_config; 7288 SSLConfig ssl_config;
7277 session->ssl_config_service()->GetSSLConfig(&ssl_config); 7289 session->ssl_config_service()->GetSSLConfig(&ssl_config);
7278 scoped_ptr<ClientSocketHandle> ssl_connection(new ClientSocketHandle); 7290 scoped_ptr<ClientSocketHandle> ssl_connection(new ClientSocketHandle);
7279 SSLClientSocketContext context; 7291 SSLClientSocketContext context;
7280 context.cert_verifier = session_deps.cert_verifier.get(); 7292 context.cert_verifier = session_deps.cert_verifier.get();
7281 ssl_connection->set_socket(session_deps.socket_factory.CreateSSLClientSocket( 7293 ssl_connection->set_socket(session_deps.socket_factory.CreateSSLClientSocket(
7282 connection.release(), HostPortPair("" , 443), ssl_config, 7294 connection.release(), HostPortPair("" , 443), ssl_config,
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
7754 // each round of multi-round authentication. 7766 // each round of multi-round authentication.
7755 HttpNetworkSessionPeer session_peer(session); 7767 HttpNetworkSessionPeer session_peer(session);
7756 ClientSocketPoolHistograms transport_pool_histograms("SmallTCP"); 7768 ClientSocketPoolHistograms transport_pool_histograms("SmallTCP");
7757 TransportClientSocketPool* transport_pool = new TransportClientSocketPool( 7769 TransportClientSocketPool* transport_pool = new TransportClientSocketPool(
7758 50, // Max sockets for pool 7770 50, // Max sockets for pool
7759 1, // Max sockets per group 7771 1, // Max sockets per group
7760 &transport_pool_histograms, 7772 &transport_pool_histograms,
7761 session_deps.host_resolver.get(), 7773 session_deps.host_resolver.get(),
7762 &session_deps.socket_factory, 7774 &session_deps.socket_factory,
7763 session_deps.net_log); 7775 session_deps.net_log);
7764 session_peer.SetTransportSocketPool(transport_pool); 7776 MockClientSocketPoolManager* mock_pool_manager =
7777 new MockClientSocketPoolManager;
7778 mock_pool_manager->SetTransportSocketPool(transport_pool);
7779 session_peer.SetClientSocketPoolManager(mock_pool_manager);
7765 7780
7766 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); 7781 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
7767 TestOldCompletionCallback callback; 7782 TestOldCompletionCallback callback;
7768 7783
7769 const MockWrite kGet( 7784 const MockWrite kGet(
7770 "GET / HTTP/1.1\r\n" 7785 "GET / HTTP/1.1\r\n"
7771 "Host: www.example.com\r\n" 7786 "Host: www.example.com\r\n"
7772 "Connection: keep-alive\r\n\r\n"); 7787 "Connection: keep-alive\r\n\r\n");
7773 const MockWrite kGetAuth( 7788 const MockWrite kGetAuth(
7774 "GET / HTTP/1.1\r\n" 7789 "GET / HTTP/1.1\r\n"
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
8517 scoped_refptr<SpdySession> spdy_session = 8532 scoped_refptr<SpdySession> spdy_session =
8518 session->spdy_session_pool()->Get(pair, BoundNetLog()); 8533 session->spdy_session_pool()->Get(pair, BoundNetLog());
8519 scoped_refptr<TransportSocketParams> transport_params( 8534 scoped_refptr<TransportSocketParams> transport_params(
8520 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); 8535 new TransportSocketParams(host_port_pair, MEDIUM, false, false));
8521 TestOldCompletionCallback callback; 8536 TestOldCompletionCallback callback;
8522 8537
8523 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 8538 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
8524 EXPECT_EQ(ERR_IO_PENDING, 8539 EXPECT_EQ(ERR_IO_PENDING,
8525 connection->Init(host_port_pair.ToString(), transport_params, 8540 connection->Init(host_port_pair.ToString(), transport_params,
8526 LOWEST, &callback, 8541 LOWEST, &callback,
8527 session->transport_socket_pool(), BoundNetLog())); 8542 session->GetTransportSocketPool(), BoundNetLog()));
8528 EXPECT_EQ(OK, callback.WaitForResult()); 8543 EXPECT_EQ(OK, callback.WaitForResult());
8529 spdy_session->InitializeWithSocket(connection.release(), false, OK); 8544 spdy_session->InitializeWithSocket(connection.release(), false, OK);
8530 8545
8531 HttpRequestInfo request; 8546 HttpRequestInfo request;
8532 request.method = "GET"; 8547 request.method = "GET";
8533 request.url = GURL("https://www.google.com/"); 8548 request.url = GURL("https://www.google.com/");
8534 request.load_flags = 0; 8549 request.load_flags = 0;
8535 8550
8536 // This is the important line that marks this as a preconnect. 8551 // This is the important line that marks this as a preconnect.
8537 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; 8552 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED;
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
9222 StaticSocketDataProvider* data[] = { &data1, &data2 }; 9237 StaticSocketDataProvider* data[] = { &data1, &data2 };
9223 9238
9224 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); 9239 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data));
9225 9240
9226 EXPECT_EQ(OK, out.rv); 9241 EXPECT_EQ(OK, out.rv);
9227 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); 9242 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line);
9228 EXPECT_EQ("hello world", out.response_data); 9243 EXPECT_EQ("hello world", out.response_data);
9229 } 9244 }
9230 9245
9231 } // namespace net 9246 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session_peer.cc ('k') | net/http/http_stream_factory_impl_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698