Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Unified Diff: net/quic/quic_connection.h

Issue 12334063: Land recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more EXPECT_FALSE Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_clock_test.cc ('k') | net/quic/quic_connection.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection.h
diff --git a/net/quic/quic_connection.h b/net/quic/quic_connection.h
index 5e046adc5ec55dadd38e2fa08844fa462f678b97..dd009aec31d61101d3eed839904883629cf1f0c1 100644
--- a/net/quic/quic_connection.h
+++ b/net/quic/quic_connection.h
@@ -17,17 +17,21 @@
#define NET_QUIC_QUIC_CONNECTION_H_
#include <list>
+#include <map>
#include <queue>
#include <set>
#include <vector>
#include "base/hash_tables.h"
#include "net/base/ip_endpoint.h"
+#include "net/base/linked_hash_map.h"
#include "net/quic/congestion_control/quic_congestion_manager.h"
#include "net/quic/quic_blocked_writer_interface.h"
#include "net/quic/quic_fec_group.h"
#include "net/quic/quic_framer.h"
#include "net/quic/quic_packet_creator.h"
+#include "net/quic/quic_packet_entropy_manager.h"
+#include "net/quic/quic_packet_generator.h"
#include "net/quic/quic_protocol.h"
namespace net {
@@ -44,8 +48,6 @@ class QuicConnectionPeer;
class NET_EXPORT_PRIVATE QuicConnectionVisitorInterface {
public:
- typedef std::set<QuicPacketSequenceNumber> AckedPackets;
-
virtual ~QuicConnectionVisitorInterface() {}
// A simple visitor interface for dealing with data frames. The session
@@ -60,12 +62,15 @@ class NET_EXPORT_PRIVATE QuicConnectionVisitorInterface {
// Called when the stream is reset by the peer.
virtual void OnRstStream(const QuicRstStreamFrame& frame) = 0;
+ // Called when the connection is going away according to the peer.
+ virtual void OnGoAway(const QuicGoAwayFrame& frame) = 0;
+
// Called when the connection is closed either locally by the framer, or
// remotely by the peer.
virtual void ConnectionClose(QuicErrorCode error, bool from_peer) = 0;
// Called when packets are acked by the peer.
- virtual void OnAck(AckedPackets acked_packets) = 0;
+ virtual void OnAck(const SequenceNumberSet& acked_packets) = 0;
// Called when a blocked socket becomes writable. If all pending bytes for
// this visitor are consumed by the connection successfully this should
@@ -170,8 +175,10 @@ class NET_EXPORT_PRIVATE QuicConnectionHelperInterface {
virtual void ClearAckAlarm() = 0;
};
-class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
- public QuicBlockedWriterInterface {
+class NET_EXPORT_PRIVATE QuicConnection
+ : public QuicFramerVisitorInterface,
+ public QuicBlockedWriterInterface,
+ public QuicPacketGenerator::DelegateInterface {
public:
// Constructs a new QuicConnection for the specified |guid| and |address|.
// |helper| will be owned by this connection.
@@ -193,8 +200,14 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
bool fin);
// Send a stream reset frame to the peer.
virtual void SendRstStream(QuicStreamId id,
- QuicErrorCode error,
- QuicStreamOffset offset);
+ QuicErrorCode error);
+
+ // Sends the connection close packet without affecting the state of the
+ // connection. This should only be called if the session is actively being
+ // destroyed: otherwise call SendConnectionCloseWithDetails instead.
+ virtual void SendConnectionClosePacket(QuicErrorCode error,
+ const std::string& details);
+
// Sends a connection close frame to the peer, and closes the connection by
// calling CloseConnection(notifying the visitor as it does so).
virtual void SendConnectionClose(QuicErrorCode error);
@@ -202,6 +215,9 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
const std::string& details);
// Notifies the visitor of the close and marks the connection as disconnected.
void CloseConnection(QuicErrorCode error, bool from_peer);
+ virtual void SendGoAway(QuicErrorCode error,
+ QuicStreamId last_good_stream_id,
+ const std::string& reason);
// Processes an incoming UDP packet (consisting of a QuicEncryptedPacket) from
// the peer. If processing this packet permits a packet to be revived from
@@ -228,11 +244,17 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
virtual void OnCongestionFeedbackFrame(
const QuicCongestionFeedbackFrame& frame) OVERRIDE;
virtual void OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE;
+ virtual void OnGoAwayFrame(const QuicGoAwayFrame& frame) OVERRIDE;
virtual void OnConnectionCloseFrame(
const QuicConnectionCloseFrame& frame) OVERRIDE;
virtual void OnFecData(const QuicFecData& fec) OVERRIDE;
virtual void OnPacketComplete() OVERRIDE;
+ // QuicPacketGenerator::DelegateInterface
+ virtual QuicAckFrame* CreateAckFrame() OVERRIDE;
+ virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() OVERRIDE;
+ virtual bool OnSerializedPacket(const SerializedPacket& packet) OVERRIDE;
+
// Accessors
void set_visitor(QuicConnectionVisitorInterface* visitor) {
visitor_ = visitor;
@@ -286,19 +308,22 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
QuicTime OnRetransmissionTimeout();
protected:
- // Serializes then sends or queues the packet currently open.
- void SendOrQueueCurrentPacket();
+ // Deletes all missing packets before least unacked. The connection won't
+ // process any packets with sequence number before |least_unacked| that it
+ // received after this call. Returns true if there were missing packets before
+ // |least_unacked| unacked, false otherwise.
+ bool DontWaitForPacketsBefore(QuicPacketSequenceNumber least_unacked);
// Send a packet to the peer. If |sequence_number| is present in the
// |retransmission_map_|, then contents of this packet will be retransmitted
// with a new sequence number if it's not acked by the peer. Deletes
// |packet| via WritePacket call or transfers ownership to QueuedPacket,
- // ultimately deleted via WritePacket. If |force| is true, then the packet
- // will be sent immediately and the send scheduler will not be consulted.
+ // ultimately deleted via WritePacket. Also, it updates the entropy map
+ // corresponding to |sequence_number| using |entropy_hash|.
// TODO(wtc): none of the callers check the return value.
virtual bool SendOrQueuePacket(QuicPacketSequenceNumber sequence_number,
QuicPacket* packet,
- bool force);
+ QuicPacketEntropyHash entropy_hash);
// Writes the given packet to socket with the help of helper. Returns true on
// successful write, false otherwise. However, behavior is undefined if
@@ -324,15 +349,6 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
// Updates internal state based in incoming_ack.sent_info
void UpdatePacketInformationSentByPeer(const QuicAckFrame& incoming_ack);
- // Utility which sets SetLeastUnacked to least_unacked, and updates the list
- // of non-retransmitting packets accordingly.
- void SetLeastUnacked(QuicPacketSequenceNumber least_unacked);
-
- // Helper to update least unacked. If acked_sequence_number was not the least
- // unacked packet, this is a no-op. If it was the least unacked packet,
- // this finds the new least unacked packet and updates the outgoing ack frame.
- void UpdateLeastUnacked(QuicPacketSequenceNumber acked_sequence_number);
-
QuicConnectionHelperInterface* helper() { return helper_; }
private:
@@ -351,16 +367,6 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
QuicPacket* packet;
};
- struct UnackedPacket {
- explicit UnackedPacket(QuicFrames unacked_frames);
- UnackedPacket(QuicFrames unacked_frames, std::string data);
- ~UnackedPacket();
-
- QuicFrames frames;
- // Data referenced by the StringPiece of a QuicStreamFrame.
- std::string data;
- };
-
struct RetransmissionInfo {
explicit RetransmissionInfo(QuicPacketSequenceNumber sequence_number)
: sequence_number(sequence_number),
@@ -386,8 +392,8 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
};
typedef std::list<QueuedPacket> QueuedPacketList;
- typedef base::hash_map<QuicPacketSequenceNumber,
- UnackedPacket*> UnackedPacketMap;
+ typedef linked_hash_map<QuicPacketSequenceNumber,
+ RetransmittableFrames*> UnackedPacketMap;
typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap;
typedef base::hash_map<QuicPacketSequenceNumber,
RetransmissionInfo> RetransmissionMap;
@@ -396,24 +402,22 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
RetransmissionInfoComparator>
RetransmissionTimeouts;
- static void DeleteEnclosedFrames(UnackedPacket* unacked);
-
// Checks if a packet can be written now, and sets the timer if necessary.
- bool CanWrite(bool is_retransmission);
+ virtual bool CanWrite(bool is_retransmission) OVERRIDE;
void MaybeSetupRetransmission(QuicPacketSequenceNumber sequence_number);
bool IsRetransmission(QuicPacketSequenceNumber sequence_number);
- // Writes as much queued data as possible. The connection must not be
- // blocked when this is called. Will leave queued frames in the PacketCreator
- // if the queued data was not enough to fill a packet and |force_send| is
- // false.
- bool WriteQueuedData(bool flush);
+ // Writes as many queued packets as possible. The connection must not be
+ // blocked when this is called.
+ bool WriteQueuedPackets();
// If a packet can be revived from the current FEC group, then
// revive and process the packet.
void MaybeProcessRevivedPacket();
+ void UpdateOutgoingAck();
+
void MaybeSendAckInResponseToPacket();
// Get the FEC group associate with the last processed packet.
@@ -442,14 +446,19 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
QuicPacketHeader last_header_;
std::vector<QuicStreamFrame> last_stream_frames_;
- bool should_send_ack_;
- bool should_send_congestion_feedback_;
QuicAckFrame outgoing_ack_;
QuicCongestionFeedbackFrame outgoing_congestion_feedback_;
- // Track some client state so we can do less bookkeeping
+ // Track some peer state so we can do less bookkeeping
+ // Largest sequence sent by the peer which had an ack frame (latest ack info).
QuicPacketSequenceNumber largest_seen_packet_with_ack_;
+ // Largest sequence number that the peer has observed. Mostly received,
+ // missing in case of truncated acks.
QuicPacketSequenceNumber peer_largest_observed_packet_;
+ // Least sequence number which the peer is still waiting for.
+ QuicPacketSequenceNumber least_packet_awaited_by_peer_;
+ // Least sequence number of the the packet sent by the peer for which it
+ // hasn't received an ack.
QuicPacketSequenceNumber peer_least_packet_awaiting_ack_;
// When new packets are created which may be retransmitted, they are added
@@ -476,22 +485,26 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface,
// unacked_packets_ if they are to be retransmitted.
QueuedPacketList queued_packets_;
- // Pending control frames, besides the ack and congestion control frames.
- QuicFrames queued_control_frames_;
-
// True when the socket becomes unwritable.
bool write_blocked_;
FecGroupMap group_map_;
+ QuicPacketEntropyManager entropy_manager_;
+
QuicConnectionVisitorInterface* visitor_;
QuicConnectionDebugVisitorInterface* debug_visitor_;
QuicPacketCreator packet_creator_;
+ QuicPacketGenerator packet_generator_;
// Network idle time before we kill of this connection.
const QuicTime::Delta timeout_;
- // The time that we got or tried to send a packet for this connection.
- QuicTime time_of_last_packet_;
+
+ // The time that we got a packet for this connection.
+ QuicTime time_of_last_received_packet_;
+
+ // The time that we last sent a packet for this connection.
+ QuicTime time_of_last_sent_packet_;
// Congestion manager which controls the rate the connection sends packets
// as well as collecting and generating congestion feedback.
« no previous file with comments | « net/quic/quic_clock_test.cc ('k') | net/quic/quic_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698