Land recent QUIC changes.

Reviving entropy flag of missing packet.

Merge internal change: 42912121

Fix bug in QuicConnection::OnCanWrite in which the packet generator never flushed the packets when the visitor did not write all bytes.

Merge internal change: 42919513

Clarify the SendAlarm behavior of the TestHelper in QuicConnectionTests. In particular, it is important that if we set a send alarm for a delay of Zero, that IsSendAlarmSet() returns true.

Merge internal change: 42908913

Fix bug in SimpleQuicFramerVisitor which did not make a copy of StreamFrame data.

Merge internal change: 42880797

Use the QuicPacketGenerator in QuicConnection.

Merge internal change: 42861764

Add new files


Create a new QuicPacketGenerator class to encapsulate the write side operation of a QuicConnection.  It provides methods for enqueing control frames, consuming stream data, and sending acks and feedback.  It does just-in-time serialization.

Also adds a new test-only simple framer which provides an easy
mechanism for parsing packets to verify they contain correct
contents.

Merge internal change: 42813986

Add missing files


Implementing logic for checking entropy of received packets and setting entropy on outgoing packets.

Merge internal change: 42715914

Fixing a bug where when QuicPacketCreator queues a stream frame, the underlying string is not immediately owned, which can cause issues if SendStreamData doesn't always flush packets before exiting.

Merge internal change: 42649091

Add the SetKey, SetNoncePrefix, GetKeySize, and GetNoncePrefixSize methods to the QuicEncrypter and QuicDecrypter interfaces. Specify the format of the nonce for AEAD algorithms.

Add a |packet_sequence_number| argument to QuicEncrypter::Encrypt
and QuicDecrypter::Decrypt. This requires passing the packet
sequence number to QuicFramer::EncryptPacket and
QuicFramer::DecryptPayload.

Merge internal change: 42641062

Move all logic out of ReceivedInfo. Now it is just a plain struct that is used to represent the state of the received packets info.

Also, fixes the following bug:

i) Packet 7 8 get lost, largest observed packet is 6.
ii) Packet 9 arrives with an AckFrame which has least unacked as 9.
iii) We clear 7 8 from missing packets.
iv) While adding packet 9 we reinsert 7 and 8 as missing packets since largest observed is 6.

Merge internal change: 42556974

Make framer return SerializedPacket instead of QuicPacket.

Merge internal change: 42551314

Add SendConnectionClosePacket method to QuicConnection

Merge internal change: 42474257

Removing offset from the reset stream frame.

Merge internal change: 42436913

Fix for when the end of a frame leave too few bytes for the next header

Merge internal change: 42435044

Bug fix for packet loss in inter arrival. Added min drift threshold for inter arrival.

Merge internal change: 42391696

Add missing file.


Use linked_hash_map to store UnackedPackets: simplifies and optimizes the code.

Merge internal change: 42381785

Bugfix "Flaky tests due to QuicTime not initialized"

Removed DCHECK that due to timing was invalid

Merge internal change: 42374053

Fix TSAN test failure.

Merge internal change: 42371302

A simple tcp tail drop like implementation.

Merge internal change: 42314912

Adding the GoAway Frame.

Merge internal change: 42291652

Chromium review fixes.

Merge internal change: 42290161

Implement framing for entropy in AckFrame.

Merge internal change: 42286308

Make QuicPacketCreator return SerializedPacket struct.

Merge internal change: 42240179

Fix for incoming duplicate packet. Avoids NACKing a duplicate.

Merge internal change: 42150291

Remove QuicConnectionVisitorInterface::AckedPackets and use the existing SequenceSet typedef instead.  Renamed SequenceSet to SequenceNumberSet to be more readable.

Merge internal change: 42147690

Made ramp up bitrate in inter arrival aware of the current send rate.

Merge internal change: 42118607

Style fix of full_packet.

Merge internal change: 42057032

Packing multiple streams together in a single packet from OnCanWrite.

