Change window_update frame's byte_offset to max_data to incorporate IETF spec.

https://tools.ietf.org/html/draft-ietf-quic-transport-24#section-19.10

gfe-relnote: name change only. Not protected.
PiperOrigin-RevId: 281838511
Change-Id: I716cfd6856d8c9dd9981040f68bc0567feaedaee
diff --git a/quic/core/frames/quic_frames_test.cc b/quic/core/frames/quic_frames_test.cc
index 303fd0c..1764e17 100644
--- a/quic/core/frames/quic_frames_test.cc
+++ b/quic/core/frames/quic_frames_test.cc
@@ -204,9 +204,9 @@
   EXPECT_EQ(3u, GetControlFrameId(frame));
   std::ostringstream stream;
   window_update.stream_id = 1;
-  window_update.byte_offset = 2;
+  window_update.max_data = 2;
   stream << window_update;
-  EXPECT_EQ("{ control_frame_id: 3, stream_id: 1, byte_offset: 2 }\n",
+  EXPECT_EQ("{ control_frame_id: 3, stream_id: 1, max_data: 2 }\n",
             stream.str());
   EXPECT_TRUE(IsControlFrame(frame.type));
 }
diff --git a/quic/core/frames/quic_window_update_frame.cc b/quic/core/frames/quic_window_update_frame.cc
index 07e3168..81ca125 100644
--- a/quic/core/frames/quic_window_update_frame.cc
+++ b/quic/core/frames/quic_window_update_frame.cc
@@ -13,16 +13,16 @@
 QuicWindowUpdateFrame::QuicWindowUpdateFrame(
     QuicControlFrameId control_frame_id,
     QuicStreamId stream_id,
-    QuicStreamOffset byte_offset)
+    QuicByteCount max_data)
     : control_frame_id(control_frame_id),
       stream_id(stream_id),
-      byte_offset(byte_offset) {}
+      max_data(max_data) {}
 
 std::ostream& operator<<(std::ostream& os,
                          const QuicWindowUpdateFrame& window_update_frame) {
   os << "{ control_frame_id: " << window_update_frame.control_frame_id
      << ", stream_id: " << window_update_frame.stream_id
-     << ", byte_offset: " << window_update_frame.byte_offset << " }\n";
+     << ", max_data: " << window_update_frame.max_data << " }\n";
   return os;
 }
 
diff --git a/quic/core/frames/quic_window_update_frame.h b/quic/core/frames/quic_window_update_frame.h
index 73163ce..ff44785 100644
--- a/quic/core/frames/quic_window_update_frame.h
+++ b/quic/core/frames/quic_window_update_frame.h
@@ -12,15 +12,13 @@
 namespace quic {
 
 // Flow control updates per-stream and at the connection level.
-// Based on SPDY's WINDOW_UPDATE frame, but uses an absolute byte offset rather
-// than a window delta.
-// TODO(rjshade): A possible future optimization is to make stream_id and
-//                byte_offset variable length, similar to stream frames.
+// Based on SPDY's WINDOW_UPDATE frame, but uses an absolute max data bytes
+// rather than a window delta.
 struct QUIC_EXPORT_PRIVATE QuicWindowUpdateFrame {
   QuicWindowUpdateFrame();
   QuicWindowUpdateFrame(QuicControlFrameId control_frame_id,
                         QuicStreamId stream_id,
-                        QuicStreamOffset byte_offset);
+                        QuicByteCount max_data);
 
   friend QUIC_EXPORT_PRIVATE std::ostream& operator<<(
       std::ostream& os,
@@ -34,13 +32,9 @@
   // connection rather than a specific stream.
   QuicStreamId stream_id;
 
-  // Byte offset in the stream or connection. The receiver of this frame must
-  // not send data which would result in this offset being exceeded.
-  //
-  // TODO(fkastenholz): Rename this to max_data and change the type to
-  // QuicByteCount because the IETF defines this as the "maximum
-  // amount of data that can be sent".
-  QuicStreamOffset byte_offset;
+  // Maximum data allowed in the stream or connection. The receiver of this
+  // frame must not send data which would exceedes this restriction.
+  QuicByteCount max_data;
 };
 
 }  // namespace quic
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 908fc4a..c457ca4 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -1296,9 +1296,7 @@
   if (debug_visitor_ != nullptr) {
     debug_visitor_->OnWindowUpdateFrame(frame, time_of_last_received_packet_);
   }
