| 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 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 pending_version_negotiation_packet_(false), | 213 pending_version_negotiation_packet_(false), |
| 214 received_packet_manager_(kTCP, &stats_), | 214 received_packet_manager_(kTCP, &stats_), |
| 215 ack_queued_(false), | 215 ack_queued_(false), |
| 216 stop_waiting_count_(0), | 216 stop_waiting_count_(0), |
| 217 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))), | 217 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))), |
| 218 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))), | 218 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))), |
| 219 send_alarm_(helper->CreateAlarm(new SendAlarm(this))), | 219 send_alarm_(helper->CreateAlarm(new SendAlarm(this))), |
| 220 resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))), | 220 resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))), |
| 221 timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))), | 221 timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))), |
| 222 ping_alarm_(helper->CreateAlarm(new PingAlarm(this))), | 222 ping_alarm_(helper->CreateAlarm(new PingAlarm(this))), |
| 223 debug_visitor_(NULL), | |
| 224 packet_generator_(connection_id_, &framer_, random_generator_, this), | 223 packet_generator_(connection_id_, &framer_, random_generator_, this), |
| 225 idle_network_timeout_( | 224 idle_network_timeout_( |
| 226 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)), | 225 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)), |
| 227 overall_connection_timeout_(QuicTime::Delta::Infinite()), | 226 overall_connection_timeout_(QuicTime::Delta::Infinite()), |
| 228 time_of_last_received_packet_(clock_->ApproximateNow()), | 227 time_of_last_received_packet_(clock_->ApproximateNow()), |
| 229 time_of_last_sent_new_packet_(clock_->ApproximateNow()), | 228 time_of_last_sent_new_packet_(clock_->ApproximateNow()), |
| 230 sequence_number_of_last_sent_packet_(0), | 229 sequence_number_of_last_sent_packet_(0), |
| 231 sent_packet_manager_( | 230 sent_packet_manager_( |
| 232 is_server, clock_, &stats_, kCubic, | 231 is_server, clock_, &stats_, kCubic, |
| 233 FLAGS_quic_use_time_loss_detection ? kTime : kNack), | 232 FLAGS_quic_use_time_loss_detection ? kTime : kNack), |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 last_window_update_frames_.empty() && | 301 last_window_update_frames_.empty() && |
| 303 last_blocked_frames_.empty() && | 302 last_blocked_frames_.empty() && |
| 304 last_rst_frames_.empty() && | 303 last_rst_frames_.empty() && |
| 305 last_ack_frames_.empty() && | 304 last_ack_frames_.empty() && |
| 306 last_congestion_frames_.empty() && | 305 last_congestion_frames_.empty() && |
| 307 last_stop_waiting_frames_.empty()); | 306 last_stop_waiting_frames_.empty()); |
| 308 } | 307 } |
| 309 | 308 |
| 310 void QuicConnection::OnPublicResetPacket( | 309 void QuicConnection::OnPublicResetPacket( |
| 311 const QuicPublicResetPacket& packet) { | 310 const QuicPublicResetPacket& packet) { |
| 312 if (debug_visitor_) { | 311 if (debug_visitor_.get() != NULL) { |
| 313 debug_visitor_->OnPublicResetPacket(packet); | 312 debug_visitor_->OnPublicResetPacket(packet); |
| 314 } | 313 } |
| 315 CloseConnection(QUIC_PUBLIC_RESET, true); | 314 CloseConnection(QUIC_PUBLIC_RESET, true); |
| 316 | 315 |
| 317 DVLOG(1) << ENDPOINT << "Connection " << connection_id() | 316 DVLOG(1) << ENDPOINT << "Connection " << connection_id() |
| 318 << " closed via QUIC_PUBLIC_RESET from peer."; | 317 << " closed via QUIC_PUBLIC_RESET from peer."; |
| 319 } | 318 } |
| 320 | 319 |
| 321 bool QuicConnection::OnProtocolVersionMismatch(QuicVersion received_version) { | 320 bool QuicConnection::OnProtocolVersionMismatch(QuicVersion received_version) { |
| 322 DVLOG(1) << ENDPOINT << "Received packet with mismatched version " | 321 DVLOG(1) << ENDPOINT << "Received packet with mismatched version " |
| 323 << received_version; | 322 << received_version; |
| 324 // TODO(satyamshekhar): Implement no server state in this mode. | 323 // TODO(satyamshekhar): Implement no server state in this mode. |
| 325 if (!is_server_) { | 324 if (!is_server_) { |
| 326 LOG(DFATAL) << ENDPOINT << "Framer called OnProtocolVersionMismatch. " | 325 LOG(DFATAL) << ENDPOINT << "Framer called OnProtocolVersionMismatch. " |
| 327 << "Closing connection."; | 326 << "Closing connection."; |
| 328 CloseConnection(QUIC_INTERNAL_ERROR, false); | 327 CloseConnection(QUIC_INTERNAL_ERROR, false); |
| 329 return false; | 328 return false; |
| 330 } | 329 } |
| 331 DCHECK_NE(version(), received_version); | 330 DCHECK_NE(version(), received_version); |
| 332 | 331 |
| 333 if (debug_visitor_) { | 332 if (debug_visitor_.get() != NULL) { |
| 334 debug_visitor_->OnProtocolVersionMismatch(received_version); | 333 debug_visitor_->OnProtocolVersionMismatch(received_version); |
| 335 } | 334 } |
| 336 | 335 |
| 337 switch (version_negotiation_state_) { | 336 switch (version_negotiation_state_) { |
| 338 case START_NEGOTIATION: | 337 case START_NEGOTIATION: |
| 339 if (!framer_.IsSupportedVersion(received_version)) { | 338 if (!framer_.IsSupportedVersion(received_version)) { |
| 340 SendVersionNegotiationPacket(); | 339 SendVersionNegotiationPacket(); |
| 341 version_negotiation_state_ = NEGOTIATION_IN_PROGRESS; | 340 version_negotiation_state_ = NEGOTIATION_IN_PROGRESS; |
| 342 return false; | 341 return false; |
| 343 } | 342 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 374 | 373 |
| 375 // Handles version negotiation for client connection. | 374 // Handles version negotiation for client connection. |
| 376 void QuicConnection::OnVersionNegotiationPacket( | 375 void QuicConnection::OnVersionNegotiationPacket( |
| 377 const QuicVersionNegotiationPacket& packet) { | 376 const QuicVersionNegotiationPacket& packet) { |
| 378 if (is_server_) { | 377 if (is_server_) { |
| 379 LOG(DFATAL) << ENDPOINT << "Framer parsed VersionNegotiationPacket." | 378 LOG(DFATAL) << ENDPOINT << "Framer parsed VersionNegotiationPacket." |
| 380 << " Closing connection."; | 379 << " Closing connection."; |
| 381 CloseConnection(QUIC_INTERNAL_ERROR, false); | 380 CloseConnection(QUIC_INTERNAL_ERROR, false); |
| 382 return; | 381 return; |
| 383 } | 382 } |
| 384 if (debug_visitor_) { | 383 if (debug_visitor_.get() != NULL) { |
| 385 debug_visitor_->OnVersionNegotiationPacket(packet); | 384 debug_visitor_->OnVersionNegotiationPacket(packet); |
| 386 } | 385 } |
| 387 | 386 |
| 388 if (version_negotiation_state_ != START_NEGOTIATION) { | 387 if (version_negotiation_state_ != START_NEGOTIATION) { |
| 389 // Possibly a duplicate version negotiation packet. | 388 // Possibly a duplicate version negotiation packet. |
| 390 return; | 389 return; |
| 391 } | 390 } |
| 392 | 391 |
| 393 if (std::find(packet.versions.begin(), | 392 if (std::find(packet.versions.begin(), |
| 394 packet.versions.end(), version()) != | 393 packet.versions.end(), version()) != |
| (...skipping 27 matching lines...) Expand all Loading... |
| 422 | 421 |
| 423 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) { | 422 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) { |
| 424 return true; | 423 return true; |
| 425 } | 424 } |
| 426 | 425 |
| 427 void QuicConnection::OnDecryptedPacket(EncryptionLevel level) { | 426 void QuicConnection::OnDecryptedPacket(EncryptionLevel level) { |
| 428 last_decrypted_packet_level_ = level; | 427 last_decrypted_packet_level_ = level; |
| 429 } | 428 } |
| 430 | 429 |
| 431 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { | 430 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { |
| 432 if (debug_visitor_) { | 431 if (debug_visitor_.get() != NULL) { |
| 433 debug_visitor_->OnPacketHeader(header); | 432 debug_visitor_->OnPacketHeader(header); |
| 434 } | 433 } |
| 435 | 434 |
| 436 if (!ProcessValidatedPacket()) { | 435 if (!ProcessValidatedPacket()) { |
| 437 return false; | 436 return false; |
| 438 } | 437 } |
| 439 | 438 |
| 440 // Will be decrement below if we fall through to return true; | 439 // Will be decrement below if we fall through to return true; |
| 441 ++stats_.packets_dropped; | 440 ++stats_.packets_dropped; |
| 442 | 441 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 DCHECK_EQ(IN_FEC_GROUP, last_header_.is_in_fec_group); | 504 DCHECK_EQ(IN_FEC_GROUP, last_header_.is_in_fec_group); |
| 506 DCHECK_NE(0u, last_header_.fec_group); | 505 DCHECK_NE(0u, last_header_.fec_group); |
| 507 QuicFecGroup* group = GetFecGroup(); | 506 QuicFecGroup* group = GetFecGroup(); |
| 508 if (group != NULL) { | 507 if (group != NULL) { |
| 509 group->Update(last_decrypted_packet_level_, last_header_, payload); | 508 group->Update(last_decrypted_packet_level_, last_header_, payload); |
| 510 } | 509 } |
| 511 } | 510 } |
| 512 | 511 |
| 513 bool QuicConnection::OnStreamFrame(const QuicStreamFrame& frame) { | 512 bool QuicConnection::OnStreamFrame(const QuicStreamFrame& frame) { |
| 514 DCHECK(connected_); | 513 DCHECK(connected_); |
| 515 if (debug_visitor_) { | 514 if (debug_visitor_.get() != NULL) { |
| 516 debug_visitor_->OnStreamFrame(frame); | 515 debug_visitor_->OnStreamFrame(frame); |
| 517 } | 516 } |
| 518 if (frame.stream_id != kCryptoStreamId && | 517 if (frame.stream_id != kCryptoStreamId && |
| 519 last_decrypted_packet_level_ == ENCRYPTION_NONE) { | 518 last_decrypted_packet_level_ == ENCRYPTION_NONE) { |
| 520 DLOG(WARNING) << ENDPOINT | 519 DLOG(WARNING) << ENDPOINT |
| 521 << "Received an unencrypted data frame: closing connection"; | 520 << "Received an unencrypted data frame: closing connection"; |
| 522 SendConnectionClose(QUIC_UNENCRYPTED_STREAM_DATA); | 521 SendConnectionClose(QUIC_UNENCRYPTED_STREAM_DATA); |
| 523 return false; | 522 return false; |
| 524 } | 523 } |
| 525 last_stream_frames_.push_back(frame); | 524 last_stream_frames_.push_back(frame); |
| 526 return true; | 525 return true; |
| 527 } | 526 } |
| 528 | 527 |
| 529 bool QuicConnection::OnAckFrame(const QuicAckFrame& incoming_ack) { | 528 bool QuicConnection::OnAckFrame(const QuicAckFrame& incoming_ack) { |
| 530 DCHECK(connected_); | 529 DCHECK(connected_); |
| 531 if (debug_visitor_) { | 530 if (debug_visitor_.get() != NULL) { |
| 532 debug_visitor_->OnAckFrame(incoming_ack); | 531 debug_visitor_->OnAckFrame(incoming_ack); |
| 533 } | 532 } |
| 534 DVLOG(1) << ENDPOINT << "OnAckFrame: " << incoming_ack; | 533 DVLOG(1) << ENDPOINT << "OnAckFrame: " << incoming_ack; |
| 535 | 534 |
| 536 if (last_header_.packet_sequence_number <= largest_seen_packet_with_ack_) { | 535 if (last_header_.packet_sequence_number <= largest_seen_packet_with_ack_) { |
| 537 DVLOG(1) << ENDPOINT << "Received an old ack frame: ignoring"; | 536 DVLOG(1) << ENDPOINT << "Received an old ack frame: ignoring"; |
| 538 return true; | 537 return true; |
| 539 } | 538 } |
| 540 | 539 |
| 541 if (!ValidateAckFrame(incoming_ack)) { | 540 if (!ValidateAckFrame(incoming_ack)) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 const QuicStopWaitingFrame& stop_waiting) { | 573 const QuicStopWaitingFrame& stop_waiting) { |
| 575 largest_seen_packet_with_stop_waiting_ = last_header_.packet_sequence_number; | 574 largest_seen_packet_with_stop_waiting_ = last_header_.packet_sequence_number; |
| 576 received_packet_manager_.UpdatePacketInformationSentByPeer(stop_waiting); | 575 received_packet_manager_.UpdatePacketInformationSentByPeer(stop_waiting); |
| 577 // Possibly close any FecGroups which are now irrelevant. | 576 // Possibly close any FecGroups which are now irrelevant. |
| 578 CloseFecGroupsBefore(stop_waiting.least_unacked + 1); | 577 CloseFecGroupsBefore(stop_waiting.least_unacked + 1); |
| 579 } | 578 } |
| 580 | 579 |
| 581 bool QuicConnection::OnCongestionFeedbackFrame( | 580 bool QuicConnection::OnCongestionFeedbackFrame( |
| 582 const QuicCongestionFeedbackFrame& feedback) { | 581 const QuicCongestionFeedbackFrame& feedback) { |
| 583 DCHECK(connected_); | 582 DCHECK(connected_); |
| 584 if (debug_visitor_) { | 583 if (debug_visitor_.get() != NULL) { |
| 585 debug_visitor_->OnCongestionFeedbackFrame(feedback); | 584 debug_visitor_->OnCongestionFeedbackFrame(feedback); |
| 586 } | 585 } |
| 587 last_congestion_frames_.push_back(feedback); | 586 last_congestion_frames_.push_back(feedback); |
| 588 return connected_; | 587 return connected_; |
| 589 } | 588 } |
| 590 | 589 |
| 591 bool QuicConnection::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) { | 590 bool QuicConnection::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) { |
| 592 DCHECK(connected_); | 591 DCHECK(connected_); |
| 593 | 592 |
| 594 if (last_header_.packet_sequence_number <= | 593 if (last_header_.packet_sequence_number <= |
| 595 largest_seen_packet_with_stop_waiting_) { | 594 largest_seen_packet_with_stop_waiting_) { |
| 596 DVLOG(1) << ENDPOINT << "Received an old stop waiting frame: ignoring"; | 595 DVLOG(1) << ENDPOINT << "Received an old stop waiting frame: ignoring"; |
| 597 return true; | 596 return true; |
| 598 } | 597 } |
| 599 | 598 |
| 600 if (!ValidateStopWaitingFrame(frame)) { | 599 if (!ValidateStopWaitingFrame(frame)) { |
| 601 SendConnectionClose(QUIC_INVALID_STOP_WAITING_DATA); | 600 SendConnectionClose(QUIC_INVALID_STOP_WAITING_DATA); |
| 602 return false; | 601 return false; |
| 603 } | 602 } |
| 604 | 603 |
| 605 if (debug_visitor_) { | 604 if (debug_visitor_.get() != NULL) { |
| 606 debug_visitor_->OnStopWaitingFrame(frame); | 605 debug_visitor_->OnStopWaitingFrame(frame); |
| 607 } | 606 } |
| 608 | 607 |
| 609 last_stop_waiting_frames_.push_back(frame); | 608 last_stop_waiting_frames_.push_back(frame); |
| 610 return connected_; | 609 return connected_; |
| 611 } | 610 } |
| 612 | 611 |
| 613 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) { | 612 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) { |
| 614 DCHECK(connected_); | 613 DCHECK(connected_); |
| 615 if (debug_visitor_) { | 614 if (debug_visitor_.get() != NULL) { |
| 616 debug_visitor_->OnPingFrame(frame); | 615 debug_visitor_->OnPingFrame(frame); |
| 617 } | 616 } |
| 618 return true; | 617 return true; |
| 619 } | 618 } |
| 620 | 619 |
| 621 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { | 620 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { |
| 622 if (incoming_ack.largest_observed > packet_generator_.sequence_number()) { | 621 if (incoming_ack.largest_observed > packet_generator_.sequence_number()) { |
| 623 DLOG(ERROR) << ENDPOINT << "Peer's observed unsent packet:" | 622 DLOG(ERROR) << ENDPOINT << "Peer's observed unsent packet:" |
| 624 << incoming_ack.largest_observed << " vs " | 623 << incoming_ack.largest_observed << " vs " |
| 625 << packet_generator_.sequence_number(); | 624 << packet_generator_.sequence_number(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 DCHECK_NE(0u, last_header_.fec_group); | 703 DCHECK_NE(0u, last_header_.fec_group); |
| 705 QuicFecGroup* group = GetFecGroup(); | 704 QuicFecGroup* group = GetFecGroup(); |
| 706 if (group != NULL) { | 705 if (group != NULL) { |
| 707 group->UpdateFec(last_decrypted_packet_level_, | 706 group->UpdateFec(last_decrypted_packet_level_, |
| 708 last_header_.packet_sequence_number, fec); | 707 last_header_.packet_sequence_number, fec); |
| 709 } | 708 } |
| 710 } | 709 } |
| 711 | 710 |
| 712 bool QuicConnection::OnRstStreamFrame(const QuicRstStreamFrame& frame) { | 711 bool QuicConnection::OnRstStreamFrame(const QuicRstStreamFrame& frame) { |
| 713 DCHECK(connected_); | 712 DCHECK(connected_); |
| 714 if (debug_visitor_) { | 713 if (debug_visitor_.get() != NULL) { |
| 715 debug_visitor_->OnRstStreamFrame(frame); | 714 debug_visitor_->OnRstStreamFrame(frame); |
| 716 } | 715 } |
| 717 DVLOG(1) << ENDPOINT << "Stream reset with error " | 716 DVLOG(1) << ENDPOINT << "Stream reset with error " |
| 718 << QuicUtils::StreamErrorToString(frame.error_code); | 717 << QuicUtils::StreamErrorToString(frame.error_code); |
| 719 last_rst_frames_.push_back(frame); | 718 last_rst_frames_.push_back(frame); |
| 720 return connected_; | 719 return connected_; |
| 721 } | 720 } |
| 722 | 721 |
| 723 bool QuicConnection::OnConnectionCloseFrame( | 722 bool QuicConnection::OnConnectionCloseFrame( |
| 724 const QuicConnectionCloseFrame& frame) { | 723 const QuicConnectionCloseFrame& frame) { |
| 725 DCHECK(connected_); | 724 DCHECK(connected_); |
| 726 if (debug_visitor_) { | 725 if (debug_visitor_.get() != NULL) { |
| 727 debug_visitor_->OnConnectionCloseFrame(frame); | 726 debug_visitor_->OnConnectionCloseFrame(frame); |
| 728 } | 727 } |
| 729 DVLOG(1) << ENDPOINT << "Connection " << connection_id() | 728 DVLOG(1) << ENDPOINT << "Connection " << connection_id() |
| 730 << " closed with error " | 729 << " closed with error " |
| 731 << QuicUtils::ErrorToString(frame.error_code) | 730 << QuicUtils::ErrorToString(frame.error_code) |
| 732 << " " << frame.error_details; | 731 << " " << frame.error_details; |
| 733 last_close_frames_.push_back(frame); | 732 last_close_frames_.push_back(frame); |
| 734 return connected_; | 733 return connected_; |
| 735 } | 734 } |
| 736 | 735 |
| 737 bool QuicConnection::OnGoAwayFrame(const QuicGoAwayFrame& frame) { | 736 bool QuicConnection::OnGoAwayFrame(const QuicGoAwayFrame& frame) { |
| 738 DCHECK(connected_); | 737 DCHECK(connected_); |
| 739 if (debug_visitor_) { | 738 if (debug_visitor_.get() != NULL) { |
| 740 debug_visitor_->OnGoAwayFrame(frame); | 739 debug_visitor_->OnGoAwayFrame(frame); |
| 741 } | 740 } |
| 742 DVLOG(1) << ENDPOINT << "Go away received with error " | 741 DVLOG(1) << ENDPOINT << "Go away received with error " |
| 743 << QuicUtils::ErrorToString(frame.error_code) | 742 << QuicUtils::ErrorToString(frame.error_code) |
| 744 << " and reason:" << frame.reason_phrase; | 743 << " and reason:" << frame.reason_phrase; |
| 745 last_goaway_frames_.push_back(frame); | 744 last_goaway_frames_.push_back(frame); |
| 746 return connected_; | 745 return connected_; |
| 747 } | 746 } |
| 748 | 747 |
| 749 bool QuicConnection::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { | 748 bool QuicConnection::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { |
| 750 DCHECK(connected_); | 749 DCHECK(connected_); |
| 751 if (debug_visitor_) { | 750 if (debug_visitor_.get() != NULL) { |
| 752 debug_visitor_->OnWindowUpdateFrame(frame); | 751 debug_visitor_->OnWindowUpdateFrame(frame); |
| 753 } | 752 } |
| 754 DVLOG(1) << ENDPOINT << "WindowUpdate received for stream: " | 753 DVLOG(1) << ENDPOINT << "WindowUpdate received for stream: " |
| 755 << frame.stream_id << " with byte offset: " << frame.byte_offset; | 754 << frame.stream_id << " with byte offset: " << frame.byte_offset; |
| 756 last_window_update_frames_.push_back(frame); | 755 last_window_update_frames_.push_back(frame); |
| 757 return connected_; | 756 return connected_; |
| 758 } | 757 } |
| 759 | 758 |
| 760 bool QuicConnection::OnBlockedFrame(const QuicBlockedFrame& frame) { | 759 bool QuicConnection::OnBlockedFrame(const QuicBlockedFrame& frame) { |
| 761 DCHECK(connected_); | 760 DCHECK(connected_); |
| 762 if (debug_visitor_) { | 761 if (debug_visitor_.get() != NULL) { |
| 763 debug_visitor_->OnBlockedFrame(frame); | 762 debug_visitor_->OnBlockedFrame(frame); |
| 764 } | 763 } |
| 765 DVLOG(1) << ENDPOINT << "Blocked frame received for stream: " | 764 DVLOG(1) << ENDPOINT << "Blocked frame received for stream: " |
| 766 << frame.stream_id; | 765 << frame.stream_id; |
| 767 last_blocked_frames_.push_back(frame); | 766 last_blocked_frames_.push_back(frame); |
| 768 return connected_; | 767 return connected_; |
| 769 } | 768 } |
| 770 | 769 |
| 771 void QuicConnection::OnPacketComplete() { | 770 void QuicConnection::OnPacketComplete() { |
| 772 // Don't do anything if this packet closed the connection. | 771 // Don't do anything if this packet closed the connection. |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 stats_.max_packet_size = packet_generator_.max_packet_length(); | 1066 stats_.max_packet_size = packet_generator_.max_packet_length(); |
| 1068 return stats_; | 1067 return stats_; |
| 1069 } | 1068 } |
| 1070 | 1069 |
| 1071 void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, | 1070 void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, |
| 1072 const IPEndPoint& peer_address, | 1071 const IPEndPoint& peer_address, |
| 1073 const QuicEncryptedPacket& packet) { | 1072 const QuicEncryptedPacket& packet) { |
| 1074 if (!connected_) { | 1073 if (!connected_) { |
| 1075 return; | 1074 return; |
| 1076 } | 1075 } |
| 1077 if (debug_visitor_) { | 1076 if (debug_visitor_.get() != NULL) { |
| 1078 debug_visitor_->OnPacketReceived(self_address, peer_address, packet); | 1077 debug_visitor_->OnPacketReceived(self_address, peer_address, packet); |
| 1079 } | 1078 } |
| 1080 last_packet_revived_ = false; | 1079 last_packet_revived_ = false; |
| 1081 last_size_ = packet.length(); | 1080 last_size_ = packet.length(); |
| 1082 | 1081 |
| 1083 CheckForAddressMigration(self_address, peer_address); | 1082 CheckForAddressMigration(self_address, peer_address); |
| 1084 | 1083 |
| 1085 stats_.bytes_received += packet.length(); | 1084 stats_.bytes_received += packet.length(); |
| 1086 ++stats_.packets_received; | 1085 ++stats_.packets_received; |
| 1087 | 1086 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 // Flush the packet generator before making a new packet. | 1238 // Flush the packet generator before making a new packet. |
| 1240 // TODO(ianswett): Implement ReserializeAllFrames as a separate path that | 1239 // TODO(ianswett): Implement ReserializeAllFrames as a separate path that |
| 1241 // does not require the creator to be flushed. | 1240 // does not require the creator to be flushed. |
| 1242 packet_generator_.FlushAllQueuedFrames(); | 1241 packet_generator_.FlushAllQueuedFrames(); |
| 1243 SerializedPacket serialized_packet = packet_generator_.ReserializeAllFrames( | 1242 SerializedPacket serialized_packet = packet_generator_.ReserializeAllFrames( |
| 1244 pending.retransmittable_frames.frames(), | 1243 pending.retransmittable_frames.frames(), |
| 1245 pending.sequence_number_length); | 1244 pending.sequence_number_length); |
| 1246 | 1245 |
| 1247 DVLOG(1) << ENDPOINT << "Retransmitting " << pending.sequence_number | 1246 DVLOG(1) << ENDPOINT << "Retransmitting " << pending.sequence_number |
| 1248 << " as " << serialized_packet.sequence_number; | 1247 << " as " << serialized_packet.sequence_number; |
| 1249 if (debug_visitor_) { | 1248 if (debug_visitor_.get() != NULL) { |
| 1250 debug_visitor_->OnPacketRetransmitted( | 1249 debug_visitor_->OnPacketRetransmitted( |
| 1251 pending.sequence_number, serialized_packet.sequence_number); | 1250 pending.sequence_number, serialized_packet.sequence_number); |
| 1252 } | 1251 } |
| 1253 sent_packet_manager_.OnRetransmittedPacket( | 1252 sent_packet_manager_.OnRetransmittedPacket( |
| 1254 pending.sequence_number, | 1253 pending.sequence_number, |
| 1255 serialized_packet.sequence_number); | 1254 serialized_packet.sequence_number); |
| 1256 | 1255 |
| 1257 SendOrQueuePacket(pending.retransmittable_frames.encryption_level(), | 1256 SendOrQueuePacket(pending.retransmittable_frames.encryption_level(), |
| 1258 serialized_packet, | 1257 serialized_packet, |
| 1259 pending.transmission_type); | 1258 pending.transmission_type); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1388 DCHECK(pending_write_.get() == NULL); | 1387 DCHECK(pending_write_.get() == NULL); |
| 1389 pending_write_.reset(new QueuedPacket(packet)); | 1388 pending_write_.reset(new QueuedPacket(packet)); |
| 1390 | 1389 |
| 1391 WriteResult result = writer_->WritePacket(encrypted->data(), | 1390 WriteResult result = writer_->WritePacket(encrypted->data(), |
| 1392 encrypted->length(), | 1391 encrypted->length(), |
| 1393 self_address().address(), | 1392 self_address().address(), |
| 1394 peer_address()); | 1393 peer_address()); |
| 1395 if (result.error_code == ERR_IO_PENDING) { | 1394 if (result.error_code == ERR_IO_PENDING) { |
| 1396 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); | 1395 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); |
| 1397 } | 1396 } |
| 1398 if (debug_visitor_) { | 1397 if (debug_visitor_.get() != NULL) { |
| 1399 // Pass the write result to the visitor. | 1398 // Pass the write result to the visitor. |
| 1400 debug_visitor_->OnPacketSent(sequence_number, | 1399 debug_visitor_->OnPacketSent(sequence_number, |
| 1401 packet.encryption_level, | 1400 packet.encryption_level, |
| 1402 packet.transmission_type, | 1401 packet.transmission_type, |
| 1403 *encrypted, | 1402 *encrypted, |
| 1404 result); | 1403 result); |
| 1405 } | 1404 } |
| 1406 if (result.status == WRITE_STATUS_BLOCKED) { | 1405 if (result.status == WRITE_STATUS_BLOCKED) { |
| 1407 visitor_->OnWriteBlocked(); | 1406 visitor_->OnWriteBlocked(); |
| 1408 // If the socket buffers the the data, then the packet should not | 1407 // If the socket buffers the the data, then the packet should not |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 last_header_.public_header.sequence_number_length; | 1708 last_header_.public_header.sequence_number_length; |
| 1710 revived_header.fec_flag = false; | 1709 revived_header.fec_flag = false; |
| 1711 revived_header.is_in_fec_group = NOT_IN_FEC_GROUP; | 1710 revived_header.is_in_fec_group = NOT_IN_FEC_GROUP; |
| 1712 revived_header.fec_group = 0; | 1711 revived_header.fec_group = 0; |
| 1713 group_map_.erase(last_header_.fec_group); | 1712 group_map_.erase(last_header_.fec_group); |
| 1714 last_decrypted_packet_level_ = group->effective_encryption_level(); | 1713 last_decrypted_packet_level_ = group->effective_encryption_level(); |
| 1715 DCHECK_LT(last_decrypted_packet_level_, NUM_ENCRYPTION_LEVELS); | 1714 DCHECK_LT(last_decrypted_packet_level_, NUM_ENCRYPTION_LEVELS); |
| 1716 delete group; | 1715 delete group; |
| 1717 | 1716 |
| 1718 last_packet_revived_ = true; | 1717 last_packet_revived_ = true; |
| 1719 if (debug_visitor_) { | 1718 if (debug_visitor_.get() != NULL) { |
| 1720 debug_visitor_->OnRevivedPacket(revived_header, | 1719 debug_visitor_->OnRevivedPacket(revived_header, |
| 1721 StringPiece(revived_payload, len)); | 1720 StringPiece(revived_payload, len)); |
| 1722 } | 1721 } |
| 1723 | 1722 |
| 1724 ++stats_.packets_revived; | 1723 ++stats_.packets_revived; |
| 1725 framer_.ProcessRevivedPacket(&revived_header, | 1724 framer_.ProcessRevivedPacket(&revived_header, |
| 1726 StringPiece(revived_payload, len)); | 1725 StringPiece(revived_payload, len)); |
| 1727 } | 1726 } |
| 1728 | 1727 |
| 1729 QuicFecGroup* QuicConnection::GetFecGroup() { | 1728 QuicFecGroup* QuicConnection::GetFecGroup() { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1971 // If we changed the generator's batch state, restore original batch state. | 1970 // If we changed the generator's batch state, restore original batch state. |
| 1972 if (!already_in_batch_mode_) { | 1971 if (!already_in_batch_mode_) { |
| 1973 DVLOG(1) << "Leaving Batch Mode."; | 1972 DVLOG(1) << "Leaving Batch Mode."; |
| 1974 connection_->packet_generator_.FinishBatchOperations(); | 1973 connection_->packet_generator_.FinishBatchOperations(); |
| 1975 } | 1974 } |
| 1976 DCHECK_EQ(already_in_batch_mode_, | 1975 DCHECK_EQ(already_in_batch_mode_, |
| 1977 connection_->packet_generator_.InBatchMode()); | 1976 connection_->packet_generator_.InBatchMode()); |
| 1978 } | 1977 } |
| 1979 | 1978 |
| 1980 } // namespace net | 1979 } // namespace net |
| OLD | NEW |