Merge internal change: 42054845

Change the representation of public and private flags to explicts bools. Using enums turns out to be problematic because ENUM1 | ENUM2 can not be assigned to EnumType.  I discovered this problem in attempting to implement version negotiation.

Merge internal change: 42042022

Various small QUIC cleanups after merging to Chrome.

Merge internal change: 42041347

Start using QuicClock Now where needed and sending it around instead of querying it multiple times. This CL also fixes the reports of incoming lost packets which had been lost.

Merge internal change: 41944659

Fix mock clock.


Adding Now function back to QuicClock but now as a more accurate now

Merge internal change: 41909929

Rename of function Now to ApproximateNow to allow us to differentiate between the two in the future.

Merge internal change: 41909178

[email protected]
[email protected]
BUG=


Review URL: https://chromiumcodereview.appspot.com/12334063

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184374 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/quic/quic_session.cc b/net/quic/quic_session.cc
index ef0efbe3..dfcea32d 100644
--- a/net/quic/quic_session.cc
+++ b/net/quic/quic_session.cc
@@ -39,7 +39,12 @@
     session_->PostProcessAfterData();
   }
 
-  virtual void OnAck(AckedPackets acked_packets) OVERRIDE {
+  virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE {
+    session_->OnGoAway(frame);
+    session_->PostProcessAfterData();
+  }
+
+  virtual void OnAck(const SequenceNumberSet& acked_packets) OVERRIDE {
     session_->OnAck(acked_packets);
     session_->PostProcessAfterData();
   }
@@ -65,7 +70,9 @@
       max_open_streams_(kDefaultMaxStreamsPerConnection),
       next_stream_id_(is_server ? 2 : 3),
       is_server_(is_server),
-      largest_peer_created_stream_id_(0) {
+      largest_peer_created_stream_id_(0),
+      goaway_received_(false),
+      goaway_sent_(false) {
   connection->set_visitor(visitor_shim_.get());
 }
 
@@ -109,7 +116,12 @@
   if (!stream) {
     return;  // Errors are handled by GetStream.
   }
-  stream->OnStreamReset(frame.error_code, frame.offset);
+  stream->OnStreamReset(frame.error_code);
+}
+
+void QuicSession::OnGoAway(const QuicGoAwayFrame& frame) {
+  DCHECK(frame.last_good_stream_id < next_stream_id_);
+  goaway_received_ = true;
 }
 
 void QuicSession::ConnectionClose(QuicErrorCode error, bool from_peer) {
@@ -150,18 +162,20 @@
                                         StringPiece data,
                                         QuicStreamOffset offset,
                                         bool fin) {
-  // TODO(wtc): type mismatch -- connection_->SendStreamData() returns a
-  // size_t.
   return connection_->SendStreamData(id, data, offset, fin);
 }
 
 void QuicSession::SendRstStream(QuicStreamId id,
-                                QuicErrorCode error,
-                                QuicStreamOffset offset) {
-  connection_->SendRstStream(id, error, offset);
+                                QuicErrorCode error) {
+  connection_->SendRstStream(id, error);
   CloseStream(id);
 }
 
+void QuicSession::SendGoAway(QuicErrorCode error_code, const string& reason) {
+  goaway_sent_ = true;
+  connection_->SendGoAway(error_code, largest_peer_created_stream_id_, reason);
+}
+
 void QuicSession::CloseStream(QuicStreamId stream_id) {
   DLOG(INFO) << "Closing stream " << stream_id;
 
@@ -226,6 +240,12 @@
     return NULL;
   }
 
+  if (goaway_sent_) {
+    // We've already sent a GoAway
+    connection()->SendRstStream(stream_id, QUIC_PEER_GOING_AWAY);
+    return NULL;
+  }
+
   implicitly_created_streams_.erase(stream_id);
   if (stream_id > largest_peer_created_stream_id_) {
     // TODO(rch) add unit test for this