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

Side by Side Diff: net/quic/quic_connection.h

Issue 14718011: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_client_session_test.cc ('k') | net/quic/quic_connection.cc » ('j') | 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 // The entity that handles framing writes for a Quic client or server. 5 // The entity that handles framing writes for a Quic client or server.
6 // Each QuicSession will have a connection associated with it. 6 // Each QuicSession will have a connection associated with it.
7 // 7 //
8 // On the server side, the Dispatcher handles the raw reads, and hands off 8 // On the server side, the Dispatcher handles the raw reads, and hands off
9 // packets via ProcessUdpPacket for framing and processing. 9 // packets via ProcessUdpPacket for framing and processing.
10 // 10 //
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // not actually writing it to the wire. 338 // not actually writing it to the wire.
339 bool ShouldSimulateLostPacket(); 339 bool ShouldSimulateLostPacket();
340 340
341 // Sets up a packet with an QuicAckFrame and sends it out. 341 // Sets up a packet with an QuicAckFrame and sends it out.
342 void SendAck(); 342 void SendAck();
343 343
344 // Called when an RTO fires. Returns the time when this alarm 344 // Called when an RTO fires. Returns the time when this alarm
345 // should next fire, or 0 if no retransmission alarm should be set. 345 // should next fire, or 0 if no retransmission alarm should be set.
346 QuicTime OnRetransmissionTimeout(); 346 QuicTime OnRetransmissionTimeout();
347 347
348 // Changes the encrypter used by |framer_| to |encrypter|. The function 348 // Changes the encrypter used for level |level| to |encrypter|. The function
349 // takes ownership of |encrypter|. 349 // takes ownership of |encrypter|.
350 void ChangeEncrypter(QuicEncrypter* encrypter); 350 void SetEncrypter(EncryptionLevel level, QuicEncrypter* encrypter);
351 const QuicEncrypter* encrypter(EncryptionLevel level) const;
351 352
352 // Sets the primary decrypter used by |framer_| to |decrypter|. The current 353 // SetDefaultEncryptionLevel sets the encryption level that will be applied
353 // primary decrypter becomes the backup decrypter. The function takes 354 // to new packets.
354 // ownership of |decrypter|. 355 void SetDefaultEncryptionLevel(EncryptionLevel level);
355 //
356 // After the function is called, |framer_| starts to decrypt packets using
357 // |decrypter|. If the decryption fails, |framer_| falls back on the backup
358 // decrypter. Eventually |framer_| determines that the backup decrypter is
359 // no longer needed and deletes it.
360 void PushDecrypter(QuicDecrypter* decrypter);
361 356
362 // Deletes the current primary decrypter and promotes the backup decrypter 357 // SetDecrypter sets the primary decrypter, replacing any that already exists,
363 // to be the primary decrypter. 358 // and takes ownership. If an alternative decrypter is in place then the
364 void PopDecrypter(); 359 // function DCHECKs. This is intended for cases where one knows that future
360 // packets will be using the new decrypter and the previous decrypter is now
361 // obsolete.
362 void SetDecrypter(QuicDecrypter* decrypter);
365 363
366 QuicDecrypter* decrypter() const { return framer_.decrypter(); } 364 // SetAlternativeDecrypter sets a decrypter that may be used to decrypt
367 QuicEncrypter* encrypter() const { return framer_.encrypter(); } 365 // future packets and takes ownership of it. If |latch_once_used| is true,
366 // then the first time that the decrypter is successful it will replace the
367 // primary decrypter. Otherwise both decrypters will remain active and the
368 // primary decrypter will be the one last used.
369 void SetAlternativeDecrypter(QuicDecrypter* decrypter,
370 bool latch_once_used);
371
372 const QuicDecrypter* decrypter() const;
373 const QuicDecrypter* alternative_decrypter() const;
368 374
369 protected: 375 protected:
370 // Deletes all missing packets before least unacked. The connection won't 376 // Deletes all missing packets before least unacked. The connection won't
371 // process any packets with sequence number before |least_unacked| that it 377 // process any packets with sequence number before |least_unacked| that it
372 // received after this call. Returns true if there were missing packets before 378 // received after this call. Returns true if there were missing packets before
373 // |least_unacked| unacked, false otherwise. 379 // |least_unacked| unacked, false otherwise.
374 bool DontWaitForPacketsBefore(QuicPacketSequenceNumber least_unacked); 380 bool DontWaitForPacketsBefore(QuicPacketSequenceNumber least_unacked);
375 381
376 // Send a packet to the peer. If |sequence_number| is present in the 382 // Send a packet to the peer using encryption |level|. If |sequence_number|
377 // |retransmission_map_|, then contents of this packet will be retransmitted 383 // is present in the |retransmission_map_|, then contents of this packet will
378 // with a new sequence number if it's not acked by the peer. Deletes 384 // be retransmitted with a new sequence number if it's not acked by the peer.
379 // |packet| via WritePacket call or transfers ownership to QueuedPacket, 385 // Deletes |packet| via WritePacket call or transfers ownership to
380 // ultimately deleted via WritePacket. Also, it updates the entropy map 386 // QueuedPacket, ultimately deleted via WritePacket. Also, it updates the
381 // corresponding to |sequence_number| using |entropy_hash|. 387 // entropy map corresponding to |sequence_number| using |entropy_hash|.
382 // TODO(wtc): none of the callers check the return value. 388 // TODO(wtc): none of the callers check the return value.
383 virtual bool SendOrQueuePacket(QuicPacketSequenceNumber sequence_number, 389 virtual bool SendOrQueuePacket(EncryptionLevel level,
390 QuicPacketSequenceNumber sequence_number,
384 QuicPacket* packet, 391 QuicPacket* packet,
385 QuicPacketEntropyHash entropy_hash, 392 QuicPacketEntropyHash entropy_hash,
386 HasRetransmittableData retransmittable); 393 HasRetransmittableData retransmittable);
387 394
388 // Writes the given packet to socket with the help of helper. Returns true on 395 // Writes the given packet to socket, encrypted with |level|, with the help
389 // successful write, false otherwise. However, behavior is undefined if 396 // of helper. Returns true on successful write, false otherwise. However,
390 // connection is not established or broken. In any circumstances, a return 397 // behavior is undefined if connection is not established or broken. In any
391 // value of true implies that |packet| has been deleted and should not be 398 // circumstances, a return value of true implies that |packet| has been
392 // accessed. If |sequence_number| is present in |retransmission_map_| it also 399 // deleted and should not be accessed. If |sequence_number| is present in
393 // sets up retransmission of the given packet in case of successful write. If 400 // |retransmission_map_| it also sets up retransmission of the given packet
394 // |force| is FORCE, then the packet will be sent immediately and the send 401 // in case of successful write. If |force| is FORCE, then the packet will be
395 // scheduler will not be consulted. 402 // sent immediately and the send scheduler will not be consulted.
396 bool WritePacket(QuicPacketSequenceNumber sequence_number, 403 bool WritePacket(EncryptionLevel level,
404 QuicPacketSequenceNumber sequence_number,
397 QuicPacket* packet, 405 QuicPacket* packet,
398 HasRetransmittableData retransmittable, 406 HasRetransmittableData retransmittable,
399 Force force); 407 Force force);
400 408
401 // Make sure an ack we got from our peer is sane. 409 // Make sure an ack we got from our peer is sane.
402 bool ValidateAckFrame(const QuicAckFrame& incoming_ack); 410 bool ValidateAckFrame(const QuicAckFrame& incoming_ack);
403 411
404 // These two are called by OnAckFrame to update the appropriate internal 412 // These two are called by OnAckFrame to update the appropriate internal
405 // state. 413 // state.
406 // 414 //
407 // Updates internal state based on incoming_ack.received_info 415 // Updates internal state based on incoming_ack.received_info
408 void UpdatePacketInformationReceivedByPeer( 416 void UpdatePacketInformationReceivedByPeer(
409 const QuicAckFrame& incoming_ack); 417 const QuicAckFrame& incoming_ack);
410 // Updates internal state based in incoming_ack.sent_info 418 // Updates internal state based in incoming_ack.sent_info
411 void UpdatePacketInformationSentByPeer(const QuicAckFrame& incoming_ack); 419 void UpdatePacketInformationSentByPeer(const QuicAckFrame& incoming_ack);
412 420
413 QuicConnectionHelperInterface* helper() { return helper_.get(); } 421 QuicConnectionHelperInterface* helper() { return helper_.get(); }
414 422
415 private: 423 private:
416 friend class test::QuicConnectionPeer; 424 friend class test::QuicConnectionPeer;
417 425
418 // Packets which have not been written to the wire. 426 // Packets which have not been written to the wire.
419 // Owns the QuicPacket* packet. 427 // Owns the QuicPacket* packet.
420 struct QueuedPacket { 428 struct QueuedPacket {
421 QueuedPacket(QuicPacketSequenceNumber sequence_number, 429 QueuedPacket(QuicPacketSequenceNumber sequence_number,
422 QuicPacket* packet, 430 QuicPacket* packet,
431 EncryptionLevel level,
423 HasRetransmittableData retransmittable) 432 HasRetransmittableData retransmittable)
424 : sequence_number(sequence_number), 433 : sequence_number(sequence_number),
425 packet(packet), 434 packet(packet),
435 encryption_level(level),
426 retransmittable(retransmittable) { 436 retransmittable(retransmittable) {
427 } 437 }
428 438
429 QuicPacketSequenceNumber sequence_number; 439 QuicPacketSequenceNumber sequence_number;
430 QuicPacket* packet; 440 QuicPacket* packet;
441 const EncryptionLevel encryption_level;
431 HasRetransmittableData retransmittable; 442 HasRetransmittableData retransmittable;
432 }; 443 };
433 444
434 struct RetransmissionInfo { 445 struct RetransmissionInfo {
435 explicit RetransmissionInfo(QuicPacketSequenceNumber sequence_number) 446 explicit RetransmissionInfo(QuicPacketSequenceNumber sequence_number)
436 : sequence_number(sequence_number), 447 : sequence_number(sequence_number),
437 scheduled_time(QuicTime::Zero()), 448 scheduled_time(QuicTime::Zero()),
438 number_nacks(0), 449 number_nacks(0),
439 number_retransmissions(0) { 450 number_retransmissions(0) {
440 } 451 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 void MaybeSendAckInResponseToPacket(); 502 void MaybeSendAckInResponseToPacket();
492 503
493 // Get the FEC group associate with the last processed packet. 504 // Get the FEC group associate with the last processed packet.
494 QuicFecGroup* GetFecGroup(); 505 QuicFecGroup* GetFecGroup();
495 506
496 // Closes any FEC groups protecting packets before |sequence_number|. 507 // Closes any FEC groups protecting packets before |sequence_number|.
497 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); 508 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number);
498 509
499 scoped_ptr<QuicConnectionHelperInterface> helper_; 510 scoped_ptr<QuicConnectionHelperInterface> helper_;
500 QuicFramer framer_; 511 QuicFramer framer_;
512 EncryptionLevel encryption_level_;
501 const QuicClock* clock_; 513 const QuicClock* clock_;
502 QuicRandom* random_generator_; 514 QuicRandom* random_generator_;
503 515
504 const QuicGuid guid_; 516 const QuicGuid guid_;
505 // Address on the last successfully processed packet received from the 517 // Address on the last successfully processed packet received from the
506 // client. 518 // client.
507 IPEndPoint self_address_; 519 IPEndPoint self_address_;
508 IPEndPoint peer_address_; 520 IPEndPoint peer_address_;
509 // Address on the last(currently being processed) packet received. Not 521 // Address on the last(currently being processed) packet received. Not
510 // verified/authenticated. 522 // verified/authenticated.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 bool received_truncated_ack_; 617 bool received_truncated_ack_;
606 618
607 bool send_ack_in_response_to_packet_; 619 bool send_ack_in_response_to_packet_;
608 620
609 DISALLOW_COPY_AND_ASSIGN(QuicConnection); 621 DISALLOW_COPY_AND_ASSIGN(QuicConnection);
610 }; 622 };
611 623
612 } // namespace net 624 } // namespace net
613 625
614 #endif // NET_QUIC_QUIC_CONNECTION_H_ 626 #endif // NET_QUIC_QUIC_CONNECTION_H_
OLDNEW
« no previous file with comments | « net/quic/quic_client_session_test.cc ('k') | net/quic/quic_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698