-  QUIC_DVLOG(1) << ENDPOINT << "WINDOW_UPDATE_FRAME received for stream: "
-                << frame.stream_id
-                << " with byte offset: " << frame.byte_offset;
+  QUIC_DVLOG(1) << ENDPOINT << "WINDOW_UPDATE_FRAME received " << frame;
   visitor_->OnWindowUpdateFrame(frame);
   should_last_packet_instigate_acks_ = true;
   return connected_;
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index c23e2b8..1fbd121 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -7093,7 +7093,7 @@
 
   QuicWindowUpdateFrame window_update;
   window_update.stream_id = 3;
-  window_update.byte_offset = 1234;
+  window_update.max_data = 1234;
   EXPECT_CALL(visitor_, OnWindowUpdateFrame(_));
   ProcessFramePacket(QuicFrame(&window_update));
 }
@@ -7383,7 +7383,7 @@
   // Send a WINDOW_UPDATE frame.
   QuicWindowUpdateFrame window_update;
   window_update.stream_id = 3;
-  window_update.byte_offset = 1234;
+  window_update.max_data = 1234;
   EXPECT_CALL(visitor_, OnWindowUpdateFrame(_));
   ProcessFramePacket(QuicFrame(&window_update));
 
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index 8164cdc..27e738a 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -546,13 +546,11 @@
   }
   if (frame.stream_id == QuicUtils::GetInvalidStreamId(version)) {
     // Frame would be a MAX DATA frame, which has only a Maximum Data field.
-    return kQuicFrameTypeSize +
-           QuicDataWriter::GetVarInt62Len(frame.byte_offset);
+    return kQuicFrameTypeSize + QuicDataWriter::GetVarInt62Len(frame.max_data);
   }
   // Frame would be MAX STREAM DATA, has Maximum Stream Data and Stream ID
   // fields.
-  return kQuicFrameTypeSize +
-         QuicDataWriter::GetVarInt62Len(frame.byte_offset) +
+  return kQuicFrameTypeSize + QuicDataWriter::GetVarInt62Len(frame.max_data) +
          QuicDataWriter::GetVarInt62Len(frame.stream_id);
 }
 
@@ -3921,7 +3919,7 @@
     return false;
   }
 
