| OLD | NEW |
| 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/quic_connection.h" | 5 #include "net/quic/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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 } | 687 } |
| 688 if (frame.stream_id != kCryptoStreamId && | 688 if (frame.stream_id != kCryptoStreamId && |
| 689 last_decrypted_packet_level_ == ENCRYPTION_NONE) { | 689 last_decrypted_packet_level_ == ENCRYPTION_NONE) { |
| 690 DLOG(WARNING) << ENDPOINT | 690 DLOG(WARNING) << ENDPOINT |
| 691 << "Received an unencrypted data frame: closing connection"; | 691 << "Received an unencrypted data frame: closing connection"; |
| 692 SendConnectionCloseWithDetails(QUIC_UNENCRYPTED_STREAM_DATA, | 692 SendConnectionCloseWithDetails(QUIC_UNENCRYPTED_STREAM_DATA, |
| 693 "Unencrypted stream data seen"); | 693 "Unencrypted stream data seen"); |
| 694 return false; | 694 return false; |
| 695 } | 695 } |
| 696 visitor_->OnStreamFrame(frame); | 696 visitor_->OnStreamFrame(frame); |
| 697 visitor_->PostProcessAfterData(); |
| 697 stats_.stream_bytes_received += frame.frame_length; | 698 stats_.stream_bytes_received += frame.frame_length; |
| 698 should_last_packet_instigate_acks_ = true; | 699 should_last_packet_instigate_acks_ = true; |
| 699 return connected_; | 700 return connected_; |
| 700 } | 701 } |
| 701 | 702 |
| 702 bool QuicConnection::OnAckFrame(const QuicAckFrame& incoming_ack) { | 703 bool QuicConnection::OnAckFrame(const QuicAckFrame& incoming_ack) { |
| 703 DCHECK(connected_); | 704 DCHECK(connected_); |
| 704 if (debug_visitor_ != nullptr) { | 705 if (debug_visitor_ != nullptr) { |
| 705 debug_visitor_->OnAckFrame(incoming_ack); | 706 debug_visitor_->OnAckFrame(incoming_ack); |
| 706 } | 707 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 bool QuicConnection::OnRstStreamFrame(const QuicRstStreamFrame& frame) { | 876 bool QuicConnection::OnRstStreamFrame(const QuicRstStreamFrame& frame) { |
| 876 DCHECK(connected_); | 877 DCHECK(connected_); |
| 877 if (debug_visitor_ != nullptr) { | 878 if (debug_visitor_ != nullptr) { |
| 878 debug_visitor_->OnRstStreamFrame(frame); | 879 debug_visitor_->OnRstStreamFrame(frame); |
| 879 } | 880 } |
| 880 DVLOG(1) << ENDPOINT | 881 DVLOG(1) << ENDPOINT |
| 881 << "RST_STREAM_FRAME received for stream: " << frame.stream_id | 882 << "RST_STREAM_FRAME received for stream: " << frame.stream_id |
| 882 << " with error: " | 883 << " with error: " |
| 883 << QuicUtils::StreamErrorToString(frame.error_code); | 884 << QuicUtils::StreamErrorToString(frame.error_code); |
| 884 visitor_->OnRstStream(frame); | 885 visitor_->OnRstStream(frame); |
| 886 visitor_->PostProcessAfterData(); |
| 885 should_last_packet_instigate_acks_ = true; | 887 should_last_packet_instigate_acks_ = true; |
| 886 return connected_; | 888 return connected_; |
| 887 } | 889 } |
| 888 | 890 |
| 889 bool QuicConnection::OnConnectionCloseFrame( | 891 bool QuicConnection::OnConnectionCloseFrame( |
| 890 const QuicConnectionCloseFrame& frame) { | 892 const QuicConnectionCloseFrame& frame) { |
| 891 DCHECK(connected_); | 893 DCHECK(connected_); |
| 892 if (debug_visitor_ != nullptr) { | 894 if (debug_visitor_ != nullptr) { |
| 893 debug_visitor_->OnConnectionCloseFrame(frame); | 895 debug_visitor_->OnConnectionCloseFrame(frame); |
| 894 } | 896 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 905 if (debug_visitor_ != nullptr) { | 907 if (debug_visitor_ != nullptr) { |
| 906 debug_visitor_->OnGoAwayFrame(frame); | 908 debug_visitor_->OnGoAwayFrame(frame); |
| 907 } | 909 } |
| 908 DVLOG(1) << ENDPOINT << "GOAWAY_FRAME received with last good stream: " | 910 DVLOG(1) << ENDPOINT << "GOAWAY_FRAME received with last good stream: " |
| 909 << frame.last_good_stream_id | 911 << frame.last_good_stream_id |
| 910 << " and error: " << QuicUtils::ErrorToString(frame.error_code) | 912 << " and error: " << QuicUtils::ErrorToString(frame.error_code) |
| 911 << " and reason: " << frame.reason_phrase; | 913 << " and reason: " << frame.reason_phrase; |
| 912 | 914 |
| 913 goaway_received_ = true; | 915 goaway_received_ = true; |
| 914 visitor_->OnGoAway(frame); | 916 visitor_->OnGoAway(frame); |
| 917 visitor_->PostProcessAfterData(); |
| 915 should_last_packet_instigate_acks_ = true; | 918 should_last_packet_instigate_acks_ = true; |
| 916 return connected_; | 919 return connected_; |
| 917 } | 920 } |
| 918 | 921 |
| 919 bool QuicConnection::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { | 922 bool QuicConnection::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { |
| 920 DCHECK(connected_); | 923 DCHECK(connected_); |
| 921 if (debug_visitor_ != nullptr) { | 924 if (debug_visitor_ != nullptr) { |
| 922 debug_visitor_->OnWindowUpdateFrame(frame); | 925 debug_visitor_->OnWindowUpdateFrame(frame); |
| 923 } | 926 } |
| 924 DVLOG(1) << ENDPOINT | 927 DVLOG(1) << ENDPOINT |
| 925 << "WINDOW_UPDATE_FRAME received for stream: " << frame.stream_id | 928 << "WINDOW_UPDATE_FRAME received for stream: " << frame.stream_id |
| 926 << " with byte offset: " << frame.byte_offset; | 929 << " with byte offset: " << frame.byte_offset; |
| 927 visitor_->OnWindowUpdateFrame(frame); | 930 visitor_->OnWindowUpdateFrame(frame); |
| 931 visitor_->PostProcessAfterData(); |
| 928 should_last_packet_instigate_acks_ = true; | 932 should_last_packet_instigate_acks_ = true; |
| 929 return connected_; | 933 return connected_; |
| 930 } | 934 } |
| 931 | 935 |
| 932 bool QuicConnection::OnBlockedFrame(const QuicBlockedFrame& frame) { | 936 bool QuicConnection::OnBlockedFrame(const QuicBlockedFrame& frame) { |
| 933 DCHECK(connected_); | 937 DCHECK(connected_); |
| 934 if (debug_visitor_ != nullptr) { | 938 if (debug_visitor_ != nullptr) { |
| 935 debug_visitor_->OnBlockedFrame(frame); | 939 debug_visitor_->OnBlockedFrame(frame); |
| 936 } | 940 } |
| 937 DVLOG(1) << ENDPOINT | 941 DVLOG(1) << ENDPOINT |
| 938 << "BLOCKED_FRAME received for stream: " << frame.stream_id; | 942 << "BLOCKED_FRAME received for stream: " << frame.stream_id; |
| 939 visitor_->OnBlockedFrame(frame); | 943 visitor_->OnBlockedFrame(frame); |
| 944 visitor_->PostProcessAfterData(); |
| 940 should_last_packet_instigate_acks_ = true; | 945 should_last_packet_instigate_acks_ = true; |
| 941 return connected_; | 946 return connected_; |
| 942 } | 947 } |
| 943 | 948 |
| 944 bool QuicConnection::OnPathCloseFrame(const QuicPathCloseFrame& frame) { | 949 bool QuicConnection::OnPathCloseFrame(const QuicPathCloseFrame& frame) { |
| 945 DCHECK(connected_); | 950 DCHECK(connected_); |
| 946 if (debug_visitor_ != nullptr) { | 951 if (debug_visitor_ != nullptr) { |
| 947 debug_visitor_->OnPathCloseFrame(frame); | 952 debug_visitor_->OnPathCloseFrame(frame); |
| 948 } | 953 } |
| 949 DVLOG(1) << ENDPOINT | 954 DVLOG(1) << ENDPOINT |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 // or the congestion manager to prohibit sending. If we've sent everything | 1330 // or the congestion manager to prohibit sending. If we've sent everything |
| 1326 // we had queued and we're still not blocked, let the visitor know it can | 1331 // we had queued and we're still not blocked, let the visitor know it can |
| 1327 // write more. | 1332 // write more. |
| 1328 if (!CanWrite(HAS_RETRANSMITTABLE_DATA)) { | 1333 if (!CanWrite(HAS_RETRANSMITTABLE_DATA)) { |
| 1329 return; | 1334 return; |
| 1330 } | 1335 } |
| 1331 | 1336 |
| 1332 { // Limit the scope of the bundler. ACK inclusion happens elsewhere. | 1337 { // Limit the scope of the bundler. ACK inclusion happens elsewhere. |
| 1333 ScopedPacketBundler bundler(this, NO_ACK); | 1338 ScopedPacketBundler bundler(this, NO_ACK); |
| 1334 visitor_->OnCanWrite(); | 1339 visitor_->OnCanWrite(); |
| 1340 visitor_->PostProcessAfterData(); |
| 1335 } | 1341 } |
| 1336 | 1342 |
| 1337 // After the visitor writes, it may have caused the socket to become write | 1343 // After the visitor writes, it may have caused the socket to become write |
| 1338 // blocked or the congestion manager to prohibit sending, so check again. | 1344 // blocked or the congestion manager to prohibit sending, so check again. |
| 1339 if (visitor_->WillingAndAbleToWrite() && !resume_writes_alarm_->IsSet() && | 1345 if (visitor_->WillingAndAbleToWrite() && !resume_writes_alarm_->IsSet() && |
| 1340 CanWrite(HAS_RETRANSMITTABLE_DATA)) { | 1346 CanWrite(HAS_RETRANSMITTABLE_DATA)) { |
| 1341 // We're not write blocked, but some stream didn't write out all of its | 1347 // We're not write blocked, but some stream didn't write out all of its |
| 1342 // bytes. Register for 'immediate' resumption so we'll keep writing after | 1348 // bytes. Register for 'immediate' resumption so we'll keep writing after |
| 1343 // other connections and events have had a chance to use the thread. | 1349 // other connections and events have had a chance to use the thread. |
| 1344 resume_writes_alarm_->Set(clock_->ApproximateNow()); | 1350 resume_writes_alarm_->Set(clock_->ApproximateNow()); |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2448 void QuicConnection::OnPathClosed(QuicPathId path_id) { | 2454 void QuicConnection::OnPathClosed(QuicPathId path_id) { |
| 2449 // Stop receiving packets on this path. | 2455 // Stop receiving packets on this path. |
| 2450 framer_.OnPathClosed(path_id); | 2456 framer_.OnPathClosed(path_id); |
| 2451 } | 2457 } |
| 2452 | 2458 |
| 2453 bool QuicConnection::ack_frame_updated() const { | 2459 bool QuicConnection::ack_frame_updated() const { |
| 2454 return received_packet_manager_.ack_frame_updated(); | 2460 return received_packet_manager_.ack_frame_updated(); |
| 2455 } | 2461 } |
| 2456 | 2462 |
| 2457 } // namespace net | 2463 } // namespace net |
| OLD | NEW |