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

Side by Side Diff: net/quic/core/quic_connection.cc

Issue 2709503004: Inline QUIC ack and stop waiting processing, because it's only called from one location each. (Closed)
Patch Set: Created 3 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/core/quic_connection.h ('k') | no next file » | 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 #include "net/quic/core/quic_connection.h" 5 #include "net/quic/core/quic_connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 const char* error = ValidateAckFrame(incoming_ack); 684 const char* error = ValidateAckFrame(incoming_ack);
685 if (error != nullptr) { 685 if (error != nullptr) {
686 CloseConnection(QUIC_INVALID_ACK_DATA, error, 686 CloseConnection(QUIC_INVALID_ACK_DATA, error,
687 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); 687 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
688 return false; 688 return false;
689 } 689 }
690 690
691 if (send_alarm_->IsSet()) { 691 if (send_alarm_->IsSet()) {
692 send_alarm_->Cancel(); 692 send_alarm_->Cancel();
693 } 693 }
694 ProcessAckFrame(incoming_ack); 694 largest_seen_packet_with_ack_ = last_header_.packet_number;
695 sent_packet_manager_.OnIncomingAck(incoming_ack,
696 time_of_last_received_packet_);
697 // Always reset the retransmission alarm when an ack comes in, since we now
698 // have a better estimate of the current rtt than when it was set.
699 SetRetransmissionAlarm();
700
695 // If the incoming ack's packets set expresses missing packets: peer is still 701 // If the incoming ack's packets set expresses missing packets: peer is still
696 // waiting for a packet lower than a packet that we are no longer planning to 702 // waiting for a packet lower than a packet that we are no longer planning to
697 // send. 703 // send.
698 // If the incoming ack's packets set expresses received packets: peer is still 704 // If the incoming ack's packets set expresses received packets: peer is still
699 // acking packets which we never care about. 705 // acking packets which we never care about.
700 // Send an ack to raise the high water mark. 706 // Send an ack to raise the high water mark.
701 if (!incoming_ack.packets.Empty() && 707 if (!incoming_ack.packets.Empty() &&
702 GetLeastUnacked() > incoming_ack.packets.Min()) { 708 GetLeastUnacked() > incoming_ack.packets.Min()) {
703 ++stop_waiting_count_; 709 ++stop_waiting_count_;
704 } else { 710 } else {
705 stop_waiting_count_ = 0; 711 stop_waiting_count_ = 0;
706 } 712 }
707 713
708 return connected_; 714 return connected_;
709 } 715 }
710 716
711 void QuicConnection::ProcessAckFrame(const QuicAckFrame& incoming_ack) {
712 largest_seen_packet_with_ack_ = last_header_.packet_number;
713 sent_packet_manager_.OnIncomingAck(incoming_ack,
714 time_of_last_received_packet_);
715 // Always reset the retransmission alarm when an ack comes in, since we now
716 // have a better estimate of the current rtt than when it was set.
717 SetRetransmissionAlarm();
718 }
719
720 void QuicConnection::ProcessStopWaitingFrame(
721 const QuicStopWaitingFrame& stop_waiting) {
722 largest_seen_packet_with_stop_waiting_ = last_header_.packet_number;
723 received_packet_manager_.UpdatePacketInformationSentByPeer(stop_waiting);
724 }
725
726 bool QuicConnection::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) { 717 bool QuicConnection::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) {
727 DCHECK(connected_); 718 DCHECK(connected_);
728 719
729 if (last_header_.packet_number <= largest_seen_packet_with_stop_waiting_) { 720 if (last_header_.packet_number <= largest_seen_packet_with_stop_waiting_) {
730 QUIC_DLOG(INFO) << ENDPOINT 721 QUIC_DLOG(INFO) << ENDPOINT
731 << "Received an old stop waiting frame: ignoring"; 722 << "Received an old stop waiting frame: ignoring";
732 return true; 723 return true;
733 } 724 }
734 725
735 const char* error = ValidateStopWaitingFrame(frame); 726 const char* error = ValidateStopWaitingFrame(frame);
736 if (error != nullptr) { 727 if (error != nullptr) {
737 CloseConnection(QUIC_INVALID_STOP_WAITING_DATA, error, 728 CloseConnection(QUIC_INVALID_STOP_WAITING_DATA, error,
738 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); 729 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
739 return false; 730 return false;
740 } 731 }
741 732
742 if (debug_visitor_ != nullptr) { 733 if (debug_visitor_ != nullptr) {
743 debug_visitor_->OnStopWaitingFrame(frame); 734 debug_visitor_->OnStopWaitingFrame(frame);
744 } 735 }
745 736
746 ProcessStopWaitingFrame(frame); 737 largest_seen_packet_with_stop_waiting_ = last_header_.packet_number;
738 received_packet_manager_.UpdatePacketInformationSentByPeer(frame);
747 return connected_; 739 return connected_;
748 } 740 }
749 741
750 bool QuicConnection::OnPaddingFrame(const QuicPaddingFrame& frame) { 742 bool QuicConnection::OnPaddingFrame(const QuicPaddingFrame& frame) {
751 DCHECK(connected_); 743 DCHECK(connected_);
752 if (debug_visitor_ != nullptr) { 744 if (debug_visitor_ != nullptr) {
753 debug_visitor_->OnPaddingFrame(frame); 745 debug_visitor_->OnPaddingFrame(frame);
754 } 746 }
755 return true; 747 return true;
756 } 748 }
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
2391 2383
2392 void QuicConnection::CheckIfApplicationLimited() { 2384 void QuicConnection::CheckIfApplicationLimited() {
2393 if (queued_packets_.empty() && 2385 if (queued_packets_.empty() &&
2394 !sent_packet_manager_.HasPendingRetransmissions() && 2386 !sent_packet_manager_.HasPendingRetransmissions() &&
2395 !visitor_->WillingAndAbleToWrite()) { 2387 !visitor_->WillingAndAbleToWrite()) {
2396 sent_packet_manager_.OnApplicationLimited(); 2388 sent_packet_manager_.OnApplicationLimited();
2397 } 2389 }
2398 } 2390 }
2399 2391
2400 } // namespace net 2392 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698