-  if (!reader->ReadUInt64(&frame->byte_offset)) {
+  if (!reader->ReadUInt64(&frame->max_data)) {
     set_detailed_error("Unable to read window byte_offset.");
     return false;
   }
@@ -5521,7 +5519,7 @@
   if (!writer->WriteUInt32(stream_id)) {
     return false;
   }
-  if (!writer->WriteUInt64(frame.byte_offset)) {
+  if (!writer->WriteUInt64(frame.max_data)) {
     return false;
   }
   return true;
@@ -5826,7 +5824,7 @@
 // Append/process IETF-Format MAX_DATA Frame
 bool QuicFramer::AppendMaxDataFrame(const QuicWindowUpdateFrame& frame,
                                     QuicDataWriter* writer) {
-  if (!writer->WriteVarInt62(frame.byte_offset)) {
+  if (!writer->WriteVarInt62(frame.max_data)) {
     set_detailed_error("Can not write MAX_DATA byte-offset");
     return false;
   }
@@ -5836,7 +5834,7 @@
 bool QuicFramer::ProcessMaxDataFrame(QuicDataReader* reader,
                                      QuicWindowUpdateFrame* frame) {
   frame->stream_id = QuicUtils::GetInvalidStreamId(transport_version());
-  if (!reader->ReadVarInt62(&frame->byte_offset)) {
+  if (!reader->ReadVarInt62(&frame->max_data)) {
     set_detailed_error("Can not read MAX_DATA byte-offset");
     return false;
   }
@@ -5850,7 +5848,7 @@
     set_detailed_error("Can not write MAX_STREAM_DATA stream id");
     return false;
   }
-  if (!writer->WriteVarInt62(frame.byte_offset)) {
+  if (!writer->WriteVarInt62(frame.max_data)) {
     set_detailed_error("Can not write MAX_STREAM_DATA byte-offset");
     return false;
   }
@@ -5863,7 +5861,7 @@
     set_detailed_error("Can not read MAX_STREAM_DATA stream id");
     return false;
   }
-  if (!reader->ReadVarInt62(&frame->byte_offset)) {
+  if (!reader->ReadVarInt62(&frame->max_data)) {
     set_detailed_error("Can not read MAX_STREAM_DATA byte-count");
     return false;
   }
diff --git a/quic/core/quic_framer_test.cc b/quic/core/quic_framer_test.cc
index 592b019..0f86dbe 100644
--- a/quic/core/quic_framer_test.cc
+++ b/quic/core/quic_framer_test.cc
@@ -4836,7 +4836,7 @@
       PACKET_8BYTE_CONNECTION_ID, PACKET_0BYTE_CONNECTION_ID));
 
   EXPECT_EQ(kStreamId, visitor_.window_update_frame_.stream_id);
-  EXPECT_EQ(kStreamOffset, visitor_.window_update_frame_.byte_offset);
+  EXPECT_EQ(kStreamOffset, visitor_.window_update_frame_.max_data);
 
   CheckFramingBoundaries(fragments, QUIC_INVALID_WINDOW_UPDATE_DATA);
 }
@@ -4880,7 +4880,7 @@
 
   EXPECT_EQ(QuicUtils::GetInvalidStreamId(framer_.transport_version()),
             visitor_.window_update_frame_.stream_id);
-  EXPECT_EQ(kStreamOffset, visitor_.window_update_frame_.byte_offset);
+  EXPECT_EQ(kStreamOffset, visitor_.window_update_frame_.max_data);
 
   CheckFramingBoundaries(packet99, QUIC_INVALID_MAX_DATA_FRAME_DATA);
 }
@@ -4926,7 +4926,7 @@
       PACKET_8BYTE_CONNECTION_ID, PACKET_0BYTE_CONNECTION_ID));
 
   EXPECT_EQ(kStreamId, visitor_.window_update_frame_.stream_id);
-  EXPECT_EQ(kStreamOffset, visitor_.window_update_frame_.byte_offset);
+  EXPECT_EQ(kStreamOffset, visitor_.window_update_frame_.max_data);
 
   CheckFramingBoundaries(packet99, QUIC_INVALID_MAX_STREAM_DATA_FRAME_DATA);
 }
@@ -8165,7 +8165,7 @@
 
   QuicWindowUpdateFrame window_update_frame;
   window_update_frame.stream_id = kStreamId;
-  window_update_frame.byte_offset = 0x1122334455667788;
+  window_update_frame.max_data = 0x1122334455667788;
 
   QuicFrames frames = {QuicFrame(&window_update_frame)};
 
@@ -8253,7 +8253,7 @@
 
   QuicWindowUpdateFrame window_update_frame;
   window_update_frame.stream_id = kStreamId;
-  window_update_frame.byte_offset = 0x1122334455667788;
+  window_update_frame.max_data = 0x1122334455667788;
 
   QuicFrames frames = {QuicFrame(&window_update_frame)};
 
@@ -8299,7 +8299,7 @@
   QuicWindowUpdateFrame window_update_frame;
   window_update_frame.stream_id =
       QuicUtils::GetInvalidStreamId(framer_.transport_version());
-  window_update_frame.byte_offset = 0x1122334455667788;
+  window_update_frame.max_data = 0x1122334455667788;
 
   QuicFrames frames = {QuicFrame(&window_update_frame)};
 
diff --git a/quic/core/quic_ietf_framer_test.cc b/quic/core/quic_ietf_framer_test.cc
index 8557a35..725eb68 100644
--- a/quic/core/quic_ietf_framer_test.cc
+++ b/quic/core/quic_ietf_framer_test.cc
@@ -1224,8 +1224,8 @@
         QuicFramerPeer::ProcessMaxDataFrame(&framer_, &reader, &receive_frame));
 
     // Now check that the received data equals the sent data.
