Landing recent QUIC changes until 8:47 PM, Nov 30, 2018 UTC-5

Flag changes:
Enable FLAGS_quic_reloadable_flag_quic_aggregate_acked_stream_frames_2
Enable FLAGS_quic_reloadable_flag_quic_new_lru_cache
Enable FLAGS_quic_reloadable_flag_quic_optimize_encryption_established
Enable FLAGS_quic_restart_flag_quic_no_ephemeral_key_source

Handle RST_STREAM frames received by PendingStream.
Merge internal change: 223602833
https://chromium-review.googlesource.com/c/chromium/src/+/1365799

Add a method to QuartcStream to ask it for the current read offset.
Merge internal change: 223580443
https://chromium-review.googlesource.com/c/chromium/src/+/1365798

First step towards variable length QUIC connection IDs. This CL introduces QuicConnectionIdFromUInt64() and QuicConnectionIdToUInt64() and uses it in all code that assumes connection IDs are uint64_t's. Once this is in, the next step will be to make QuicConnectionId a class that contains a uint64_t.
Merge internal change: 223557525
https://chromium-review.googlesource.com/c/chromium/src/+/1365796

In QUIC v99, when stream is created, determine stream type solely by stream ID.
Merge internal change: 223522570
https://chromium-review.googlesource.com/c/chromium/src/+/1363435

Add a new method to QuicSession for creating an incoming stream from a PendingStream. Implement this method in the various session subclasses which also requires add a PendingStream-based constructor to various QuicStream subclasses.
Merge internal change: 222419285
https://chromium-review.googlesource.com/c/chromium/src/+/1363434

Pass a QuicPerPacketContext into QuicTimeWaitListManager::ProcessPacket and QuicTimeWaitListManager::SendVersionNegotiationPacket. The context is not used in this CL, so there is no behavior change.
Merge internal change: 223407840
https://chromium-review.googlesource.com/c/chromium/src/+/1361636

Add a QUIC connection option to disable pacing offload.
Merge internal change: 223405141
https://chromium-review.googlesource.com/c/chromium/src/+/1361635

Change QpackInstructionEncoder and Decoder varint type to uint64_t.
Merge internal change: 223384725
https://chromium-review.googlesource.com/c/chromium/src/+/1361628

In QuicTimeWaitListManager, rename server_address to self_address, and client_address to peer_address.
Merge internal change: 223338983
https://chromium-review.googlesource.com/c/chromium/src/+/1361626

When a QuicStream is constructed from a PendingStream, ensure that the moved sequencer points to the new QuicStream not the old PendingStream.
Merge internal change: 223338371
https://chromium-review.googlesource.com/c/chromium/src/+/1361625

In QUIC, implement IETF style bidirectional and unidirectional stream IDs numbering in version 99.
Merge internal change: 223337761
https://chromium-review.googlesource.com/c/chromium/src/+/1361624

Move quic::QuicDispatcher::PerPacketContext to quic_packets.h, and rename it to quic::QuicPerPacketContext.
Merge internal change: 223234533
https://chromium-review.googlesource.com/c/chromium/src/+/1361329

Add GetNextUnreadRegion() API in QuicStreamSequencerBuffer.
Merge internal change: 223233937
https://chromium-review.googlesource.com/c/chromium/src/+/1361328

Remove the limit on QUIC stream buffer length.
Merge internal change: 223213240
https://chromium-review.googlesource.com/c/chromium/src/+/1361326

Change QuartcStream's max retransmission count to per-stream rather than number of frames.
Merge internal change: 223014131
https://chromium-review.googlesource.com/c/chromium/src/+/1361323

[email protected]

