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

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

Issue 146033003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error Created 6 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_client_session_test.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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // Deletes |packet| if WritePacket call succeeds, or transfers ownership to 420 // Deletes |packet| if WritePacket call succeeds, or transfers ownership to
421 // QueuedPacket, ultimately deleted in WriteQueuedPackets. Updates the 421 // QueuedPacket, ultimately deleted in WriteQueuedPackets. Updates the
422 // entropy map corresponding to |sequence_number| using |entropy_hash|. 422 // entropy map corresponding to |sequence_number| using |entropy_hash|.
423 // |transmission_type| and |retransmittable| are supplied to the congestion 423 // |transmission_type| and |retransmittable| are supplied to the congestion
424 // manager, and when |forced| is true, it bypasses the congestion manager. 424 // manager, and when |forced| is true, it bypasses the congestion manager.
425 // TODO(wtc): none of the callers check the return value. 425 // TODO(wtc): none of the callers check the return value.
426 virtual bool SendOrQueuePacket(EncryptionLevel level, 426 virtual bool SendOrQueuePacket(EncryptionLevel level,
427 const SerializedPacket& packet, 427 const SerializedPacket& packet,
428 TransmissionType transmission_type); 428 TransmissionType transmission_type);
429 429
430 // Writes the given packet to socket, encrypted with |level|, with the help
431 // of helper. Returns true on successful write, false otherwise. However,
432 // behavior is undefined if connection is not established or broken. In any
433 // circumstances, a return value of true implies that |packet| has been
434 // transmitted and may be destroyed. If |sequence_number| is present in
435 // |retransmission_map_| it also sets up retransmission of the given packet
436 // in case of successful write. If |force| is FORCE, then the packet will be
437 // sent immediately and the send scheduler will not be consulted.
438 bool WritePacket(EncryptionLevel level,
439 QuicPacketSequenceNumber sequence_number,
440 const QuicPacket& packet,
441 TransmissionType transmission_type,
442 HasRetransmittableData retransmittable,
443 IsHandshake handshake,
444 Force force);
445
446 // Make sure an ack we got from our peer is sane.
447 bool ValidateAckFrame(const QuicAckFrame& incoming_ack);
448
449 QuicConnectionHelperInterface* helper() { return helper_; } 430 QuicConnectionHelperInterface* helper() { return helper_; }
450 431
451 // Selects and updates the version of the protocol being used by selecting a 432 // Selects and updates the version of the protocol being used by selecting a
452 // version from |available_versions| which is also supported. Returns true if 433 // version from |available_versions| which is also supported. Returns true if
453 // such a version exists, false otherwise. 434 // such a version exists, false otherwise.
454 bool SelectMutualVersion(const QuicVersionVector& available_versions); 435 bool SelectMutualVersion(const QuicVersionVector& available_versions);
455 436
456 QuicFramer framer_;
457
458 private: 437 private:
459 // Stores current batch state for connection, puts the connection 438 // Stores current batch state for connection, puts the connection
460 // into batch mode, and destruction restores the stored batch state. 439 // into batch mode, and destruction restores the stored batch state.
461 // While the bundler is in scope, any generated frames are bundled 440 // While the bundler is in scope, any generated frames are bundled
462 // as densely as possible into packets. In addition, this bundler 441 // as densely as possible into packets. In addition, this bundler
463 // can be configured to ensure that an ACK frame is included in the 442 // can be configured to ensure that an ACK frame is included in the
464 // first packet created, if there's new ack information to be sent. 443 // first packet created, if there's new ack information to be sent.
465 class ScopedPacketBundler { 444 class ScopedPacketBundler {
466 public: 445 public:
467 // In addition to all outgoing frames being bundled when the 446 // In addition to all outgoing frames being bundled when the
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 TransmissionType transmission_type; 504 TransmissionType transmission_type;
526 HasRetransmittableData retransmittable; 505 HasRetransmittableData retransmittable;
527 EncryptionLevel level; 506 EncryptionLevel level;
528 bool is_fec_packet; 507 bool is_fec_packet;
529 size_t length; 508 size_t length;
530 }; 509 };
531 510
532 typedef std::list<QueuedPacket> QueuedPacketList; 511 typedef std::list<QueuedPacket> QueuedPacketList;
533 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap; 512 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap;
534 513
514 // Writes the given packet to socket, encrypted with |level|. Returns true on
515 // successful write. Behavior is undefined if connection is not established or
516 // broken. In any circumstance, a return value of true implies that |packet|
517 // has been transmitted and may be destroyed. If |sequence_number| is present
518 // in |retransmission_map_| it also sets up retransmission of the given packet
519 // in case of successful write. If |force| is FORCE, then the packet will be
520 // sent immediately and the send scheduler will not be consulted.
521 bool WritePacket(EncryptionLevel level,
522 QuicPacketSequenceNumber sequence_number,
523 const QuicPacket& packet,
524 TransmissionType transmission_type,
525 HasRetransmittableData retransmittable,
526 IsHandshake handshake,
527 Force force);
528
529 // Make sure an ack we got from our peer is sane.
530 bool ValidateAckFrame(const QuicAckFrame& incoming_ack);
531
535 // Sends a version negotiation packet to the peer. 532 // Sends a version negotiation packet to the peer.
536 void SendVersionNegotiationPacket(); 533 void SendVersionNegotiationPacket();
537 534
538 // Clears any accumulated frames from the last received packet. 535 // Clears any accumulated frames from the last received packet.
539 void ClearLastFrames(); 536 void ClearLastFrames();
540 537
541 // Calculates the smallest sequence number length that can also represent four 538 // Calculates the smallest sequence number length that can also represent four
542 // times the maximum of the congestion window and the difference between the 539 // times the maximum of the congestion window and the difference between the
543 // least_packet_awaited_by_peer_ and |sequence_number|. 540 // least_packet_awaited_by_peer_ and |sequence_number|.
544 QuicSequenceNumberLength CalculateSequenceNumberLength( 541 QuicSequenceNumberLength CalculateSequenceNumberLength(
(...skipping 26 matching lines...) Expand all
571 568
572 // If a packet can be revived from the current FEC group, then 569 // If a packet can be revived from the current FEC group, then
573 // revive and process the packet. 570 // revive and process the packet.
574 void MaybeProcessRevivedPacket(); 571 void MaybeProcessRevivedPacket();
575 572
576 void ProcessAckFrame(const QuicAckFrame& incoming_ack); 573 void ProcessAckFrame(const QuicAckFrame& incoming_ack);
577 574
578 // Update the |sent_info| for an outgoing ack. 575 // Update the |sent_info| for an outgoing ack.
579 void UpdateSentPacketInfo(SentPacketInfo* sent_info); 576 void UpdateSentPacketInfo(SentPacketInfo* sent_info);
580 577
578 // Queues an ack or sets the ack alarm when an incoming packet arrives that
579 // should be acked.
580 void MaybeQueueAck();
581
581 // Checks if the last packet should instigate an ack. 582 // Checks if the last packet should instigate an ack.
582 bool ShouldLastPacketInstigateAck(); 583 bool ShouldLastPacketInstigateAck();
583 584
584 // Sends any packets which are a response to the last packet, including both 585 // Sends any packets which are a response to the last packet, including both
585 // acks and pending writes if an ack opened the congestion window. 586 // acks and pending writes if an ack opened the congestion window.
586 void MaybeSendInResponseToPacket(bool send_ack_immediately, 587 void MaybeSendInResponseToPacket();
587 bool last_packet_should_instigate_ack);
588 588
589 // Get the FEC group associate with the last processed packet or NULL, if the 589 // Get the FEC group associate with the last processed packet or NULL, if the
590 // group has already been deleted. 590 // group has already been deleted.
591 QuicFecGroup* GetFecGroup(); 591 QuicFecGroup* GetFecGroup();
592 592
593 // Closes any FEC groups protecting packets before |sequence_number|. 593 // Closes any FEC groups protecting packets before |sequence_number|.
594 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); 594 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number);
595 595
596 QuicFramer framer_;
596 QuicConnectionHelperInterface* helper_; // Not owned. 597 QuicConnectionHelperInterface* helper_; // Not owned.
597 QuicPacketWriter* writer_; // Not owned. 598 QuicPacketWriter* writer_; // Not owned.
598 EncryptionLevel encryption_level_; 599 EncryptionLevel encryption_level_;
599 const QuicClock* clock_; 600 const QuicClock* clock_;
600 QuicRandom* random_generator_; 601 QuicRandom* random_generator_;
601 602
602 const QuicGuid guid_; 603 const QuicGuid guid_;
603 // Address on the last successfully processed packet received from the 604 // Address on the last successfully processed packet received from the
604 // client. 605 // client.
605 IPEndPoint self_address_; 606 IPEndPoint self_address_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 scoped_ptr<PendingWrite> pending_write_; 641 scoped_ptr<PendingWrite> pending_write_;
641 642
642 // Contains the connection close packet if the connection has been closed. 643 // Contains the connection close packet if the connection has been closed.
643 scoped_ptr<QuicEncryptedPacket> connection_close_packet_; 644 scoped_ptr<QuicEncryptedPacket> connection_close_packet_;
644 645
645 FecGroupMap group_map_; 646 FecGroupMap group_map_;
646 647
647 QuicReceivedPacketManager received_packet_manager_; 648 QuicReceivedPacketManager received_packet_manager_;
648 QuicSentEntropyManager sent_entropy_manager_; 649 QuicSentEntropyManager sent_entropy_manager_;
649 650
651 // Indicates whether an ack should be sent the next time we try to write.
652 bool ack_queued_;
653
650 // An alarm that fires when an ACK should be sent to the peer. 654 // An alarm that fires when an ACK should be sent to the peer.
651 scoped_ptr<QuicAlarm> ack_alarm_; 655 scoped_ptr<QuicAlarm> ack_alarm_;
652 // An alarm that fires when a packet needs to be retransmitted. 656 // An alarm that fires when a packet needs to be retransmitted.
653 scoped_ptr<QuicAlarm> retransmission_alarm_; 657 scoped_ptr<QuicAlarm> retransmission_alarm_;
654 // An alarm that is scheduled when the sent scheduler requires a 658 // An alarm that is scheduled when the sent scheduler requires a
655 // a delay before sending packets and fires when the packet may be sent. 659 // a delay before sending packets and fires when the packet may be sent.
656 scoped_ptr<QuicAlarm> send_alarm_; 660 scoped_ptr<QuicAlarm> send_alarm_;
657 // An alarm that is scheduled when the connection can still write and there 661 // An alarm that is scheduled when the connection can still write and there
658 // may be more data to send. 662 // may be more data to send.
659 scoped_ptr<QuicAlarm> resume_writes_alarm_; 663 scoped_ptr<QuicAlarm> resume_writes_alarm_;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // If non-empty this contains the set of versions received in a 714 // If non-empty this contains the set of versions received in a
711 // version negotiation packet. 715 // version negotiation packet.
712 QuicVersionVector server_supported_versions_; 716 QuicVersionVector server_supported_versions_;
713 717
714 DISALLOW_COPY_AND_ASSIGN(QuicConnection); 718 DISALLOW_COPY_AND_ASSIGN(QuicConnection);
715 }; 719 };
716 720
717 } // namespace net 721 } // namespace net
718 722
719 #endif // NET_QUIC_QUIC_CONNECTION_H_ 723 #endif // NET_QUIC_QUIC_CONNECTION_H_
OLDNEW
« no previous file with comments | « net/quic/quic_client_session_test.cc ('k') | net/quic/quic_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698