-    EXPECT_EQ(transmit_frame.byte_offset, window_size);
-    EXPECT_EQ(transmit_frame.byte_offset, receive_frame.byte_offset);
+    EXPECT_EQ(transmit_frame.max_data, window_size);
+    EXPECT_EQ(transmit_frame.max_data, receive_frame.max_data);
     EXPECT_EQ(QuicUtils::GetInvalidStreamId(framer_.transport_version()),
               receive_frame.stream_id);
   }
@@ -1266,8 +1266,8 @@
                                                             &receive_frame));
 
       // Now check that received data and sent data are equal.
-      EXPECT_EQ(transmit_frame.byte_offset, window_size);
-      EXPECT_EQ(transmit_frame.byte_offset, receive_frame.byte_offset);
+      EXPECT_EQ(transmit_frame.max_data, window_size);
+      EXPECT_EQ(transmit_frame.max_data, receive_frame.max_data);
       EXPECT_EQ(stream_id, receive_frame.stream_id);
       EXPECT_EQ(transmit_frame.stream_id, receive_frame.stream_id);
     }
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index 1c85430..cba27f0 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -454,9 +454,9 @@
     // individual stream.
     QUIC_DVLOG(1) << ENDPOINT
                   << "Received connection level flow control window "
-                     "update with byte offset: "
-                  << frame.byte_offset;
-    flow_controller_.UpdateSendWindowOffset(frame.byte_offset);
+                     "update with max data: "
+                  << frame.max_data;
+    flow_controller_.UpdateSendWindowOffset(frame.max_data);
     return;
   }
 
diff --git a/quic/core/quic_stream.cc b/quic/core/quic_stream.cc
index 30c94f9..2037327 100644
--- a/quic/core/quic_stream.cc
+++ b/quic/core/quic_stream.cc
@@ -816,7 +816,7 @@
     return;
   }
 
-  if (flow_controller_->UpdateSendWindowOffset(frame.byte_offset)) {
+  if (flow_controller_->UpdateSendWindowOffset(frame.max_data)) {
     // Let session unblock this stream.
     session_->MarkConnectionLevelWriteBlocked(id_);
   }
diff --git a/quic/core/quic_stream_test.cc b/quic/core/quic_stream_test.cc
index e68ed58..ba21608 100644
--- a/quic/core/quic_stream_test.cc
+++ b/quic/core/quic_stream_test.cc
@@ -517,9 +517,8 @@
   QuicWindowUpdateFrame window_update_1(kInvalidControlFrameId, stream_->id(),
                                         kMinimumFlowControlSendWindow + 5);
   stream_->OnWindowUpdateFrame(window_update_1);
-  EXPECT_EQ(
-      window_update_1.byte_offset,
-      QuicFlowControllerPeer::SendWindowOffset(stream_->flow_controller()));
+  EXPECT_EQ(window_update_1.max_data, QuicFlowControllerPeer::SendWindowOffset(
+                                          stream_->flow_controller()));
 
   // Now send a few more WINDOW_UPDATES and make sure that only the largest is
   // remembered.
@@ -532,9 +531,8 @@
   stream_->OnWindowUpdateFrame(window_update_2);
   stream_->OnWindowUpdateFrame(window_update_3);
   stream_->OnWindowUpdateFrame(window_update_4);
-  EXPECT_EQ(
-      window_update_3.byte_offset,
-      QuicFlowControllerPeer::SendWindowOffset(stream_->flow_controller()));
+  EXPECT_EQ(window_update_3.max_data, QuicFlowControllerPeer::SendWindowOffset(
+                                          stream_->flow_controller()));
 }
 
 TEST_P(QuicStreamTest, FrameStats) {
diff --git a/quic/core/quic_trace_visitor.cc b/quic/core/quic_trace_visitor.cc
index 99681af..5097485 100644
--- a/quic/core/quic_trace_visitor.cc
+++ b/quic/core/quic_trace_visitor.cc
@@ -171,7 +171,7 @@
 
       quic_trace::FlowControlInfo* info =
           frame_record->mutable_flow_control_info();
-      info->set_max_data(frame.window_update_frame->byte_offset);
+      info->set_max_data(frame.window_update_frame->max_data);
       if (!is_connection) {
         info->set_stream_id(frame.window_update_frame->stream_id);
       }