Change-Id: I5f57f2c168cef9d0875bc6a516702110be47b070
Reviewed-on: https://chromium-review.googlesource.com/c/1366437
Commit-Queue: Fan Yang <[email protected]>
Reviewed-by: Kentaro Hara <[email protected]>
Reviewed-by: Martin Šrámek <[email protected]>
Reviewed-by: Ryan Hamilton <[email protected]>
Cr-Commit-Position: refs/heads/master@{#615215}
diff --git a/net/quic/quic_http_stream_test.cc b/net/quic/quic_http_stream_test.cc
index f35005e..d01cfb162 100644
--- a/net/quic/quic_http_stream_test.cc
+++ b/net/quic/quic_http_stream_test.cc
@@ -194,9 +194,9 @@
         crypto_config_(quic::test::crypto_test_utils::ProofVerifierForTesting(),
                        quic::TlsClientHandshaker::CreateSslCtx()),
         read_buffer_(base::MakeRefCounted<IOBufferWithSize>(4096)),
-        promise_id_(GetNthServerInitiatedStreamId(0)),
-        stream_id_(GetNthClientInitiatedStreamId(0)),
-        connection_id_(2),
+        promise_id_(GetNthServerInitiatedUnidirectionalStreamId(0)),
+        stream_id_(GetNthClientInitiatedBidirectionalStreamId(0)),
+        connection_id_(quic::QuicConnectionIdFromUInt64(2)),
         client_maker_(version_,
                       connection_id_,
                       &clock_,
@@ -641,12 +641,12 @@
     ExpectLoadTimingHasOnlyConnectionTimes(load_timing_info);
   }
 
-  quic::QuicStreamId GetNthClientInitiatedStreamId(int n) {
-    return quic::test::GetNthClientInitiatedStreamId(version_, n);
+  quic::QuicStreamId GetNthClientInitiatedBidirectionalStreamId(int n) {
+    return quic::test::GetNthClientInitiatedBidirectionalStreamId(version_, n);
   }
 
-  quic::QuicStreamId GetNthServerInitiatedStreamId(int n) {
-    return quic::test::GetNthServerInitiatedStreamId(version_, n);
+  quic::QuicStreamId GetNthServerInitiatedUnidirectionalStreamId(int n) {
+    return quic::test::GetNthServerInitiatedUnidirectionalStreamId(version_, n);
   }
 
   const quic::QuicTransportVersion version_;
@@ -732,7 +732,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
       DEFAULT_PRIORITY, &spdy_request_header_frame_length,
       &header_stream_offset));
 
@@ -795,14 +795,14 @@
   quic::QuicStreamOffset offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
       DEFAULT_PRIORITY, &spdy_request_header_frame_length, &offset));
 
   // SetRequest() again for second request as |request_headers_| was moved.
   SetRequest("GET", "/", DEFAULT_PRIORITY);
   AddWrite(InnerConstructRequestHeadersPacket(
-      3, GetNthClientInitiatedStreamId(1), kIncludeVersion, kFin,
-      DEFAULT_PRIORITY, GetNthClientInitiatedStreamId(0),
+      3, GetNthClientInitiatedBidirectionalStreamId(1), kIncludeVersion, kFin,
+      DEFAULT_PRIORITY, GetNthClientInitiatedBidirectionalStreamId(0),
       &spdy_request_header_frame_length, &offset));
   AddWrite(ConstructClientAckPacket(4, 3, 1, 1));  // Ack the responses.
 
@@ -835,7 +835,7 @@
   size_t spdy_response_header_frame_length;
   SetResponse("200 OK", string());
   ProcessPacket(InnerConstructResponseHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kFin,
       &spdy_response_header_frame_length));
 
   // Now that the headers have been processed, the callback will return.
@@ -858,7 +858,7 @@
               IsError(ERR_IO_PENDING));
 
   ProcessPacket(InnerConstructResponseHeadersPacket(
-      3, GetNthClientInitiatedStreamId(1), kFin,
+      3, GetNthClientInitiatedBidirectionalStreamId(1), kFin,
       &spdy_response_header_frame_length));
 
   EXPECT_THAT(callback2.WaitForResult(), IsOk());
@@ -882,7 +882,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
       DEFAULT_PRIORITY, &spdy_request_header_frame_length,
       &header_stream_offset));
   AddWrite(ConstructClientAckPacket(3, 3, 1, 1));  // Ack the data packet.
@@ -978,7 +978,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
       DEFAULT_PRIORITY, &spdy_request_headers_frame_length,
       &header_stream_offset));
   Initialize();
@@ -1106,7 +1106,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
       DEFAULT_PRIORITY, &spdy_request_headers_frame_length,
       &header_stream_offset));
   AddWrite(ConstructAckAndRstStreamPacket(3));
@@ -1148,7 +1148,7 @@
   client_maker_.SetEncryptionLevel(quic::ENCRYPTION_INITIAL);
   client_maker_.SetLongHeaderType(quic::ZERO_RTT_PROTECTED);
   AddWrite(InnerConstructRequestHeadersPacket(
-      1, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin,
+      1, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
       DEFAULT_PRIORITY, &spdy_request_headers_frame_length,
       &header_stream_offset));
   Initialize();
@@ -1183,7 +1183,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
       DEFAULT_PRIORITY, &spdy_request_headers_frame_length,
       &header_stream_offset));
   Initialize();
@@ -1217,7 +1217,7 @@
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
 
   AddWrite(ConstructRequestHeadersAndDataFramesPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
       DEFAULT_PRIORITY, 0, &header_stream_offset,
       &spdy_request_headers_frame_length, {kUploadData}));
 
@@ -1288,7 +1288,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(ConstructRequestHeadersAndDataFramesPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
       DEFAULT_PRIORITY, 0, &header_stream_offset,
       &spdy_request_headers_frame_length, {kUploadData}));
   AddWrite(ConstructClientAckPacket(3, 3, 1, 1));
