OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_QUIC_QUIC_SENT_PACKET_MANAGER_INTERFACE_H_ | |
6 #define NET_QUIC_QUIC_SENT_PACKET_MANAGER_INTERFACE_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "net/quic/quic_protocol.h" | |
10 #include "net/quic/quic_sustained_bandwidth_recorder.h" | |
11 | |
12 namespace net { | |
13 | |
14 class QuicConfig; | |
15 class RttStats; | |
16 | |
17 class NET_EXPORT_PRIVATE QuicSentPacketManagerInterface { | |
18 public: | |
19 // Interface which gets callbacks from the QuicSentPacketManager at | |
20 // interesting points. Implementations must not mutate the state of | |
21 // the packet manager or connection as a result of these callbacks. | |
22 class NET_EXPORT_PRIVATE DebugDelegate { | |
23 public: | |
24 virtual ~DebugDelegate() {} | |
25 | |
26 // Called when a spurious retransmission is detected. | |
27 virtual void OnSpuriousPacketRetransmission( | |
28 TransmissionType transmission_type, | |
29 QuicByteCount byte_size) {} | |
30 | |
31 virtual void OnIncomingAck(const QuicAckFrame& ack_frame, | |
32 QuicTime ack_receive_time, | |
33 QuicPacketNumber largest_observed, | |
34 bool rtt_updated, | |
35 QuicPacketNumber least_unacked_sent_packet) {} | |
36 | |
37 virtual void OnPacketLoss(QuicPacketNumber lost_packet_number, | |
38 TransmissionType transmission_type, | |
39 QuicTime detection_time) {} | |
40 }; | |
41 | |
42 // Interface which gets callbacks from the QuicSentPacketManager when | |
43 // network-related state changes. Implementations must not mutate the | |
44 // state of the packet manager as a result of these callbacks. | |
45 class NET_EXPORT_PRIVATE NetworkChangeVisitor { | |
46 public: | |
47 virtual ~NetworkChangeVisitor() {} | |
48 | |
49 // Called when congestion window or RTT may have changed. | |
50 virtual void OnCongestionChange() = 0; | |
51 | |
52 // Called with the path may be degrading. Note that the path may only be | |
53 // temporarily degrading. | |
54 // TODO(jri): With multipath, this method should probably have a path_id | |
55 // parameter, and should maybe result in the path being marked as inactive. | |
56 virtual void OnPathDegrading() = 0; | |
57 | |
58 // Called when the Path MTU may have increased. | |
59 virtual void OnPathMtuIncreased(QuicPacketLength packet_size) = 0; | |
60 }; | |
61 | |
62 virtual ~QuicSentPacketManagerInterface() {} | |
63 | |
64 virtual void SetFromConfig(const QuicConfig& config) = 0; | |
65 | |
66 // Resumes connection state on the default path. | |
67 virtual void ResumeConnectionState( | |
68 const CachedNetworkParameters& cached_network_params, | |
69 bool max_bandwidth_resumption) = 0; | |
70 | |
71 // Sets number of active streams of all paths. | |
72 virtual void SetNumOpenStreams(size_t num_streams) = 0; | |
73 | |
74 // Sets max pacing rate of the default path. | |
75 virtual void SetMaxPacingRate(QuicBandwidth max_pacing_rate) = 0; | |
76 | |
77 // Indicates the handshake has completed, so no handshake packets need to be | |
78 // retransmitted. | |
79 virtual void SetHandshakeConfirmed() = 0; | |
80 | |
81 virtual void OnIncomingAck(const QuicAckFrame& ack_frame, | |
82 QuicTime ack_receive_time) = 0; | |
83 | |
84 // Requests retransmission of all unacked packets of |retransmission_type| on | |
85 // the default path. | |
86 virtual void RetransmitUnackedPackets( | |
87 TransmissionType retransmission_type) = 0; | |
88 | |
89 // Retransmits the oldest pending packet on the path (on which retransmission | |
90 // alarm fires) if there is still a tail loss probe pending. Invoked after | |
91 // OnRetransmissionTimeout. | |
92 virtual bool MaybeRetransmitTailLossProbe() = 0; | |
93 | |
94 // Removes the retransmittable frames from all unencrypted packets on the | |
95 // default path to ensure they don't get retransmitted. | |
96 virtual void NeuterUnencryptedPackets() = 0; | |
97 | |
98 virtual bool HasPendingRetransmissions() const = 0; | |
99 | |
100 virtual PendingRetransmission NextPendingRetransmission() = 0; | |
101 | |
102 // Returns true if the default path has unacked packets. | |
103 virtual bool HasUnackedPackets() const = 0; | |
104 | |
105 virtual QuicPacketNumber GetLeastUnacked(QuicPathId path_id) const = 0; | |
106 | |
107 virtual bool OnPacketSent( | |
108 SerializedPacket* serialized_packet, | |
109 QuicPathId original_path_id, | |
110 QuicPacketNumber original_packet_number, | |
111 QuicTime sent_time, | |
112 TransmissionType transmission_type, | |
113 HasRetransmittableData has_retransmittable_data) = 0; | |
114 | |
115 virtual void OnRetransmissionTimeout() = 0; | |
116 | |
117 // Returns the earliest time we can send the next packet. Sets |path_id| to be | |
118 // the path on which the next packet will be sent. | |
119 virtual QuicTime::Delta TimeUntilSend(QuicTime now, | |
120 HasRetransmittableData retransmittable, | |
121 QuicPathId* path_id) = 0; | |
122 | |
123 // Returns the earliest retransmission time of all paths. | |
124 // TODO(fayang): This method should not be const becasue the return value | |
125 // depends upon the time it is invoked. | |
126 virtual const QuicTime GetRetransmissionTime() const = 0; | |
127 | |
128 // Returns the rtt stats of the default path. | |
129 virtual const RttStats* GetRttStats() const = 0; | |
130 | |
131 // Returns the estimated bandwidth on default path calculated by the | |
132 // congestion algorithm. | |
133 virtual QuicBandwidth BandwidthEstimate() const = 0; | |
134 | |
135 // Returns the sustained bandwidth recorder on the default path. | |
136 virtual const QuicSustainedBandwidthRecorder* SustainedBandwidthRecorder() | |
137 const = 0; | |
138 | |
139 // Returns the size of the current congestion window on default path in number | |
140 // of kDefaultTCPMSS-sized segments. | |
141 virtual QuicPacketCount GetCongestionWindowInTcpMss() const = 0; | |
142 | |
143 // Determines the number of packets of length |max_packet_length| which fit in | |
144 // the congestion windows for all paths, and returns the max number of packets | |
145 // across all paths. | |
146 virtual QuicPacketCount EstimateMaxPacketsInFlight( | |
147 QuicByteCount max_packet_length) const = 0; | |
148 | |
149 // Returns the size of the current congestion window size on the default path | |
150 // in bytes. | |
151 virtual QuicByteCount GetCongestionWindowInBytes() const = 0; | |
152 | |
153 // Returns the size of the slow start congestion window in number of 1460 byte | |
154 // TCP segments on the default path. | |
155 virtual QuicPacketCount GetSlowStartThresholdInTcpMss() const = 0; | |
156 | |
157 // No longer retransmit data for |stream_id| on all paths. | |
158 virtual void CancelRetransmissionsForStream(QuicStreamId stream_id) = 0; | |
159 | |
160 // Called when peer address changes and the connection migrates on |path_id|. | |
161 // TODO(fayang): Name of this method is confusing in multipath world because | |
162 // this migration is path level. Need to rename this as OnPeerMigration. | |
163 virtual void OnConnectionMigration(QuicPathId path_id, | |
164 PeerAddressChangeType type) = 0; | |
165 | |
166 virtual bool IsHandshakeConfirmed() const = 0; | |
167 | |
168 virtual void SetDebugDelegate(DebugDelegate* debug_delegate) = 0; | |
169 | |
170 virtual QuicPacketNumber GetLargestObserved(QuicPathId path_id) const = 0; | |
171 | |
172 virtual QuicPacketNumber GetLargestSentPacket(QuicPathId path_id) const = 0; | |
173 | |
174 virtual QuicPacketNumber GetLeastPacketAwaitedByPeer( | |
175 QuicPathId path_id) const = 0; | |
176 | |
177 virtual void SetNetworkChangeVisitor(NetworkChangeVisitor* visitor) = 0; | |
178 | |
179 // Returns true if the default path is in slow start. | |
180 virtual bool InSlowStart() const = 0; | |
181 | |
182 // These two methods return the consecutive RTO or TLP count of the default | |
183 // path. | |
184 virtual size_t GetConsecutiveRtoCount() const = 0; | |
185 virtual size_t GetConsecutiveTlpCount() const = 0; | |
186 }; | |
187 | |
188 } // namespace net | |
189 | |
190 #endif // NET_QUIC_QUIC_SENT_PACKET_MANAGER_INTERFACE_H_ | |
OLD | NEW |