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/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "net/base/capturing_net_log.h" | 11 #include "net/base/capturing_net_log.h" |
| 12 #include "net/base/load_flags.h" | |
| 12 #include "net/base/net_log_unittest.h" | 13 #include "net/base/net_log_unittest.h" |
| 13 #include "net/base/test_completion_callback.h" | 14 #include "net/base/test_completion_callback.h" |
| 14 #include "net/cert/mock_cert_verifier.h" | 15 #include "net/cert/mock_cert_verifier.h" |
| 15 #include "net/dns/mock_host_resolver.h" | 16 #include "net/dns/mock_host_resolver.h" |
| 16 #include "net/http/http_auth_handler_factory.h" | 17 #include "net/http/http_auth_handler_factory.h" |
| 17 #include "net/http/http_network_session.h" | 18 #include "net/http/http_network_session.h" |
| 18 #include "net/http/http_network_transaction.h" | 19 #include "net/http/http_network_transaction.h" |
| 19 #include "net/http/http_server_properties_impl.h" | 20 #include "net/http/http_server_properties_impl.h" |
| 20 #include "net/http/http_stream.h" | 21 #include "net/http/http_stream.h" |
| 21 #include "net/http/http_stream_factory.h" | 22 #include "net/http/http_stream_factory.h" |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 socket_factory_.AddSocketDataProvider(&http_data); | 577 socket_factory_.AddSocketDataProvider(&http_data); |
| 577 | 578 |
| 578 params_.alternate_protocol_probability_threshold = .75; | 579 params_.alternate_protocol_probability_threshold = .75; |
| 579 CreateSessionWithNextProtos(); | 580 CreateSessionWithNextProtos(); |
| 580 | 581 |
| 581 SendRequestAndExpectHttpResponse("hello world"); | 582 SendRequestAndExpectHttpResponse("hello world"); |
| 582 SendRequestAndExpectHttpResponse("hello world"); | 583 SendRequestAndExpectHttpResponse("hello world"); |
| 583 } | 584 } |
| 584 | 585 |
| 585 TEST_P(QuicNetworkTransactionTest, | 586 TEST_P(QuicNetworkTransactionTest, |
| 587 DontUseAlternateProtocolForQuicWithDisableAlternateProtocols) { | |
| 588 MockRead http_reads[] = { | |
| 589 MockRead("HTTP/1.1 200 OK\r\n"), | |
| 590 MockRead(kQuicAlternateProtocol50pctHttpHeader), | |
| 591 MockRead("hello world"), | |
| 592 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | |
| 593 MockRead(ASYNC, OK) | |
| 594 }; | |
| 595 | |
| 596 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), | |
| 597 nullptr, 0); | |
| 598 socket_factory_.AddSocketDataProvider(&http_data); | |
| 599 socket_factory_.AddSocketDataProvider(&http_data); | |
| 600 | |
| 601 request_.load_flags = LOAD_DISABLE_ALTERNATE_PROTOCOLS; | |
| 602 | |
| 603 // Even though the alternate protocol probability works out in favor of using | |
| 604 // QUIC here, the LOAD_DISABLE_ALTERNATE_PROTOCOLS load flag should prevent | |
| 605 // QUIC from being used. | |
| 606 params_.alternate_protocol_probability_threshold = .25; | |
| 607 CreateSessionWithNextProtos(); | |
| 608 | |
| 609 SendRequestAndExpectHttpResponse("hello world"); | |
| 610 SendRequestAndExpectHttpResponse("hello world"); | |
|
Ryan Hamilton
2015/02/13 19:44:28
Please add a comment about why this line is duplic
| |
| 611 } | |
| 612 | |
| 613 TEST_P(QuicNetworkTransactionTest, | |
| 586 DontUseAlternateProtocolWithBadProbabilityForQuic) { | 614 DontUseAlternateProtocolWithBadProbabilityForQuic) { |
| 587 MockRead http_reads[] = { | 615 MockRead http_reads[] = { |
| 588 MockRead("HTTP/1.1 200 OK\r\n"), | 616 MockRead("HTTP/1.1 200 OK\r\n"), |
| 589 MockRead("Alternate-Protocol: 443:quic,p=2\r\n\r\n"), | 617 MockRead("Alternate-Protocol: 443:quic,p=2\r\n\r\n"), |
| 590 MockRead("hello world"), | 618 MockRead("hello world"), |
| 591 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 619 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 592 MockRead(ASYNC, OK) | 620 MockRead(ASYNC, OK) |
| 593 }; | 621 }; |
| 594 | 622 |
| 595 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), | 623 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 nullptr, | 1091 nullptr, |
| 1064 net_log_.bound()); | 1092 net_log_.bound()); |
| 1065 | 1093 |
| 1066 CreateSessionWithNextProtos(); | 1094 CreateSessionWithNextProtos(); |
| 1067 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 1095 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| 1068 SendRequestAndExpectHttpResponse("hello world"); | 1096 SendRequestAndExpectHttpResponse("hello world"); |
| 1069 } | 1097 } |
| 1070 | 1098 |
| 1071 } // namespace test | 1099 } // namespace test |
| 1072 } // namespace net | 1100 } // namespace net |
| OLD | NEW |