OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Responsible for generating packets on behalf of a QuicConnection. | 5 // Responsible for generating packets on behalf of a QuicConnection. |
6 // Packets are serialized just-in-time. Control frames are queued. | 6 // Packets are serialized just-in-time. Control frames are queued. |
7 // Ack and Feedback frames will be requested from the Connection | 7 // Ack and Feedback frames will be requested from the Connection |
8 // just-in-time. When a packet needs to be sent, the Generator | 8 // just-in-time. When a packet needs to be sent, the Generator |
9 // will serialize a packet and pass it to QuicConnection::SendOrQueuePacket() | 9 // will serialize a packet and pass it to QuicConnection::SendOrQueuePacket() |
10 // | 10 // |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 class NET_EXPORT_PRIVATE QuicPacketGenerator { | 62 class NET_EXPORT_PRIVATE QuicPacketGenerator { |
63 public: | 63 public: |
64 class NET_EXPORT_PRIVATE DelegateInterface { | 64 class NET_EXPORT_PRIVATE DelegateInterface { |
65 public: | 65 public: |
66 virtual ~DelegateInterface() {} | 66 virtual ~DelegateInterface() {} |
67 virtual bool ShouldGeneratePacket(TransmissionType transmission_type, | 67 virtual bool ShouldGeneratePacket(TransmissionType transmission_type, |
68 HasRetransmittableData retransmittable, | 68 HasRetransmittableData retransmittable, |
69 IsHandshake handshake) = 0; | 69 IsHandshake handshake) = 0; |
70 virtual QuicAckFrame* CreateAckFrame() = 0; | 70 virtual QuicAckFrame* CreateAckFrame() = 0; |
71 virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() = 0; | 71 virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() = 0; |
| 72 virtual QuicStopWaitingFrame* CreateStopWaitingFrame() = 0; |
72 // Takes ownership of |packet.packet| and |packet.retransmittable_frames|. | 73 // Takes ownership of |packet.packet| and |packet.retransmittable_frames|. |
73 virtual bool OnSerializedPacket(const SerializedPacket& packet) = 0; | 74 virtual bool OnSerializedPacket(const SerializedPacket& packet) = 0; |
74 virtual void CloseConnection(QuicErrorCode error, bool from_peer) = 0; | 75 virtual void CloseConnection(QuicErrorCode error, bool from_peer) = 0; |
75 }; | 76 }; |
76 | 77 |
77 // Interface which gets callbacks from the QuicPacketGenerator at interesting | 78 // Interface which gets callbacks from the QuicPacketGenerator at interesting |
78 // points. Implementations must not mutate the state of the generator | 79 // points. Implementations must not mutate the state of the generator |
79 // as a result of these callbacks. | 80 // as a result of these callbacks. |
80 class NET_EXPORT_PRIVATE DebugDelegateInterface { | 81 class NET_EXPORT_PRIVATE DebugDelegateInterface { |
81 public: | 82 public: |
82 virtual ~DebugDelegateInterface() {} | 83 virtual ~DebugDelegateInterface() {} |
83 | 84 |
84 // Called when a frame has been added to the current packet. | 85 // Called when a frame has been added to the current packet. |
85 virtual void OnFrameAddedToPacket(const QuicFrame& frame) = 0; | 86 virtual void OnFrameAddedToPacket(const QuicFrame& frame) = 0; |
86 }; | 87 }; |
87 | 88 |
88 QuicPacketGenerator(DelegateInterface* delegate, | 89 QuicPacketGenerator(DelegateInterface* delegate, |
89 DebugDelegateInterface* debug_delegate, | 90 DebugDelegateInterface* debug_delegate, |
90 QuicPacketCreator* creator); | 91 QuicPacketCreator* creator); |
91 | 92 |
92 virtual ~QuicPacketGenerator(); | 93 virtual ~QuicPacketGenerator(); |
93 | 94 |
94 // Indicates that an ACK frame should be sent. If |also_send_feedback| is | 95 // Indicates that an ACK frame should be sent. If |also_send_feedback| is |
95 // true, then it also indicates a CONGESTION_FEEDBACK frame should be sent. | 96 // true, then it also indicates a CONGESTION_FEEDBACK frame should be sent. |
| 97 // If |also_send_stop_waiting| is true, then it also indicates that a |
| 98 // STOP_WAITING frame should be sent as well. |
96 // The contents of the frame(s) will be generated via a call to the delegates | 99 // The contents of the frame(s) will be generated via a call to the delegates |
97 // CreateAckFrame() and CreateFeedbackFrame() when the packet is serialized. | 100 // CreateAckFrame() and CreateFeedbackFrame() when the packet is serialized. |
98 void SetShouldSendAck(bool also_send_feedback); | 101 void SetShouldSendAck(bool also_send_feedback, |
| 102 bool also_send_stop_waiting); |
| 103 |
| 104 // Indicates that a STOP_WAITING frame should be sent. |
| 105 void SetShouldSendStopWaiting(); |
| 106 |
99 void AddControlFrame(const QuicFrame& frame); | 107 void AddControlFrame(const QuicFrame& frame); |
100 | 108 |
101 // Given some data, may consume part or all of it and pass it to the | 109 // Given some data, may consume part or all of it and pass it to the |
102 // packet creator to be serialized into packets. If not in batch | 110 // packet creator to be serialized into packets. If not in batch |
103 // mode, these packets will also be sent during this call. Also | 111 // mode, these packets will also be sent during this call. Also |
104 // attaches a QuicAckNotifier to any created stream frames, which | 112 // attaches a QuicAckNotifier to any created stream frames, which |
105 // will be called once the frame is ACKed by the peer. The | 113 // will be called once the frame is ACKed by the peer. The |
106 // QuicAckNotifier is owned by the QuicConnection. |notifier| may | 114 // QuicAckNotifier is owned by the QuicConnection. |notifier| may |
107 // be NULL. | 115 // be NULL. |
108 QuicConsumedData ConsumeData(QuicStreamId id, | 116 QuicConsumedData ConsumeData(QuicStreamId id, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 156 |
149 QuicPacketCreator* packet_creator_; | 157 QuicPacketCreator* packet_creator_; |
150 QuicFrames queued_control_frames_; | 158 QuicFrames queued_control_frames_; |
151 | 159 |
152 // True if batch mode is currently enabled. | 160 // True if batch mode is currently enabled. |
153 bool batch_mode_; | 161 bool batch_mode_; |
154 | 162 |
155 // Flags to indicate the need for just-in-time construction of a frame. | 163 // Flags to indicate the need for just-in-time construction of a frame. |
156 bool should_send_ack_; | 164 bool should_send_ack_; |
157 bool should_send_feedback_; | 165 bool should_send_feedback_; |
| 166 bool should_send_stop_waiting_; |
158 // If we put a non-retransmittable frame (namley ack or feedback frame) in | 167 // If we put a non-retransmittable frame (namley ack or feedback frame) in |
159 // this packet, then we have to hold a reference to it until we flush (and | 168 // this packet, then we have to hold a reference to it until we flush (and |
160 // serialize it). Retransmittable frames are referenced elsewhere so that they | 169 // serialize it). Retransmittable frames are referenced elsewhere so that they |
161 // can later be (optionally) retransmitted. | 170 // can later be (optionally) retransmitted. |
162 scoped_ptr<QuicAckFrame> pending_ack_frame_; | 171 scoped_ptr<QuicAckFrame> pending_ack_frame_; |
163 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; | 172 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; |
| 173 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_; |
164 | 174 |
165 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); | 175 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); |
166 }; | 176 }; |
167 | 177 |
168 } // namespace net | 178 } // namespace net |
169 | 179 |
170 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ | 180 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ |
OLD | NEW |