@@ -1361,7 +1361,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(ConstructRequestHeadersAndDataFramesPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, !kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, !kFin,
       DEFAULT_PRIORITY, 0, &header_stream_offset,
       &spdy_request_headers_frame_length, {kUploadData}));
   AddWrite(ConstructClientDataPacket(3, kIncludeVersion, kFin, chunk_size,
@@ -1434,7 +1434,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(ConstructRequestHeadersAndDataFramesPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, !kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, !kFin,
       DEFAULT_PRIORITY, 0, &header_stream_offset,
       &spdy_request_headers_frame_length, {kUploadData}));
   AddWrite(ConstructClientDataPacket(3, kIncludeVersion, kFin, chunk_size, ""));
@@ -1503,7 +1503,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, !kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, !kFin,
       DEFAULT_PRIORITY, &spdy_request_headers_frame_length,
       &header_stream_offset));
   AddWrite(ConstructClientDataPacket(3, kIncludeVersion, kFin, 0, ""));
@@ -1571,7 +1571,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
       DEFAULT_PRIORITY, &spdy_request_headers_frame_length,
       &header_stream_offset));
   AddWrite(ConstructAckAndRstStreamPacket(3));
@@ -1618,8 +1618,8 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, kFin, MEDIUM,
-      &spdy_request_headers_frame_length, &header_stream_offset));
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, kFin,
+      MEDIUM, &spdy_request_headers_frame_length, &header_stream_offset));
   Initialize();
 
   request_.method = "GET";
@@ -1660,7 +1660,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(ConstructRequestHeadersAndDataFramesPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, !kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, !kFin,
       DEFAULT_PRIORITY, 0, &header_stream_offset,
       &spdy_request_headers_frame_length, {kUploadData}));
   // Second data write will result in a synchronous failure which will close
@@ -1771,7 +1771,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, !kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, !kFin,
       DEFAULT_PRIORITY, &spdy_request_headers_frame_length,
       &header_stream_offset));
   AddWrite(SYNCHRONOUS, ERR_FAILED);
@@ -1812,7 +1812,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(ConstructRequestHeadersAndDataFramesPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, !kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, !kFin,
       DEFAULT_PRIORITY, 0, &header_stream_offset,
       &spdy_request_headers_frame_length, {kUploadData}));
   AddWrite(SYNCHRONOUS, ERR_FAILED);
@@ -2222,9 +2222,9 @@
         DEFAULT_PRIORITY, &header_stream_offset));
   }
   AddWrite(ConstructClientRstStreamVaryMismatchAndRequestHeadersPacket(
-      client_packet_number++, stream_id_ + 2, !kIncludeVersion, kFin,
-      DEFAULT_PRIORITY, promise_id_, &spdy_request_header_frame_length,
-      &header_stream_offset));
+      client_packet_number++, stream_id_ + quic::test::NextStreamId(version_),
+      !kIncludeVersion, kFin, DEFAULT_PRIORITY, promise_id_,
+      &spdy_request_header_frame_length, &header_stream_offset));
   AddWrite(ConstructClientAckPacket(client_packet_number++, 3, 1, 1));
   AddWrite(ConstructClientRstStreamCancelledPacket(client_packet_number++));
 
@@ -2284,7 +2284,7 @@
   EXPECT_EQ(
       QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get())
           ->id(),
-      stream_id_ + 2);
+      stream_id_ + quic::test::NextStreamId(version_));
 
   // After rendezvous failure, the push stream has been cancelled.
   EXPECT_EQ(session_->GetPromisedByUrl(promise_url_), nullptr);
@@ -2298,7 +2298,8 @@
   SetResponse("404 Not Found", string());
   size_t spdy_response_header_frame_length;
   ProcessPacket(InnerConstructResponseHeadersPacket(
-      3, stream_id_ + 2, kFin, &spdy_response_header_frame_length));
+      3, stream_id_ + quic::test::NextStreamId(version_), kFin,
+      &spdy_response_header_frame_length));
 
   base::RunLoop().RunUntilIdle();
 
@@ -2334,7 +2335,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(ConstructRequestAndRstPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, !kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, !kFin,
       DEFAULT_PRIORITY, 0, &spdy_request_headers_frame_length,
       &header_stream_offset, quic::QUIC_ERROR_PROCESSING_STREAM, 0));
 
@@ -2369,7 +2370,7 @@
   quic::QuicStreamOffset header_stream_offset = 0;
   AddWrite(ConstructInitialSettingsPacket(&header_stream_offset));
   AddWrite(InnerConstructRequestHeadersPacket(
-      2, GetNthClientInitiatedStreamId(0), kIncludeVersion, !kFin,
+      2, GetNthClientInitiatedBidirectionalStreamId(0), kIncludeVersion, !kFin,
       DEFAULT_PRIORITY, &spdy_request_headers_frame_length,
       &header_stream_offset));
   AddWrite(ConstructClientRstStreamErrorPacket(3, !kIncludeVersion));