Chromium Code Reviews| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/run_loop.h" | |
| 10 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 12 #include "net/base/network_quality_estimator.h" | 13 #include "net/base/network_quality_estimator.h" |
| 13 #include "net/base/socket_performance_watcher.h" | 14 #include "net/base/socket_performance_watcher.h" |
| 14 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
| 15 #include "net/base/test_data_directory.h" | 16 #include "net/base/test_data_directory.h" |
| 16 #include "net/cert/mock_cert_verifier.h" | 17 #include "net/cert/mock_cert_verifier.h" |
| 17 #include "net/cert/multi_log_ct_verifier.h" | 18 #include "net/cert/multi_log_ct_verifier.h" |
| 18 #include "net/dns/mock_host_resolver.h" | 19 #include "net/dns/mock_host_resolver.h" |
| 19 #include "net/http/http_auth_handler_factory.h" | 20 #include "net/http/http_auth_handler_factory.h" |
| (...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1328 MockWrite http_writes[] = { | 1329 MockWrite http_writes[] = { |
| 1329 MockWrite(SYNCHRONOUS, 0, "GET / HTTP/1.1\r\n"), | 1330 MockWrite(SYNCHRONOUS, 0, "GET / HTTP/1.1\r\n"), |
| 1330 MockWrite(SYNCHRONOUS, 1, "Host: mail.example.com\r\n"), | 1331 MockWrite(SYNCHRONOUS, 1, "Host: mail.example.com\r\n"), |
| 1331 MockWrite(SYNCHRONOUS, 2, "Connection: keep-alive\r\n\r\n")}; | 1332 MockWrite(SYNCHRONOUS, 2, "Connection: keep-alive\r\n\r\n")}; |
| 1332 | 1333 |
| 1333 MockRead http_reads[] = { | 1334 MockRead http_reads[] = { |
| 1334 MockRead(SYNCHRONOUS, 3, "HTTP/1.1 200 OK\r\n"), | 1335 MockRead(SYNCHRONOUS, 3, "HTTP/1.1 200 OK\r\n"), |
| 1335 MockRead(SYNCHRONOUS, 4, kQuicAlternateProtocolHeader), | 1336 MockRead(SYNCHRONOUS, 4, kQuicAlternateProtocolHeader), |
| 1336 MockRead(SYNCHRONOUS, 5, "hello world"), MockRead(SYNCHRONOUS, OK, 6)}; | 1337 MockRead(SYNCHRONOUS, 5, "hello world"), MockRead(SYNCHRONOUS, OK, 6)}; |
| 1337 | 1338 |
| 1338 DeterministicMockClientSocketFactory socket_factory; | 1339 MockClientSocketFactory socket_factory; |
| 1339 | 1340 |
| 1340 DeterministicSocketData http_data(http_reads, arraysize(http_reads), | 1341 SequencedSocketData http_data(http_reads, arraysize(http_reads), http_writes, |
| 1341 http_writes, arraysize(http_writes)); | 1342 arraysize(http_writes)); |
| 1342 socket_factory.AddSocketDataProvider(&http_data); | 1343 socket_factory.AddSocketDataProvider(&http_data); |
| 1343 socket_factory.AddSSLSocketDataProvider(&ssl_data_); | 1344 socket_factory.AddSSLSocketDataProvider(&ssl_data_); |
| 1344 | 1345 |
| 1345 // The QUIC transaction will not be allowed to complete. | 1346 // The QUIC transaction will not be allowed to complete. |
| 1346 MockWrite quic_writes[] = {MockWrite(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 1347 MockWrite quic_writes[] = {MockWrite(SYNCHRONOUS, ERR_IO_PENDING, 1)}; |
| 1347 MockRead quic_reads[] = { | 1348 MockRead quic_reads[] = { |
| 1348 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 1), | 1349 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0), |
| 1349 }; | 1350 }; |
| 1350 DeterministicSocketData quic_data(quic_reads, arraysize(quic_reads), | 1351 SequencedSocketData quic_data(quic_reads, arraysize(quic_reads), quic_writes, |
| 1351 quic_writes, arraysize(quic_writes)); | 1352 arraysize(quic_writes)); |
| 1352 socket_factory.AddSocketDataProvider(&quic_data); | 1353 socket_factory.AddSocketDataProvider(&quic_data); |
| 1353 | 1354 |
| 1354 // The HTTP transaction will complete. | 1355 // The HTTP transaction will complete. |
| 1355 DeterministicSocketData http_data2(http_reads, arraysize(http_reads), | 1356 SequencedSocketData http_data2(http_reads, arraysize(http_reads), http_writes, |
| 1356 http_writes, arraysize(http_writes)); | 1357 arraysize(http_writes)); |
| 1357 socket_factory.AddSocketDataProvider(&http_data2); | 1358 socket_factory.AddSocketDataProvider(&http_data2); |
| 1358 socket_factory.AddSSLSocketDataProvider(&ssl_data_); | 1359 socket_factory.AddSSLSocketDataProvider(&ssl_data_); |
| 1359 | 1360 |
| 1360 CreateSessionWithFactory(&socket_factory, true); | 1361 CreateSessionWithFactory(&socket_factory, true); |
| 1361 | 1362 |
| 1362 // Run the first request. | 1363 // Run the first request. |
| 1363 http_data.StopAfter(arraysize(http_reads) + arraysize(http_writes)); | |
| 1364 SendRequestAndExpectHttpResponse("hello world"); | 1364 SendRequestAndExpectHttpResponse("hello world"); |
| 1365 ASSERT_TRUE(http_data.AllReadDataConsumed()); | 1365 ASSERT_TRUE(http_data.AllReadDataConsumed()); |
| 1366 ASSERT_TRUE(http_data.AllWriteDataConsumed()); | 1366 ASSERT_TRUE(http_data.AllWriteDataConsumed()); |
| 1367 | 1367 |
| 1368 // Now run the second request in which the QUIC socket hangs, | 1368 // Now run the second request in which the QUIC socket hangs, |
| 1369 // and verify the the transaction continues over HTTP. | 1369 // and verify the the transaction continues over HTTP. |
| 1370 http_data2.StopAfter(arraysize(http_reads) + arraysize(http_writes)); | |
| 1371 SendRequestAndExpectHttpResponse("hello world"); | 1370 SendRequestAndExpectHttpResponse("hello world"); |
| 1371 base::RunLoop().RunUntilIdle(); | |
| 1372 | 1372 |
| 1373 ASSERT_TRUE(http_data2.AllReadDataConsumed()); | 1373 ASSERT_TRUE(http_data2.AllReadDataConsumed()); |
| 1374 ASSERT_TRUE(http_data2.AllWriteDataConsumed()); | 1374 ASSERT_TRUE(http_data2.AllWriteDataConsumed()); |
| 1375 ASSERT_TRUE(!quic_data.AllReadDataConsumed()); | 1375 ASSERT_TRUE(quic_data.AllReadDataConsumed()); |
|
mmenke
2015/12/18 17:37:53
Note that the "SYCHRONOUS" write, which the orderi
| |
| 1376 ASSERT_TRUE(!quic_data.AllWriteDataConsumed()); | |
| 1377 } | 1376 } |
| 1378 | 1377 |
| 1379 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithHttpRace) { | 1378 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithHttpRace) { |
| 1380 MockQuicData mock_quic_data; | 1379 MockQuicData mock_quic_data; |
| 1381 mock_quic_data.AddWrite( | 1380 mock_quic_data.AddWrite( |
| 1382 ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true, | 1381 ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true, |
| 1383 GetRequestHeaders("GET", "https", "/"))); | 1382 GetRequestHeaders("GET", "https", "/"))); |
| 1384 mock_quic_data.AddRead( | 1383 mock_quic_data.AddRead( |
| 1385 ConstructResponseHeadersPacket(1, kClientDataStreamId1, false, false, | 1384 ConstructResponseHeadersPacket(1, kClientDataStreamId1, false, false, |
| 1386 GetResponseHeaders("200 OK"))); | 1385 GetResponseHeaders("200 OK"))); |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1874 request_.url = GURL("https://www.example.org:443"); | 1873 request_.url = GURL("https://www.example.org:443"); |
| 1875 AddHangingNonAlternateProtocolSocketData(); | 1874 AddHangingNonAlternateProtocolSocketData(); |
| 1876 CreateSessionWithNextProtos(); | 1875 CreateSessionWithNextProtos(); |
| 1877 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); | 1876 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 1878 SendRequestAndExpectQuicResponse("hello!"); | 1877 SendRequestAndExpectQuicResponse("hello!"); |
| 1879 EXPECT_TRUE(rtt_observer_.rtt_notification_received()); | 1878 EXPECT_TRUE(rtt_observer_.rtt_notification_received()); |
| 1880 } | 1879 } |
| 1881 | 1880 |
| 1882 } // namespace test | 1881 } // namespace test |
| 1883 } // namespace net | 1882 } // namespace net |
| OLD | NEW |