Commit ae8db840 authored by bnc's avatar bnc Committed by Commit bot

Confirm QUIC alternative service upon success.

A non-broken but recently broken QUIC alternative service does not race for 0RTT
(because it is recently broken) but is still used (because it is not broken).
Upon successful connection, the service should be confirmed (marked as not
recently broken so that it can be used next time for 0RTT).

This CL adds this functionality and a test for it.  I locally verified that the
test fails without the rest of the change.

BUG=392575

Review URL: https://codereview.chromium.org/1035713003

Cr-Commit-Position: refs/heads/master@{#322455}
parent 02dd0e69
...@@ -527,6 +527,53 @@ TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolForQuic) { ...@@ -527,6 +527,53 @@ TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolForQuic) {
SendRequestAndExpectQuicResponse("hello!"); SendRequestAndExpectQuicResponse("hello!");
} }
TEST_P(QuicNetworkTransactionTest, ConfirmAlternativeService) {
MockRead http_reads[] = {
MockRead("HTTP/1.1 200 OK\r\n"),
MockRead(kQuicAlternateProtocolHttpHeader),
MockRead("hello world"),
MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
MockRead(ASYNC, OK)};
StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr,
0);
socket_factory_.AddSocketDataProvider(&http_data);
MockQuicData mock_quic_data;
mock_quic_data.AddWrite(
ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true,
GetRequestHeaders("GET", "http", "/")));
mock_quic_data.AddRead(ConstructResponseHeadersPacket(
1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK")));
mock_quic_data.AddRead(
ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!"));
mock_quic_data.AddWrite(ConstructAckPacket(2, 1));
mock_quic_data.AddRead(SYNCHRONOUS, 0); // EOF
mock_quic_data.AddDelayedSocketDataToFactory(&socket_factory_, 1);
// The non-alternate protocol job needs to hang in order to guarantee that
// the alternate-protocol job will "win".
AddHangingNonAlternateProtocolSocketData();
CreateSessionWithNextProtos();
AlternativeService alternative_service(QUIC,
HostPortPair::FromURL(request_.url));
session_->http_server_properties()->MarkAlternativeServiceRecentlyBroken(
alternative_service);
EXPECT_TRUE(
session_->http_server_properties()->WasAlternativeServiceRecentlyBroken(
alternative_service));
SendRequestAndExpectHttpResponse("hello world");
SendRequestAndExpectQuicResponse("hello!");
EXPECT_FALSE(
session_->http_server_properties()->WasAlternativeServiceRecentlyBroken(
alternative_service));
}
TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolProbabilityForQuic) { TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolProbabilityForQuic) {
MockRead http_reads[] = { MockRead http_reads[] = {
MockRead("HTTP/1.1 200 OK\r\n"), MockRead("HTTP/1.1 200 OK\r\n"),
......
...@@ -1134,7 +1134,10 @@ void QuicStreamFactory::ProcessGoingAwaySession( ...@@ -1134,7 +1134,10 @@ void QuicStreamFactory::ProcessGoingAwaySession(
return; return;
const QuicConnectionStats& stats = session->connection()->GetStats(); const QuicConnectionStats& stats = session->connection()->GetStats();
const AlternativeService alternative_service(QUIC,
server_id.host_port_pair());
if (session->IsCryptoHandshakeConfirmed()) { if (session->IsCryptoHandshakeConfirmed()) {
http_server_properties_->ConfirmAlternativeService(alternative_service);
ServerNetworkStats network_stats; ServerNetworkStats network_stats;
network_stats.srtt = base::TimeDelta::FromMicroseconds(stats.srtt_us); network_stats.srtt = base::TimeDelta::FromMicroseconds(stats.srtt_us);
network_stats.bandwidth_estimate = stats.estimated_bandwidth; network_stats.bandwidth_estimate = stats.estimated_bandwidth;
...@@ -1161,9 +1164,8 @@ void QuicStreamFactory::ProcessGoingAwaySession( ...@@ -1161,9 +1164,8 @@ void QuicStreamFactory::ProcessGoingAwaySession(
// job also fails. So to avoid not using QUIC when we otherwise could, we mark // job also fails. So to avoid not using QUIC when we otherwise could, we mark
// it as recently broken, which means that 0-RTT will be disabled but we'll // it as recently broken, which means that 0-RTT will be disabled but we'll
// still race. // still race.
const HostPortPair& server = server_id.host_port_pair();
http_server_properties_->MarkAlternativeServiceRecentlyBroken( http_server_properties_->MarkAlternativeServiceRecentlyBroken(
AlternativeService(QUIC, server.host(), server.port())); alternative_service);
} }
} // namespace net } // namespace net
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment