| 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/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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 ack_queued_(false), | 224 ack_queued_(false), |
| 225 num_retransmittable_packets_received_since_last_ack_sent_(0), | 225 num_retransmittable_packets_received_since_last_ack_sent_(0), |
| 226 last_ack_had_missing_packets_(false), | 226 last_ack_had_missing_packets_(false), |
| 227 num_packets_received_since_last_ack_sent_(0), | 227 num_packets_received_since_last_ack_sent_(0), |
| 228 stop_waiting_count_(0), | 228 stop_waiting_count_(0), |
| 229 ack_mode_(TCP_ACKING), | 229 ack_mode_(TCP_ACKING), |
| 230 ack_decimation_delay_(kAckDecimationDelay), | 230 ack_decimation_delay_(kAckDecimationDelay), |
| 231 delay_setting_retransmission_alarm_(false), | 231 delay_setting_retransmission_alarm_(false), |
| 232 pending_retransmission_alarm_(false), | 232 pending_retransmission_alarm_(false), |
| 233 defer_send_in_response_to_packets_(false), | 233 defer_send_in_response_to_packets_(false), |
| 234 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), |
| 234 arena_(), | 235 arena_(), |
| 235 ack_alarm_(alarm_factory_->CreateAlarm(arena_.New<AckAlarmDelegate>(this), | 236 ack_alarm_(alarm_factory_->CreateAlarm(arena_.New<AckAlarmDelegate>(this), |
| 236 &arena_)), | 237 &arena_)), |
| 237 retransmission_alarm_(alarm_factory_->CreateAlarm( | 238 retransmission_alarm_(alarm_factory_->CreateAlarm( |
| 238 arena_.New<RetransmissionAlarmDelegate>(this), | 239 arena_.New<RetransmissionAlarmDelegate>(this), |
| 239 &arena_)), | 240 &arena_)), |
| 240 send_alarm_( | 241 send_alarm_( |
| 241 alarm_factory_->CreateAlarm(arena_.New<SendAlarmDelegate>(this), | 242 alarm_factory_->CreateAlarm(arena_.New<SendAlarmDelegate>(this), |
| 242 &arena_)), | 243 &arena_)), |
| 243 resume_writes_alarm_( | 244 resume_writes_alarm_( |
| (...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2220 void QuicConnection::SetPingAlarm() { | 2221 void QuicConnection::SetPingAlarm() { |
| 2221 if (perspective_ == Perspective::IS_SERVER) { | 2222 if (perspective_ == Perspective::IS_SERVER) { |
| 2222 // Only clients send pings. | 2223 // Only clients send pings. |
| 2223 return; | 2224 return; |
| 2224 } | 2225 } |
| 2225 if (!visitor_->HasOpenDynamicStreams()) { | 2226 if (!visitor_->HasOpenDynamicStreams()) { |
| 2226 ping_alarm_->Cancel(); | 2227 ping_alarm_->Cancel(); |
| 2227 // Don't send a ping unless there are open streams. | 2228 // Don't send a ping unless there are open streams. |
| 2228 return; | 2229 return; |
| 2229 } | 2230 } |
| 2230 QuicTime::Delta ping_timeout = QuicTime::Delta::FromSeconds(kPingTimeoutSecs); | 2231 ping_alarm_->Update(clock_->ApproximateNow() + ping_timeout_, |
| 2231 ping_alarm_->Update(clock_->ApproximateNow() + ping_timeout, | |
| 2232 QuicTime::Delta::FromSeconds(1)); | 2232 QuicTime::Delta::FromSeconds(1)); |
| 2233 } | 2233 } |
| 2234 | 2234 |
| 2235 void QuicConnection::SetRetransmissionAlarm() { | 2235 void QuicConnection::SetRetransmissionAlarm() { |
| 2236 if (delay_setting_retransmission_alarm_) { | 2236 if (delay_setting_retransmission_alarm_) { |
| 2237 pending_retransmission_alarm_ = true; | 2237 pending_retransmission_alarm_ = true; |
| 2238 return; | 2238 return; |
| 2239 } | 2239 } |
| 2240 QuicTime retransmission_time = sent_packet_manager_->GetRetransmissionTime(); | 2240 QuicTime retransmission_time = sent_packet_manager_->GetRetransmissionTime(); |
| 2241 retransmission_alarm_->Update(retransmission_time, | 2241 retransmission_alarm_->Update(retransmission_time, |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2538 | 2538 |
| 2539 void QuicConnection::CheckIfApplicationLimited() { | 2539 void QuicConnection::CheckIfApplicationLimited() { |
| 2540 if (queued_packets_.empty() && | 2540 if (queued_packets_.empty() && |
| 2541 !sent_packet_manager_->HasPendingRetransmissions() && | 2541 !sent_packet_manager_->HasPendingRetransmissions() && |
| 2542 !visitor_->WillingAndAbleToWrite()) { | 2542 !visitor_->WillingAndAbleToWrite()) { |
| 2543 sent_packet_manager_->OnApplicationLimited(); | 2543 sent_packet_manager_->OnApplicationLimited(); |
| 2544 } | 2544 } |
| 2545 } | 2545 } |
| 2546 | 2546 |
| 2547 } // namespace net | 2547 } // namespace net |
| OLD | NEW |