| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 ping_alarm_(helper->CreateAlarm(new PingAlarm(this))), | 220 ping_alarm_(helper->CreateAlarm(new PingAlarm(this))), |
| 221 debug_visitor_(NULL), | 221 debug_visitor_(NULL), |
| 222 packet_generator_(connection_id_, &framer_, random_generator_, this), | 222 packet_generator_(connection_id_, &framer_, random_generator_, this), |
| 223 idle_network_timeout_( | 223 idle_network_timeout_( |
| 224 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)), | 224 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)), |
| 225 overall_connection_timeout_(QuicTime::Delta::Infinite()), | 225 overall_connection_timeout_(QuicTime::Delta::Infinite()), |
| 226 time_of_last_received_packet_(clock_->ApproximateNow()), | 226 time_of_last_received_packet_(clock_->ApproximateNow()), |
| 227 time_of_last_sent_new_packet_(clock_->ApproximateNow()), | 227 time_of_last_sent_new_packet_(clock_->ApproximateNow()), |
| 228 sequence_number_of_last_sent_packet_(0), | 228 sequence_number_of_last_sent_packet_(0), |
| 229 sent_packet_manager_( | 229 sent_packet_manager_( |
| 230 is_server, clock_, &stats_, kTCP, | 230 is_server, clock_, &stats_, kCubic, |
| 231 FLAGS_quic_use_time_loss_detection ? kTime : kNack), | 231 FLAGS_quic_use_time_loss_detection ? kTime : kNack), |
| 232 version_negotiation_state_(START_NEGOTIATION), | 232 version_negotiation_state_(START_NEGOTIATION), |
| 233 is_server_(is_server), | 233 is_server_(is_server), |
| 234 connected_(true), | 234 connected_(true), |
| 235 peer_ip_changed_(false), | 235 peer_ip_changed_(false), |
| 236 peer_port_changed_(false), | 236 peer_port_changed_(false), |
| 237 self_ip_changed_(false), | 237 self_ip_changed_(false), |
| 238 self_port_changed_(false) { | 238 self_port_changed_(false) { |
| 239 if (!is_server_) { | 239 if (!is_server_) { |
| 240 // Pacing will be enabled if the client negotiates it. | 240 // Pacing will be enabled if the client negotiates it. |
| 241 sent_packet_manager_.MaybeEnablePacing(); | 241 sent_packet_manager_.MaybeEnablePacing(); |
| 242 } | 242 } |
| 243 DVLOG(1) << ENDPOINT << "Created connection with connection_id: " | 243 DVLOG(1) << ENDPOINT << "Created connection with connection_id: " |
| 244 << connection_id; | 244 << connection_id; |
| 245 timeout_alarm_->Set(clock_->ApproximateNow().Add(idle_network_timeout_)); | 245 timeout_alarm_->Set(clock_->ApproximateNow().Add(idle_network_timeout_)); |
| 246 framer_.set_visitor(this); | 246 framer_.set_visitor(this); |
| 247 framer_.set_received_entropy_calculator(&received_packet_manager_); | 247 framer_.set_received_entropy_calculator(&received_packet_manager_); |
| 248 stats_.connection_creation_time = clock_->ApproximateNow(); | 248 stats_.connection_creation_time = clock_->ApproximateNow(); |
| 249 sent_packet_manager_.set_network_change_visitor(&packet_generator_); |
| 249 } | 250 } |
| 250 | 251 |
| 251 QuicConnection::~QuicConnection() { | 252 QuicConnection::~QuicConnection() { |
| 252 STLDeleteElements(&undecryptable_packets_); | 253 STLDeleteElements(&undecryptable_packets_); |
| 253 STLDeleteValues(&group_map_); | 254 STLDeleteValues(&group_map_); |
| 254 for (QueuedPacketList::iterator it = queued_packets_.begin(); | 255 for (QueuedPacketList::iterator it = queued_packets_.begin(); |
| 255 it != queued_packets_.end(); ++it) { | 256 it != queued_packets_.end(); ++it) { |
| 256 delete it->packet; | 257 delete it->packet; |
| 257 } | 258 } |
| 258 } | 259 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 last_congestion_frames_.empty() && | 301 last_congestion_frames_.empty() && |
| 301 last_stop_waiting_frames_.empty()); | 302 last_stop_waiting_frames_.empty()); |
| 302 } | 303 } |
| 303 | 304 |
| 304 void QuicConnection::OnPublicResetPacket( | 305 void QuicConnection::OnPublicResetPacket( |
| 305 const QuicPublicResetPacket& packet) { | 306 const QuicPublicResetPacket& packet) { |
| 306 if (debug_visitor_) { | 307 if (debug_visitor_) { |
| 307 debug_visitor_->OnPublicResetPacket(packet); | 308 debug_visitor_->OnPublicResetPacket(packet); |
| 308 } | 309 } |
| 309 CloseConnection(QUIC_PUBLIC_RESET, true); | 310 CloseConnection(QUIC_PUBLIC_RESET, true); |
| 311 |
| 312 DVLOG(1) << ENDPOINT << "Connection " << connection_id() |
| 313 << " closed via QUIC_PUBLIC_RESET from peer."; |
| 310 } | 314 } |
| 311 | 315 |
| 312 bool QuicConnection::OnProtocolVersionMismatch(QuicVersion received_version) { | 316 bool QuicConnection::OnProtocolVersionMismatch(QuicVersion received_version) { |
| 313 DVLOG(1) << ENDPOINT << "Received packet with mismatched version " | 317 DVLOG(1) << ENDPOINT << "Received packet with mismatched version " |
| 314 << received_version; | 318 << received_version; |
| 315 // TODO(satyamshekhar): Implement no server state in this mode. | 319 // TODO(satyamshekhar): Implement no server state in this mode. |
| 316 if (!is_server_) { | 320 if (!is_server_) { |
| 317 LOG(DFATAL) << ENDPOINT << "Framer called OnProtocolVersionMismatch. " | 321 LOG(DFATAL) << ENDPOINT << "Framer called OnProtocolVersionMismatch. " |
| 318 << "Closing connection."; | 322 << "Closing connection."; |
| 319 CloseConnection(QUIC_INTERNAL_ERROR, false); | 323 CloseConnection(QUIC_INTERNAL_ERROR, false); |
| (...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 // If we changed the generator's batch state, restore original batch state. | 1982 // If we changed the generator's batch state, restore original batch state. |
| 1979 if (!already_in_batch_mode_) { | 1983 if (!already_in_batch_mode_) { |
| 1980 DVLOG(1) << "Leaving Batch Mode."; | 1984 DVLOG(1) << "Leaving Batch Mode."; |
| 1981 connection_->packet_generator_.FinishBatchOperations(); | 1985 connection_->packet_generator_.FinishBatchOperations(); |
| 1982 } | 1986 } |
| 1983 DCHECK_EQ(already_in_batch_mode_, | 1987 DCHECK_EQ(already_in_batch_mode_, |
| 1984 connection_->packet_generator_.InBatchMode()); | 1988 connection_->packet_generator_.InBatchMode()); |
| 1985 } | 1989 } |
| 1986 | 1990 |
| 1987 } // namespace net | 1991 } // namespace net |
| OLD | NEW |