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

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

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_config.cc ('k') | net/quic/quic_connection.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 // The entity that handles framing writes for a Quic client or server. 5 // The entity that handles framing writes for a Quic client or server.
6 // Each QuicSession will have a connection associated with it. 6 // Each QuicSession will have a connection associated with it.
7 // 7 //
8 // On the server side, the Dispatcher handles the raw reads, and hands off 8 // On the server side, the Dispatcher handles the raw reads, and hands off
9 // packets via ProcessUdpPacket for framing and processing. 9 // packets via ProcessUdpPacket for framing and processing.
10 // 10 //
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 virtual ~QuicConnectionDebugVisitorInterface() {} 86 virtual ~QuicConnectionDebugVisitorInterface() {}
87 87
88 // Called when a packet has been received, but before it is 88 // Called when a packet has been received, but before it is
89 // validated or parsed. 89 // validated or parsed.
90 virtual void OnPacketReceived(const IPEndPoint& self_address, 90 virtual void OnPacketReceived(const IPEndPoint& self_address,
91 const IPEndPoint& peer_address, 91 const IPEndPoint& peer_address,
92 const QuicEncryptedPacket& packet) = 0; 92 const QuicEncryptedPacket& packet) = 0;
93 93
94 // Called when the protocol version on the received packet doensn't match 94 // Called when the protocol version on the received packet doensn't match
95 // current protocol version of the connection. 95 // current protocol version of the connection.
96 virtual void OnProtocolVersionMismatch( 96 virtual void OnProtocolVersionMismatch(QuicTag version) = 0;
97 QuicVersionTag version) = 0;
98 97
99 // Called when the complete header of a packet has been parsed. 98 // Called when the complete header of a packet has been parsed.
100 virtual void OnPacketHeader(const QuicPacketHeader& header) = 0; 99 virtual void OnPacketHeader(const QuicPacketHeader& header) = 0;
101 100
102 // Called when a StreamFrame has been parsed. 101 // Called when a StreamFrame has been parsed.
103 virtual void OnStreamFrame(const QuicStreamFrame& frame) = 0; 102 virtual void OnStreamFrame(const QuicStreamFrame& frame) = 0;
104 103
105 // Called when a AckFrame has been parsed. 104 // Called when a AckFrame has been parsed.
106 virtual void OnAckFrame(const QuicAckFrame& frame) = 0; 105 virtual void OnAckFrame(const QuicAckFrame& frame) = 0;
107 106
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // its FEC group that packet will be revived and processed. 250 // its FEC group that packet will be revived and processed.
252 virtual void ProcessUdpPacket(const IPEndPoint& self_address, 251 virtual void ProcessUdpPacket(const IPEndPoint& self_address,
253 const IPEndPoint& peer_address, 252 const IPEndPoint& peer_address,
254 const QuicEncryptedPacket& packet); 253 const QuicEncryptedPacket& packet);
255 254
256 // QuicBlockedWriterInterface 255 // QuicBlockedWriterInterface
257 // Called when the underlying connection becomes writable to allow 256 // Called when the underlying connection becomes writable to allow
258 // queued writes to happen. Returns false if the socket has become blocked. 257 // queued writes to happen. Returns false if the socket has become blocked.
259 virtual bool OnCanWrite() OVERRIDE; 258 virtual bool OnCanWrite() OVERRIDE;
260 259
261 QuicVersionTag version() const { 260 QuicTag version() const { return quic_version_; }
262 return quic_version_;
263 }
264 261
265 // From QuicFramerVisitorInterface 262 // From QuicFramerVisitorInterface
266 virtual void OnError(QuicFramer* framer) OVERRIDE; 263 virtual void OnError(QuicFramer* framer) OVERRIDE;
267 virtual bool OnProtocolVersionMismatch( 264 virtual bool OnProtocolVersionMismatch(QuicTag received_version) OVERRIDE;
268 QuicVersionTag received_version) OVERRIDE;
269 virtual void OnPacket() OVERRIDE; 265 virtual void OnPacket() OVERRIDE;
270 virtual void OnPublicResetPacket( 266 virtual void OnPublicResetPacket(
271 const QuicPublicResetPacket& packet) OVERRIDE; 267 const QuicPublicResetPacket& packet) OVERRIDE;
272 virtual void OnVersionNegotiationPacket( 268 virtual void OnVersionNegotiationPacket(
273 const QuicVersionNegotiationPacket& packet) OVERRIDE; 269 const QuicVersionNegotiationPacket& packet) OVERRIDE;
274 virtual void OnRevivedPacket() OVERRIDE; 270 virtual void OnRevivedPacket() OVERRIDE;
275 virtual bool OnPacketHeader(const QuicPacketHeader& header) OVERRIDE; 271 virtual bool OnPacketHeader(const QuicPacketHeader& header) OVERRIDE;
276 virtual void OnFecProtectedPayload(base::StringPiece payload) OVERRIDE; 272 virtual void OnFecProtectedPayload(base::StringPiece payload) OVERRIDE;
277 virtual bool OnStreamFrame(const QuicStreamFrame& frame) OVERRIDE; 273 virtual bool OnStreamFrame(const QuicStreamFrame& frame) OVERRIDE;
278 virtual bool OnAckFrame(const QuicAckFrame& frame) OVERRIDE; 274 virtual bool OnAckFrame(const QuicAckFrame& frame) OVERRIDE;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 bool connected() { return connected_; } 319 bool connected() { return connected_; }
324 320
325 size_t NumFecGroups() const { return group_map_.size(); } 321 size_t NumFecGroups() const { return group_map_.size(); }
326 322
327 // Testing only. 323 // Testing only.
328 size_t NumQueuedPackets() const { return queued_packets_.size(); } 324 size_t NumQueuedPackets() const { return queued_packets_.size(); }
329 325
330 // Returns true if the connection has queued packets or frames. 326 // Returns true if the connection has queued packets or frames.
331 bool HasQueuedData() const; 327 bool HasQueuedData() const;
332 328
329 // Sets (or resets) the idle state connection timeout. Also, checks and times
330 // out the connection if network timer has expired for |timeout|.
331 void SetConnectionTimeout(QuicTime::Delta timeout);
332
333 // If the connection has timed out, this will close the connection and return 333 // If the connection has timed out, this will close the connection and return
334 // true. Otherwise, it will return false and will reset the timeout alarm. 334 // true. Otherwise, it will return false and will reset the timeout alarm.
335 bool CheckForTimeout(); 335 bool CheckForTimeout();
336 336
337 // Returns true of the next packet to be sent should be "lost" by 337 // Returns true of the next packet to be sent should be "lost" by
338 // not actually writing it to the wire. 338 // not actually writing it to the wire.
339 bool ShouldSimulateLostPacket(); 339 bool ShouldSimulateLostPacket();
340 340
341 // Sets up a packet with an QuicAckFrame and sends it out. 341 // Sets up a packet with an QuicAckFrame and sends it out.
342 void SendAck(); 342 void SendAck();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 // state. 413 // state.
414 // 414 //
415 // Updates internal state based on incoming_ack.received_info 415 // Updates internal state based on incoming_ack.received_info
416 void UpdatePacketInformationReceivedByPeer( 416 void UpdatePacketInformationReceivedByPeer(
417 const QuicAckFrame& incoming_ack); 417 const QuicAckFrame& incoming_ack);
418 // Updates internal state based in incoming_ack.sent_info 418 // Updates internal state based in incoming_ack.sent_info
419 void UpdatePacketInformationSentByPeer(const QuicAckFrame& incoming_ack); 419 void UpdatePacketInformationSentByPeer(const QuicAckFrame& incoming_ack);
420 420
421 QuicConnectionHelperInterface* helper() { return helper_.get(); } 421 QuicConnectionHelperInterface* helper() { return helper_.get(); }
422 422
423 protected:
424 QuicFramer framer_;
425
423 private: 426 private:
424 friend class test::QuicConnectionPeer; 427 friend class test::QuicConnectionPeer;
425 428
426 // Packets which have not been written to the wire. 429 // Packets which have not been written to the wire.
427 // Owns the QuicPacket* packet. 430 // Owns the QuicPacket* packet.
428 struct QueuedPacket { 431 struct QueuedPacket {
429 QueuedPacket(QuicPacketSequenceNumber sequence_number, 432 QueuedPacket(QuicPacketSequenceNumber sequence_number,
430 QuicPacket* packet, 433 QuicPacket* packet,
431 EncryptionLevel level, 434 EncryptionLevel level,
432 HasRetransmittableData retransmittable) 435 HasRetransmittableData retransmittable)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 typedef base::hash_map<QuicPacketSequenceNumber, 476 typedef base::hash_map<QuicPacketSequenceNumber,
474 RetransmissionInfo> RetransmissionMap; 477 RetransmissionInfo> RetransmissionMap;
475 typedef std::priority_queue<RetransmissionInfo, 478 typedef std::priority_queue<RetransmissionInfo,
476 std::vector<RetransmissionInfo>, 479 std::vector<RetransmissionInfo>,
477 RetransmissionInfoComparator> 480 RetransmissionInfoComparator>
478 RetransmissionTimeouts; 481 RetransmissionTimeouts;
479 482
480 // Selects and updates the version of the protocol being used by selecting a 483 // Selects and updates the version of the protocol being used by selecting a
481 // version from |available_versions| which is also supported. Returns true if 484 // version from |available_versions| which is also supported. Returns true if
482 // such a version exists, false otherwise. 485 // such a version exists, false otherwise.
483 bool SelectMutualVersion( 486 bool SelectMutualVersion(const QuicTagVector& available_versions);
484 const QuicVersionTagList& available_versions);
485 // Sends a version negotiation packet to the peer. 487 // Sends a version negotiation packet to the peer.
486 void SendVersionNegotiationPacket(); 488 void SendVersionNegotiationPacket();
487 489
488 void MaybeSetupRetransmission(QuicPacketSequenceNumber sequence_number); 490 void MaybeSetupRetransmission(QuicPacketSequenceNumber sequence_number);
489 bool IsRetransmission(QuicPacketSequenceNumber sequence_number); 491 bool IsRetransmission(QuicPacketSequenceNumber sequence_number);
490 void RetransmitAllUnackedPackets(); 492 void RetransmitAllUnackedPackets();
491 493
492 // Writes as many queued packets as possible. The connection must not be 494 // Writes as many queued packets as possible. The connection must not be
493 // blocked when this is called. 495 // blocked when this is called.
494 bool WriteQueuedPackets(); 496 bool WriteQueuedPackets();
495 497
496 // If a packet can be revived from the current FEC group, then 498 // If a packet can be revived from the current FEC group, then
497 // revive and process the packet. 499 // revive and process the packet.
498 void MaybeProcessRevivedPacket(); 500 void MaybeProcessRevivedPacket();
499 501
500 void UpdateOutgoingAck(); 502 void UpdateOutgoingAck();
501 503
502 void MaybeSendAckInResponseToPacket(); 504 void MaybeSendAckInResponseToPacket();
503 505
504 // Get the FEC group associate with the last processed packet. 506 // Get the FEC group associate with the last processed packet.
505 QuicFecGroup* GetFecGroup(); 507 QuicFecGroup* GetFecGroup();
506 508
507 // Closes any FEC groups protecting packets before |sequence_number|. 509 // Closes any FEC groups protecting packets before |sequence_number|.
508 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); 510 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number);
509 511
510 scoped_ptr<QuicConnectionHelperInterface> helper_; 512 scoped_ptr<QuicConnectionHelperInterface> helper_;
511 QuicFramer framer_;
512 EncryptionLevel encryption_level_; 513 EncryptionLevel encryption_level_;
513 const QuicClock* clock_; 514 const QuicClock* clock_;
514 QuicRandom* random_generator_; 515 QuicRandom* random_generator_;
515 516
516 const QuicGuid guid_; 517 const QuicGuid guid_;
517 // Address on the last successfully processed packet received from the 518 // Address on the last successfully processed packet received from the
518 // client. 519 // client.
519 IPEndPoint self_address_; 520 IPEndPoint self_address_;
520 IPEndPoint peer_address_; 521 IPEndPoint peer_address_;
521 // Address on the last(currently being processed) packet received. Not 522 // Address on the last(currently being processed) packet received. Not
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 FecGroupMap group_map_; 574 FecGroupMap group_map_;
574 575
575 QuicPacketEntropyManager entropy_manager_; 576 QuicPacketEntropyManager entropy_manager_;
576 577
577 QuicConnectionVisitorInterface* visitor_; 578 QuicConnectionVisitorInterface* visitor_;
578 QuicConnectionDebugVisitorInterface* debug_visitor_; 579 QuicConnectionDebugVisitorInterface* debug_visitor_;
579 QuicPacketCreator packet_creator_; 580 QuicPacketCreator packet_creator_;
580 QuicPacketGenerator packet_generator_; 581 QuicPacketGenerator packet_generator_;
581 582
582 // Network idle time before we kill of this connection. 583 // Network idle time before we kill of this connection.
583 const QuicTime::Delta timeout_; 584 QuicTime::Delta timeout_;
584 585
585 // Statistics for this session. 586 // Statistics for this session.
586 QuicConnectionStats stats_; 587 QuicConnectionStats stats_;
587 588
588 // The time that we got a packet for this connection. 589 // The time that we got a packet for this connection.
589 QuicTime time_of_last_received_packet_; 590 QuicTime time_of_last_received_packet_;
590 591
591 // The time that we last sent a packet for this connection. 592 // The time that we last sent a packet for this connection.
592 QuicTime time_of_last_sent_packet_; 593 QuicTime time_of_last_sent_packet_;
593 594
594 // Member holding the time we received the largest_observed sequence number. 595 // Member holding the time we received the largest_observed sequence number.
595 // Needed for calculating delta_time_largest_observed. 596 // Needed for calculating delta_time_largest_observed.
596 QuicTime time_largest_observed_; 597 QuicTime time_largest_observed_;
597 598
598 // Congestion manager which controls the rate the connection sends packets 599 // Congestion manager which controls the rate the connection sends packets
599 // as well as collecting and generating congestion feedback. 600 // as well as collecting and generating congestion feedback.
600 QuicCongestionManager congestion_manager_; 601 QuicCongestionManager congestion_manager_;
601 602
602 // The state of connection in version negotiation finite state machine. 603 // The state of connection in version negotiation finite state machine.
603 QuicVersionNegotiationState version_negotiation_state_; 604 QuicVersionNegotiationState version_negotiation_state_;
604 605
605 // The version of the protocol this connection is using. 606 // The version of the protocol this connection is using.
606 QuicVersionTag quic_version_; 607 QuicTag quic_version_;
607 608
608 // Tracks if the connection was created by the server. 609 // Tracks if the connection was created by the server.
609 bool is_server_; 610 bool is_server_;
610 611
611 // True by default. False if we've received or sent an explicit connection 612 // True by default. False if we've received or sent an explicit connection
612 // close. 613 // close.
613 bool connected_; 614 bool connected_;
614 615
615 // True if the last ack received from the peer may have been truncated. False 616 // True if the last ack received from the peer may have been truncated. False
616 // otherwise. 617 // otherwise.
617 bool received_truncated_ack_; 618 bool received_truncated_ack_;
618 619
619 bool send_ack_in_response_to_packet_; 620 bool send_ack_in_response_to_packet_;
620 621
621 DISALLOW_COPY_AND_ASSIGN(QuicConnection); 622 DISALLOW_COPY_AND_ASSIGN(QuicConnection);
622 }; 623 };
623 624
624 } // namespace net 625 } // namespace net
625 626
626 #endif // NET_QUIC_QUIC_CONNECTION_H_ 627 #endif // NET_QUIC_QUIC_CONNECTION_H_
OLDNEW
« no previous file with comments | « net/quic/quic_config.cc ('k') | net/quic/quic_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698