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

Side by Side Diff: net/quic/quic_session.h

Issue 1660533002: Landing Recent QUIC changes until 01/26/2016 18:14 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_sent_packet_manager_test.cc ('k') | net/quic/quic_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // A QuicSession, which demuxes a single connection to individual streams. 5 // A QuicSession, which demuxes a single connection to individual streams.
6 6
7 #ifndef NET_QUIC_QUIC_SESSION_H_ 7 #ifndef NET_QUIC_QUIC_SESSION_H_
8 #define NET_QUIC_QUIC_SESSION_H_ 8 #define NET_QUIC_QUIC_SESSION_H_
9 9
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 13 matching lines...) Expand all
24 #include "net/quic/quic_packet_creator.h" 24 #include "net/quic/quic_packet_creator.h"
25 #include "net/quic/quic_protocol.h" 25 #include "net/quic/quic_protocol.h"
26 #include "net/quic/quic_write_blocked_list.h" 26 #include "net/quic/quic_write_blocked_list.h"
27 #include "net/quic/reliable_quic_stream.h" 27 #include "net/quic/reliable_quic_stream.h"
28 28
29 namespace net { 29 namespace net {
30 30
31 class QuicCryptoStream; 31 class QuicCryptoStream;
32 class QuicFlowController; 32 class QuicFlowController;
33 class ReliableQuicStream; 33 class ReliableQuicStream;
34 class VisitorShim;
35 34
36 namespace test { 35 namespace test {
37 class QuicSessionPeer; 36 class QuicSessionPeer;
38 } // namespace test 37 } // namespace test
39 38
40 class NET_EXPORT_PRIVATE QuicSession : public QuicConnectionVisitorInterface { 39 class NET_EXPORT_PRIVATE QuicSession : public QuicConnectionVisitorInterface {
41 public: 40 public:
42 // CryptoHandshakeEvent enumerates the events generated by a QuicCryptoStream. 41 // CryptoHandshakeEvent enumerates the events generated by a QuicCryptoStream.
43 enum CryptoHandshakeEvent { 42 enum CryptoHandshakeEvent {
44 // ENCRYPTION_FIRST_ESTABLISHED indicates that a full client hello has been 43 // ENCRYPTION_FIRST_ESTABLISHED indicates that a full client hello has been
(...skipping 23 matching lines...) Expand all
68 void OnRstStream(const QuicRstStreamFrame& frame) override; 67 void OnRstStream(const QuicRstStreamFrame& frame) override;
69 void OnGoAway(const QuicGoAwayFrame& frame) override; 68 void OnGoAway(const QuicGoAwayFrame& frame) override;
70 void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; 69 void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override;
71 void OnBlockedFrame(const QuicBlockedFrame& frame) override; 70 void OnBlockedFrame(const QuicBlockedFrame& frame) override;
72 void OnConnectionClosed(QuicErrorCode error, bool from_peer) override; 71 void OnConnectionClosed(QuicErrorCode error, bool from_peer) override;
73 void OnWriteBlocked() override {} 72 void OnWriteBlocked() override {}
74 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override; 73 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override;
75 void OnCanWrite() override; 74 void OnCanWrite() override;
76 void OnCongestionWindowChange(QuicTime /*now*/) override {} 75 void OnCongestionWindowChange(QuicTime /*now*/) override {}
77 void OnConnectionMigration() override {} 76 void OnConnectionMigration() override {}
77 // Deletes streams that are safe to be deleted now that it's safe to do so (no
78 // other operations are being done on the streams at this time).
79 void PostProcessAfterData() override;
78 bool WillingAndAbleToWrite() const override; 80 bool WillingAndAbleToWrite() const override;
79 bool HasPendingHandshake() const override; 81 bool HasPendingHandshake() const override;
80 bool HasOpenDynamicStreams() const override; 82 bool HasOpenDynamicStreams() const override;
81 83
82 // Called on every incoming packet. Passes |packet| through to |connection_|. 84 // Called on every incoming packet. Passes |packet| through to |connection_|.
83 virtual void ProcessUdpPacket(const IPEndPoint& self_address, 85 virtual void ProcessUdpPacket(const IPEndPoint& self_address,
84 const IPEndPoint& peer_address, 86 const IPEndPoint& peer_address,
85 const QuicEncryptedPacket& packet); 87 const QuicEncryptedPacket& packet);
86 88
87 // Called by streams when they want to write data to the peer. 89 // Called by streams when they want to write data to the peer.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 Perspective perspective() const { return connection_->perspective(); } 196 Perspective perspective() const { return connection_->perspective(); }
195 197
196 QuicFlowController* flow_controller() { return &flow_controller_; } 198 QuicFlowController* flow_controller() { return &flow_controller_; }
197 199
198 // Returns true if connection is flow controller blocked. 200 // Returns true if connection is flow controller blocked.
199 bool IsConnectionFlowControlBlocked() const; 201 bool IsConnectionFlowControlBlocked() const;
200 202
201 // Returns true if any stream is flow controller blocked. 203 // Returns true if any stream is flow controller blocked.
202 bool IsStreamFlowControlBlocked(); 204 bool IsStreamFlowControlBlocked();
203 205
204 size_t get_max_open_streams() const { return max_open_streams_; } 206 size_t max_open_incoming_streams() const {
207 return max_open_incoming_streams_;
208 }
205 209
206 size_t get_max_available_streams() const { 210 size_t max_open_outgoing_streams() const {
207 return max_open_streams_ * kMaxAvailableStreamsMultiplier; 211 return max_open_outgoing_streams_;
208 } 212 }
209 213
214 size_t MaxAvailableStreams() const;
215
210 ReliableQuicStream* GetStream(const QuicStreamId stream_id); 216 ReliableQuicStream* GetStream(const QuicStreamId stream_id);
211 217
212 // Mark a stream as draining. 218 // Mark a stream as draining.
213 virtual void StreamDraining(QuicStreamId id); 219 virtual void StreamDraining(QuicStreamId id);
214 220
215 // Close the connection, if it is not already closed. 221 // Close the connection, if it is not already closed.
216 void CloseConnectionWithDetails(QuicErrorCode error, const char* details); 222 void CloseConnectionWithDetails(QuicErrorCode error, const char* details);
217 223
218 // Returns true if this stream should yield writes to another blocked stream. 224 // Returns true if this stream should yield writes to another blocked stream.
219 bool ShouldYield(QuicStreamId stream_id); 225 bool ShouldYield(QuicStreamId stream_id);
(...skipping 21 matching lines...) Expand all
241 // Returns the stream ID for a new outgoing stream, and increments the 247 // Returns the stream ID for a new outgoing stream, and increments the
242 // underlying counter. 248 // underlying counter.
243 QuicStreamId GetNextOutgoingStreamId(); 249 QuicStreamId GetNextOutgoingStreamId();
244 250
245 // Returns existing stream with id = |stream_id|. If no such stream exists, 251 // Returns existing stream with id = |stream_id|. If no such stream exists,
246 // and |stream_id| is a peer-created id, then a new stream is created and 252 // and |stream_id| is a peer-created id, then a new stream is created and
247 // returned. However if |stream_id| is a locally-created id and no such stream 253 // returned. However if |stream_id| is a locally-created id and no such stream
248 // exists, the connection is closed. 254 // exists, the connection is closed.
249 ReliableQuicStream* GetOrCreateDynamicStream(QuicStreamId stream_id); 255 ReliableQuicStream* GetOrCreateDynamicStream(QuicStreamId stream_id);
250 256
251 // This is called after every call other than OnConnectionClose from the
252 // QuicConnectionVisitor to allow post-processing once the work has been done.
253 // In this case, it deletes streams given that it's safe to do so (no other
254 // operations are being done on the streams at this time)
255 virtual void PostProcessAfterData();
256
257 // Performs the work required to close |stream_id|. If |locally_reset| 257 // Performs the work required to close |stream_id|. If |locally_reset|
258 // then the stream has been reset by this endpoint, not by the peer. 258 // then the stream has been reset by this endpoint, not by the peer.
259 virtual void CloseStreamInner(QuicStreamId stream_id, bool locally_reset); 259 virtual void CloseStreamInner(QuicStreamId stream_id, bool locally_reset);
260 260
261 // When a stream is closed locally, it may not yet know how many bytes the 261 // When a stream is closed locally, it may not yet know how many bytes the
262 // peer sent on that stream. 262 // peer sent on that stream.
263 // When this data arrives (via stream frame w. FIN, or RST) this method 263 // When this data arrives (via stream frame w. FIN, or RST) this method
264 // is called, and correctly updates the connection level flow controller. 264 // is called, and correctly updates the connection level flow controller.
265 void UpdateFlowControlOnFinalReceivedByteOffset( 265 void UpdateFlowControlOnFinalReceivedByteOffset(
266 QuicStreamId id, 266 QuicStreamId id,
267 QuicStreamOffset final_byte_offset); 267 QuicStreamOffset final_byte_offset);
268 268
269 // Return true if given stream is peer initiated. 269 // Return true if given stream is peer initiated.
270 bool IsIncomingStream(QuicStreamId id) const; 270 bool IsIncomingStream(QuicStreamId id) const;
271 271
272 StreamMap& static_streams() { return static_stream_map_; } 272 StreamMap& static_streams() { return static_stream_map_; }
273 const StreamMap& static_streams() const { return static_stream_map_; } 273 const StreamMap& static_streams() const { return static_stream_map_; }
274 274
275 StreamMap& dynamic_streams() { return dynamic_stream_map_; } 275 StreamMap& dynamic_streams() { return dynamic_stream_map_; }
276 const StreamMap& dynamic_streams() const { return dynamic_stream_map_; } 276 const StreamMap& dynamic_streams() const { return dynamic_stream_map_; }
277 277
278 std::vector<ReliableQuicStream*>* closed_streams() { 278 std::vector<ReliableQuicStream*>* closed_streams() {
279 return &closed_streams_; 279 return &closed_streams_;
280 } 280 }
281 281
282 void set_max_open_streams(size_t max_open_streams); 282 void set_max_open_incoming_streams(size_t max_open_incoming_streams);
283 void set_max_open_outgoing_streams(size_t max_open_outgoing_streams);
283 284
284 void set_largest_peer_created_stream_id( 285 void set_largest_peer_created_stream_id(
285 QuicStreamId largest_peer_created_stream_id) { 286 QuicStreamId largest_peer_created_stream_id) {
286 largest_peer_created_stream_id_ = largest_peer_created_stream_id; 287 largest_peer_created_stream_id_ = largest_peer_created_stream_id;
287 } 288 }
288 void set_error(QuicErrorCode error) { error_ = error; } 289 void set_error(QuicErrorCode error) { error_ = error; }
289 QuicWriteBlockedList* write_blocked_streams() { 290 QuicWriteBlockedList* write_blocked_streams() {
290 return &write_blocked_streams_; 291 return &write_blocked_streams_;
291 } 292 }
292 293
(...skipping 26 matching lines...) Expand all
319 void InsertLocallyClosedStreamsHighestOffset(const QuicStreamId id, 320 void InsertLocallyClosedStreamsHighestOffset(const QuicStreamId id,
320 QuicStreamOffset offset); 321 QuicStreamOffset offset);
321 // If stream is a locally closed stream, this RST will update FIN offset. 322 // If stream is a locally closed stream, this RST will update FIN offset.
322 // Otherwise stream is a preserved stream and the behavior of it depends on 323 // Otherwise stream is a preserved stream and the behavior of it depends on
323 // derived class's own implementation. 324 // derived class's own implementation.
324 virtual void HandleRstOnValidNonexistentStream( 325 virtual void HandleRstOnValidNonexistentStream(
325 const QuicRstStreamFrame& frame); 326 const QuicRstStreamFrame& frame);
326 327
327 private: 328 private:
328 friend class test::QuicSessionPeer; 329 friend class test::QuicSessionPeer;
329 friend class VisitorShim;
330 330
331 // Called in OnConfigNegotiated when we receive a new stream level flow 331 // Called in OnConfigNegotiated when we receive a new stream level flow
332 // control window in a negotiated config. Closes the connection if invalid. 332 // control window in a negotiated config. Closes the connection if invalid.
333 void OnNewStreamFlowControlWindow(QuicStreamOffset new_window); 333 void OnNewStreamFlowControlWindow(QuicStreamOffset new_window);
334 334
335 // Called in OnConfigNegotiated when we receive a new connection level flow 335 // Called in OnConfigNegotiated when we receive a new connection level flow
336 // control window in a negotiated config. Closes the connection if invalid. 336 // control window in a negotiated config. Closes the connection if invalid.
337 void OnNewSessionFlowControlWindow(QuicStreamOffset new_window); 337 void OnNewSessionFlowControlWindow(QuicStreamOffset new_window);
338 338
339 // Called in OnConfigNegotiated when auto-tuning is enabled for flow 339 // Called in OnConfigNegotiated when auto-tuning is enabled for flow
340 // control receive windows. 340 // control receive windows.
341 void EnableAutoTuneReceiveWindow(); 341 void EnableAutoTuneReceiveWindow();
342 342
343 // Called in OnConfigNegotiated for finch trials to measure performance of 343 // Called in OnConfigNegotiated for finch trials to measure performance of
344 // starting with smaller flow control receive windows and auto-tuning. 344 // starting with smaller flow control receive windows and auto-tuning.
345 void AdjustInitialFlowControlWindows(size_t stream_window); 345 void AdjustInitialFlowControlWindows(size_t stream_window);
346 346
347 // Keep track of highest received byte offset of locally closed streams, while 347 // Keep track of highest received byte offset of locally closed streams, while
348 // waiting for a definitive final highest offset from the peer. 348 // waiting for a definitive final highest offset from the peer.
349 std::map<QuicStreamId, QuicStreamOffset> 349 std::map<QuicStreamId, QuicStreamOffset>
350 locally_closed_streams_highest_offset_; 350 locally_closed_streams_highest_offset_;
351 351
352 scoped_ptr<QuicConnection> connection_; 352 scoped_ptr<QuicConnection> connection_;
353 353
354 // A shim to stand between the connection and the session, to handle stream
355 // deletions.
356 scoped_ptr<VisitorShim> visitor_shim_;
357
358 std::vector<ReliableQuicStream*> closed_streams_; 354 std::vector<ReliableQuicStream*> closed_streams_;
359 355
360 QuicConfig config_; 356 QuicConfig config_;
361 357
362 // Returns the maximum number of streams this connection can open. 358 // The maximum number of outgoing streams this connection can open.
363 size_t max_open_streams_; 359 size_t max_open_outgoing_streams_;
360
361 // The maximum number of incoming streams this connection will allow.
362 size_t max_open_incoming_streams_;
364 363
365 // Static streams, such as crypto and header streams. Owned by child classes 364 // Static streams, such as crypto and header streams. Owned by child classes
366 // that create these streams. 365 // that create these streams.
367 StreamMap static_stream_map_; 366 StreamMap static_stream_map_;
368 367
369 // Map from StreamId to pointers to streams. Owns the streams. 368 // Map from StreamId to pointers to streams. Owns the streams.
370 StreamMap dynamic_stream_map_; 369 StreamMap dynamic_stream_map_;
371 370
372 // The ID to use for the next outgoing stream. 371 // The ID to use for the next outgoing stream.
373 QuicStreamId next_outgoing_stream_id_; 372 QuicStreamId next_outgoing_stream_id_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 // The stream id which was last popped in OnCanWrite, or 0, if not under the 404 // The stream id which was last popped in OnCanWrite, or 0, if not under the
406 // call stack of OnCanWrite. 405 // call stack of OnCanWrite.
407 QuicStreamId currently_writing_stream_id_; 406 QuicStreamId currently_writing_stream_id_;
408 407
409 DISALLOW_COPY_AND_ASSIGN(QuicSession); 408 DISALLOW_COPY_AND_ASSIGN(QuicSession);
410 }; 409 };
411 410
412 } // namespace net 411 } // namespace net
413 412
414 #endif // NET_QUIC_QUIC_SESSION_H_ 413 #endif // NET_QUIC_QUIC_SESSION_H_
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager_test.cc ('k') | net/quic/quic_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698