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

Side by Side Diff: net/socket/ssl_client_socket_unittest.cc

Issue 657013003: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/socket/ssl_client_socket_pool.cc ('k') | net/socket/tcp_listen_socket.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) 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/socket/ssl_client_socket.h" 5 #include "net/socket/ssl_client_socket.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 new TCPClientSocket(addr(), NULL, NetLog::Source()))); 851 new TCPClientSocket(addr(), NULL, NetLog::Source())));
852 real_transport.reset( 852 real_transport.reset(
853 new SynchronousErrorStreamSocket(real_transport.Pass())); 853 new SynchronousErrorStreamSocket(real_transport.Pass()));
854 854
855 scoped_ptr<FakeBlockingStreamSocket> transport( 855 scoped_ptr<FakeBlockingStreamSocket> transport(
856 new FakeBlockingStreamSocket(real_transport.Pass())); 856 new FakeBlockingStreamSocket(real_transport.Pass()));
857 int rv = callback->GetResult(transport->Connect(callback->callback())); 857 int rv = callback->GetResult(transport->Connect(callback->callback()));
858 EXPECT_EQ(OK, rv); 858 EXPECT_EQ(OK, rv);
859 859
860 FakeBlockingStreamSocket* raw_transport = transport.get(); 860 FakeBlockingStreamSocket* raw_transport = transport.get();
861 scoped_ptr<SSLClientSocket> sock = 861 scoped_ptr<SSLClientSocket> sock = CreateSSLClientSocket(
862 CreateSSLClientSocket(transport.PassAs<StreamSocket>(), 862 transport.Pass(), test_server()->host_port_pair(), client_config);
863 test_server()->host_port_pair(),
864 client_config);
865 863
866 if (monitor_handshake_callback_) { 864 if (monitor_handshake_callback_) {
867 sock->SetHandshakeCompletionCallback( 865 sock->SetHandshakeCompletionCallback(
868 base::Bind(&SSLClientSocketTest::RecordCompletedHandshake, 866 base::Bind(&SSLClientSocketTest::RecordCompletedHandshake,
869 base::Unretained(this))); 867 base::Unretained(this)));
870 } 868 }
871 869
872 // Connect. Stop before the client processes the first server leg 870 // Connect. Stop before the client processes the first server leg
873 // (ServerHello, etc.) 871 // (ServerHello, etc.)
874 raw_transport->BlockReadResult(); 872 raw_transport->BlockReadResult();
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 scoped_ptr<SynchronousErrorStreamSocket> transport( 1323 scoped_ptr<SynchronousErrorStreamSocket> transport(
1326 new SynchronousErrorStreamSocket(real_transport.Pass())); 1324 new SynchronousErrorStreamSocket(real_transport.Pass()));
1327 int rv = callback.GetResult(transport->Connect(callback.callback())); 1325 int rv = callback.GetResult(transport->Connect(callback.callback()));
1328 EXPECT_EQ(OK, rv); 1326 EXPECT_EQ(OK, rv);
1329 1327
1330 // Disable TLS False Start to avoid handshake non-determinism. 1328 // Disable TLS False Start to avoid handshake non-determinism.
1331 SSLConfig ssl_config; 1329 SSLConfig ssl_config;
1332 ssl_config.false_start_enabled = false; 1330 ssl_config.false_start_enabled = false;
1333 1331
1334 SynchronousErrorStreamSocket* raw_transport = transport.get(); 1332 SynchronousErrorStreamSocket* raw_transport = transport.get();
1335 scoped_ptr<SSLClientSocket> sock( 1333 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket(
1336 CreateSSLClientSocket(transport.PassAs<StreamSocket>(), 1334 transport.Pass(), test_server.host_port_pair(), ssl_config));
1337 test_server.host_port_pair(),
1338 ssl_config));
1339 1335
1340 raw_transport->SetNextWriteError(ERR_CONNECTION_RESET); 1336 raw_transport->SetNextWriteError(ERR_CONNECTION_RESET);
1341 1337
1342 rv = callback.GetResult(sock->Connect(callback.callback())); 1338 rv = callback.GetResult(sock->Connect(callback.callback()));
1343 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 1339 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
1344 EXPECT_FALSE(sock->IsConnected()); 1340 EXPECT_FALSE(sock->IsConnected());
1345 } 1341 }
1346 1342
1347 // Tests that the SSLClientSocket properly handles when the underlying transport 1343 // Tests that the SSLClientSocket properly handles when the underlying transport
1348 // synchronously returns an error code - such as if an intermediary terminates 1344 // synchronously returns an error code - such as if an intermediary terminates
(...skipping 14 matching lines...) Expand all
1363 scoped_ptr<SynchronousErrorStreamSocket> transport( 1359 scoped_ptr<SynchronousErrorStreamSocket> transport(
1364 new SynchronousErrorStreamSocket(real_transport.Pass())); 1360 new SynchronousErrorStreamSocket(real_transport.Pass()));
1365 int rv = callback.GetResult(transport->Connect(callback.callback())); 1361 int rv = callback.GetResult(transport->Connect(callback.callback()));
1366 EXPECT_EQ(OK, rv); 1362 EXPECT_EQ(OK, rv);
1367 1363
1368 // Disable TLS False Start to avoid handshake non-determinism. 1364 // Disable TLS False Start to avoid handshake non-determinism.
1369 SSLConfig ssl_config; 1365 SSLConfig ssl_config;
1370 ssl_config.false_start_enabled = false; 1366 ssl_config.false_start_enabled = false;
1371 1367
1372 SynchronousErrorStreamSocket* raw_transport = transport.get(); 1368 SynchronousErrorStreamSocket* raw_transport = transport.get();
1373 scoped_ptr<SSLClientSocket> sock( 1369 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket(
1374 CreateSSLClientSocket(transport.PassAs<StreamSocket>(), 1370 transport.Pass(), test_server.host_port_pair(), ssl_config));
1375 test_server.host_port_pair(),
1376 ssl_config));
1377 1371
1378 rv = callback.GetResult(sock->Connect(callback.callback())); 1372 rv = callback.GetResult(sock->Connect(callback.callback()));
1379 EXPECT_EQ(OK, rv); 1373 EXPECT_EQ(OK, rv);
1380 EXPECT_TRUE(sock->IsConnected()); 1374 EXPECT_TRUE(sock->IsConnected());
1381 1375
1382 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; 1376 const char request_text[] = "GET / HTTP/1.0\r\n\r\n";
1383 static const int kRequestTextSize = 1377 static const int kRequestTextSize =
1384 static_cast<int>(arraysize(request_text) - 1); 1378 static_cast<int>(arraysize(request_text) - 1);
1385 scoped_refptr<IOBuffer> request_buffer(new IOBuffer(kRequestTextSize)); 1379 scoped_refptr<IOBuffer> request_buffer(new IOBuffer(kRequestTextSize));
1386 memcpy(request_buffer->data(), request_text, kRequestTextSize); 1380 memcpy(request_buffer->data(), request_text, kRequestTextSize);
(...skipping 29 matching lines...) Expand all
1416 1410
1417 TestCompletionCallback callback; 1411 TestCompletionCallback callback;
1418 scoped_ptr<StreamSocket> real_transport( 1412 scoped_ptr<StreamSocket> real_transport(
1419 new TCPClientSocket(addr, NULL, NetLog::Source())); 1413 new TCPClientSocket(addr, NULL, NetLog::Source()));
1420 // Note: |error_socket|'s ownership is handed to |transport|, but a pointer 1414 // Note: |error_socket|'s ownership is handed to |transport|, but a pointer
1421 // is retained in order to configure additional errors. 1415 // is retained in order to configure additional errors.
1422 scoped_ptr<SynchronousErrorStreamSocket> error_socket( 1416 scoped_ptr<SynchronousErrorStreamSocket> error_socket(
1423 new SynchronousErrorStreamSocket(real_transport.Pass())); 1417 new SynchronousErrorStreamSocket(real_transport.Pass()));
1424 SynchronousErrorStreamSocket* raw_error_socket = error_socket.get(); 1418 SynchronousErrorStreamSocket* raw_error_socket = error_socket.get();
1425 scoped_ptr<FakeBlockingStreamSocket> transport( 1419 scoped_ptr<FakeBlockingStreamSocket> transport(
1426 new FakeBlockingStreamSocket(error_socket.PassAs<StreamSocket>())); 1420 new FakeBlockingStreamSocket(error_socket.Pass()));
1427 FakeBlockingStreamSocket* raw_transport = transport.get(); 1421 FakeBlockingStreamSocket* raw_transport = transport.get();
1428 int rv = callback.GetResult(transport->Connect(callback.callback())); 1422 int rv = callback.GetResult(transport->Connect(callback.callback()));
1429 EXPECT_EQ(OK, rv); 1423 EXPECT_EQ(OK, rv);
1430 1424
1431 // Disable TLS False Start to avoid handshake non-determinism. 1425 // Disable TLS False Start to avoid handshake non-determinism.
1432 SSLConfig ssl_config; 1426 SSLConfig ssl_config;
1433 ssl_config.false_start_enabled = false; 1427 ssl_config.false_start_enabled = false;
1434 1428
1435 scoped_ptr<SSLClientSocket> sock( 1429 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket(
1436 CreateSSLClientSocket(transport.PassAs<StreamSocket>(), 1430 transport.Pass(), test_server.host_port_pair(), ssl_config));
1437 test_server.host_port_pair(),
1438 ssl_config));
1439 1431
1440 rv = callback.GetResult(sock->Connect(callback.callback())); 1432 rv = callback.GetResult(sock->Connect(callback.callback()));
1441 EXPECT_EQ(OK, rv); 1433 EXPECT_EQ(OK, rv);
1442 EXPECT_TRUE(sock->IsConnected()); 1434 EXPECT_TRUE(sock->IsConnected());
1443 1435
1444 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; 1436 const char request_text[] = "GET / HTTP/1.0\r\n\r\n";
1445 static const int kRequestTextSize = 1437 static const int kRequestTextSize =
1446 static_cast<int>(arraysize(request_text) - 1); 1438 static_cast<int>(arraysize(request_text) - 1);
1447 scoped_refptr<IOBuffer> request_buffer(new IOBuffer(kRequestTextSize)); 1439 scoped_refptr<IOBuffer> request_buffer(new IOBuffer(kRequestTextSize));
1448 memcpy(request_buffer->data(), request_text, kRequestTextSize); 1440 memcpy(request_buffer->data(), request_text, kRequestTextSize);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 1482
1491 TestCompletionCallback callback; 1483 TestCompletionCallback callback;
1492 scoped_ptr<StreamSocket> real_transport( 1484 scoped_ptr<StreamSocket> real_transport(
1493 new TCPClientSocket(addr, NULL, NetLog::Source())); 1485 new TCPClientSocket(addr, NULL, NetLog::Source()));
1494 // Note: intermediate sockets' ownership are handed to |sock|, but a pointer 1486 // Note: intermediate sockets' ownership are handed to |sock|, but a pointer
1495 // is retained in order to query them. 1487 // is retained in order to query them.
1496 scoped_ptr<SynchronousErrorStreamSocket> error_socket( 1488 scoped_ptr<SynchronousErrorStreamSocket> error_socket(
1497 new SynchronousErrorStreamSocket(real_transport.Pass())); 1489 new SynchronousErrorStreamSocket(real_transport.Pass()));
1498 SynchronousErrorStreamSocket* raw_error_socket = error_socket.get(); 1490 SynchronousErrorStreamSocket* raw_error_socket = error_socket.get();
1499 scoped_ptr<CountingStreamSocket> counting_socket( 1491 scoped_ptr<CountingStreamSocket> counting_socket(
1500 new CountingStreamSocket(error_socket.PassAs<StreamSocket>())); 1492 new CountingStreamSocket(error_socket.Pass()));
1501 CountingStreamSocket* raw_counting_socket = counting_socket.get(); 1493 CountingStreamSocket* raw_counting_socket = counting_socket.get();
1502 int rv = callback.GetResult(counting_socket->Connect(callback.callback())); 1494 int rv = callback.GetResult(counting_socket->Connect(callback.callback()));
1503 ASSERT_EQ(OK, rv); 1495 ASSERT_EQ(OK, rv);
1504 1496
1505 // Disable TLS False Start to avoid handshake non-determinism. 1497 // Disable TLS False Start to avoid handshake non-determinism.
1506 SSLConfig ssl_config; 1498 SSLConfig ssl_config;
1507 ssl_config.false_start_enabled = false; 1499 ssl_config.false_start_enabled = false;
1508 1500
1509 scoped_ptr<SSLClientSocket> sock( 1501 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket(
1510 CreateSSLClientSocket(counting_socket.PassAs<StreamSocket>(), 1502 counting_socket.Pass(), test_server.host_port_pair(), ssl_config));
1511 test_server.host_port_pair(),
1512 ssl_config));
1513 1503
1514 rv = callback.GetResult(sock->Connect(callback.callback())); 1504 rv = callback.GetResult(sock->Connect(callback.callback()));
1515 ASSERT_EQ(OK, rv); 1505 ASSERT_EQ(OK, rv);
1516 ASSERT_TRUE(sock->IsConnected()); 1506 ASSERT_TRUE(sock->IsConnected());
1517 1507
1518 // Simulate an unclean/forcible shutdown on the underlying socket. 1508 // Simulate an unclean/forcible shutdown on the underlying socket.
1519 raw_error_socket->SetNextWriteError(ERR_CONNECTION_RESET); 1509 raw_error_socket->SetNextWriteError(ERR_CONNECTION_RESET);
1520 1510
1521 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; 1511 const char request_text[] = "GET / HTTP/1.0\r\n\r\n";
1522 static const int kRequestTextSize = 1512 static const int kRequestTextSize =
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 1610
1621 TestCompletionCallback callback; 1611 TestCompletionCallback callback;
1622 scoped_ptr<StreamSocket> real_transport( 1612 scoped_ptr<StreamSocket> real_transport(
1623 new TCPClientSocket(addr, NULL, NetLog::Source())); 1613 new TCPClientSocket(addr, NULL, NetLog::Source()));
1624 // Note: |error_socket|'s ownership is handed to |transport|, but a pointer 1614 // Note: |error_socket|'s ownership is handed to |transport|, but a pointer
1625 // is retained in order to configure additional errors. 1615 // is retained in order to configure additional errors.
1626 scoped_ptr<SynchronousErrorStreamSocket> error_socket( 1616 scoped_ptr<SynchronousErrorStreamSocket> error_socket(
1627 new SynchronousErrorStreamSocket(real_transport.Pass())); 1617 new SynchronousErrorStreamSocket(real_transport.Pass()));
1628 SynchronousErrorStreamSocket* raw_error_socket = error_socket.get(); 1618 SynchronousErrorStreamSocket* raw_error_socket = error_socket.get();
1629 scoped_ptr<FakeBlockingStreamSocket> transport( 1619 scoped_ptr<FakeBlockingStreamSocket> transport(
1630 new FakeBlockingStreamSocket(error_socket.PassAs<StreamSocket>())); 1620 new FakeBlockingStreamSocket(error_socket.Pass()));
1631 FakeBlockingStreamSocket* raw_transport = transport.get(); 1621 FakeBlockingStreamSocket* raw_transport = transport.get();
1632 1622
1633 int rv = callback.GetResult(transport->Connect(callback.callback())); 1623 int rv = callback.GetResult(transport->Connect(callback.callback()));
1634 EXPECT_EQ(OK, rv); 1624 EXPECT_EQ(OK, rv);
1635 1625
1636 // Disable TLS False Start to avoid handshake non-determinism. 1626 // Disable TLS False Start to avoid handshake non-determinism.
1637 SSLConfig ssl_config; 1627 SSLConfig ssl_config;
1638 ssl_config.false_start_enabled = false; 1628 ssl_config.false_start_enabled = false;
1639 1629
1640 scoped_ptr<SSLClientSocket> sock = 1630 scoped_ptr<SSLClientSocket> sock = CreateSSLClientSocket(
1641 CreateSSLClientSocket(transport.PassAs<StreamSocket>(), 1631 transport.Pass(), test_server.host_port_pair(), ssl_config);
1642 test_server.host_port_pair(),
1643 ssl_config);
1644 1632
1645 rv = callback.GetResult(sock->Connect(callback.callback())); 1633 rv = callback.GetResult(sock->Connect(callback.callback()));
1646 EXPECT_EQ(OK, rv); 1634 EXPECT_EQ(OK, rv);
1647 EXPECT_TRUE(sock->IsConnected()); 1635 EXPECT_TRUE(sock->IsConnected());
1648 1636
1649 std::string request_text = "GET / HTTP/1.1\r\nUser-Agent: long browser name "; 1637 std::string request_text = "GET / HTTP/1.1\r\nUser-Agent: long browser name ";
1650 request_text.append(20 * 1024, '*'); 1638 request_text.append(20 * 1024, '*');
1651 request_text.append("\r\n\r\n"); 1639 request_text.append("\r\n\r\n");
1652 scoped_refptr<DrainableIOBuffer> request_buffer(new DrainableIOBuffer( 1640 scoped_refptr<DrainableIOBuffer> request_buffer(new DrainableIOBuffer(
1653 new StringIOBuffer(request_text), request_text.size())); 1641 new StringIOBuffer(request_text), request_text.size()));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 1724
1737 TestCompletionCallback callback; 1725 TestCompletionCallback callback;
1738 scoped_ptr<StreamSocket> real_transport( 1726 scoped_ptr<StreamSocket> real_transport(
1739 new TCPClientSocket(addr, NULL, NetLog::Source())); 1727 new TCPClientSocket(addr, NULL, NetLog::Source()));
1740 // Note: |error_socket|'s ownership is handed to |transport|, but a pointer 1728 // Note: |error_socket|'s ownership is handed to |transport|, but a pointer
1741 // is retained in order to configure additional errors. 1729 // is retained in order to configure additional errors.
1742 scoped_ptr<SynchronousErrorStreamSocket> error_socket( 1730 scoped_ptr<SynchronousErrorStreamSocket> error_socket(
1743 new SynchronousErrorStreamSocket(real_transport.Pass())); 1731 new SynchronousErrorStreamSocket(real_transport.Pass()));
1744 SynchronousErrorStreamSocket* raw_error_socket = error_socket.get(); 1732 SynchronousErrorStreamSocket* raw_error_socket = error_socket.get();
1745 scoped_ptr<FakeBlockingStreamSocket> transport( 1733 scoped_ptr<FakeBlockingStreamSocket> transport(
1746 new FakeBlockingStreamSocket(error_socket.PassAs<StreamSocket>())); 1734 new FakeBlockingStreamSocket(error_socket.Pass()));
1747 FakeBlockingStreamSocket* raw_transport = transport.get(); 1735 FakeBlockingStreamSocket* raw_transport = transport.get();
1748 1736
1749 int rv = callback.GetResult(transport->Connect(callback.callback())); 1737 int rv = callback.GetResult(transport->Connect(callback.callback()));
1750 EXPECT_EQ(OK, rv); 1738 EXPECT_EQ(OK, rv);
1751 1739
1752 // Disable TLS False Start to avoid handshake non-determinism. 1740 // Disable TLS False Start to avoid handshake non-determinism.
1753 SSLConfig ssl_config; 1741 SSLConfig ssl_config;
1754 ssl_config.false_start_enabled = false; 1742 ssl_config.false_start_enabled = false;
1755 1743
1756 scoped_ptr<SSLClientSocket> sock( 1744 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket(
1757 CreateSSLClientSocket(transport.PassAs<StreamSocket>(), 1745 transport.Pass(), test_server.host_port_pair(), ssl_config));
1758 test_server.host_port_pair(),
1759 ssl_config));
1760 1746
1761 rv = callback.GetResult(sock->Connect(callback.callback())); 1747 rv = callback.GetResult(sock->Connect(callback.callback()));
1762 EXPECT_EQ(OK, rv); 1748 EXPECT_EQ(OK, rv);
1763 EXPECT_TRUE(sock->IsConnected()); 1749 EXPECT_TRUE(sock->IsConnected());
1764 1750
1765 // Send a request so there is something to read from the socket. 1751 // Send a request so there is something to read from the socket.
1766 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; 1752 const char request_text[] = "GET / HTTP/1.0\r\n\r\n";
1767 static const int kRequestTextSize = 1753 static const int kRequestTextSize =
1768 static_cast<int>(arraysize(request_text) - 1); 1754 static_cast<int>(arraysize(request_text) - 1);
1769 scoped_refptr<IOBuffer> request_buffer(new IOBuffer(kRequestTextSize)); 1755 scoped_refptr<IOBuffer> request_buffer(new IOBuffer(kRequestTextSize));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 TestCompletionCallback callback; 1877 TestCompletionCallback callback;
1892 1878
1893 scoped_ptr<StreamSocket> real_transport( 1879 scoped_ptr<StreamSocket> real_transport(
1894 new TCPClientSocket(addr, NULL, NetLog::Source())); 1880 new TCPClientSocket(addr, NULL, NetLog::Source()));
1895 scoped_ptr<ReadBufferingStreamSocket> transport( 1881 scoped_ptr<ReadBufferingStreamSocket> transport(
1896 new ReadBufferingStreamSocket(real_transport.Pass())); 1882 new ReadBufferingStreamSocket(real_transport.Pass()));
1897 ReadBufferingStreamSocket* raw_transport = transport.get(); 1883 ReadBufferingStreamSocket* raw_transport = transport.get();
1898 int rv = callback.GetResult(transport->Connect(callback.callback())); 1884 int rv = callback.GetResult(transport->Connect(callback.callback()));
1899 ASSERT_EQ(OK, rv); 1885 ASSERT_EQ(OK, rv);
1900 1886
1901 scoped_ptr<SSLClientSocket> sock( 1887 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket(
1902 CreateSSLClientSocket(transport.PassAs<StreamSocket>(), 1888 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig));
1903 test_server.host_port_pair(),
1904 kDefaultSSLConfig));
1905 1889
1906 rv = callback.GetResult(sock->Connect(callback.callback())); 1890 rv = callback.GetResult(sock->Connect(callback.callback()));
1907 ASSERT_EQ(OK, rv); 1891 ASSERT_EQ(OK, rv);
1908 ASSERT_TRUE(sock->IsConnected()); 1892 ASSERT_TRUE(sock->IsConnected());
1909 1893
1910 const char request_text[] = "GET /ssl-many-small-records HTTP/1.0\r\n\r\n"; 1894 const char request_text[] = "GET /ssl-many-small-records HTTP/1.0\r\n\r\n";
1911 scoped_refptr<IOBuffer> request_buffer( 1895 scoped_refptr<IOBuffer> request_buffer(
1912 new IOBuffer(arraysize(request_text) - 1)); 1896 new IOBuffer(arraysize(request_text) - 1));
1913 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); 1897 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1);
1914 1898
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 scoped_ptr<SynchronousErrorStreamSocket> transport( 2678 scoped_ptr<SynchronousErrorStreamSocket> transport(
2695 new SynchronousErrorStreamSocket(real_transport.Pass())); 2679 new SynchronousErrorStreamSocket(real_transport.Pass()));
2696 int rv = callback.GetResult(transport->Connect(callback.callback())); 2680 int rv = callback.GetResult(transport->Connect(callback.callback()));
2697 EXPECT_EQ(OK, rv); 2681 EXPECT_EQ(OK, rv);
2698 2682
2699 // Disable TLS False Start to avoid handshake non-determinism. 2683 // Disable TLS False Start to avoid handshake non-determinism.
2700 SSLConfig ssl_config; 2684 SSLConfig ssl_config;
2701 ssl_config.false_start_enabled = false; 2685 ssl_config.false_start_enabled = false;
2702 2686
2703 SynchronousErrorStreamSocket* raw_transport = transport.get(); 2687 SynchronousErrorStreamSocket* raw_transport = transport.get();
2704 scoped_ptr<SSLClientSocket> sock( 2688 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket(
2705 CreateSSLClientSocket(transport.PassAs<StreamSocket>(), 2689 transport.Pass(), test_server.host_port_pair(), ssl_config));
2706 test_server.host_port_pair(),
2707 ssl_config));
2708 2690
2709 sock->SetHandshakeCompletionCallback(base::Bind( 2691 sock->SetHandshakeCompletionCallback(base::Bind(
2710 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this))); 2692 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this)));
2711 2693
2712 raw_transport->SetNextWriteError(ERR_CONNECTION_RESET); 2694 raw_transport->SetNextWriteError(ERR_CONNECTION_RESET);
2713 2695
2714 rv = callback.GetResult(sock->Connect(callback.callback())); 2696 rv = callback.GetResult(sock->Connect(callback.callback()));
2715 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 2697 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
2716 EXPECT_FALSE(sock->IsConnected()); 2698 EXPECT_FALSE(sock->IsConnected());
2717 2699
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2983 ssl_config.channel_id_enabled = true; 2965 ssl_config.channel_id_enabled = true;
2984 2966
2985 int rv; 2967 int rv;
2986 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); 2968 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv));
2987 2969
2988 EXPECT_EQ(ERR_UNEXPECTED, rv); 2970 EXPECT_EQ(ERR_UNEXPECTED, rv);
2989 EXPECT_FALSE(sock_->IsConnected()); 2971 EXPECT_FALSE(sock_->IsConnected());
2990 } 2972 }
2991 2973
2992 } // namespace net 2974 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_pool.cc ('k') | net/socket/tcp_listen_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698