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

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

Issue 149263002: Refactor QuicConnection to use explicit notification for getting onto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | « no previous file | 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // Deletes |packet| if WritePacket call succeeds, or transfers ownership to 420 // Deletes |packet| if WritePacket call succeeds, or transfers ownership to
421 // QueuedPacket, ultimately deleted in WriteQueuedPackets. Updates the 421 // QueuedPacket, ultimately deleted in WriteQueuedPackets. Updates the
422 // entropy map corresponding to |sequence_number| using |entropy_hash|. 422 // entropy map corresponding to |sequence_number| using |entropy_hash|.
423 // |transmission_type| and |retransmittable| are supplied to the congestion 423 // |transmission_type| and |retransmittable| are supplied to the congestion
424 // manager, and when |forced| is true, it bypasses the congestion manager. 424 // manager, and when |forced| is true, it bypasses the congestion manager.
425 // TODO(wtc): none of the callers check the return value. 425 // TODO(wtc): none of the callers check the return value.
426 virtual bool SendOrQueuePacket(EncryptionLevel level, 426 virtual bool SendOrQueuePacket(EncryptionLevel level,
427 const SerializedPacket& packet, 427 const SerializedPacket& packet,
428 TransmissionType transmission_type); 428 TransmissionType transmission_type);
429 429
430 // Writes the given packet to socket, encrypted with |level|, with the help
431 // of helper. Returns true on successful write, false otherwise. However,
432 // behavior is undefined if connection is not established or broken. In any
433 // circumstances, a return value of true implies that |packet| has been
434 // transmitted and may be destroyed. If |sequence_number| is present in
435 // |retransmission_map_| it also sets up retransmission of the given packet
436 // in case of successful write. If |force| is FORCE, then the packet will be
437 // sent immediately and the send scheduler will not be consulted.
438 bool WritePacket(EncryptionLevel level,
439 QuicPacketSequenceNumber sequence_number,
440 const QuicPacket& packet,
441 TransmissionType transmission_type,
442 HasRetransmittableData retransmittable,
443 IsHandshake handshake,
444 Force force);
445
446 // Make sure an ack we got from our peer is sane.
447 bool ValidateAckFrame(const QuicAckFrame& incoming_ack);
448
449 QuicConnectionHelperInterface* helper() { return helper_; } 430 QuicConnectionHelperInterface* helper() { return helper_; }
450 431
451 // Selects and updates the version of the protocol being used by selecting a 432 // Selects and updates the version of the protocol being used by selecting a
452 // version from |available_versions| which is also supported. Returns true if 433 // version from |available_versions| which is also supported. Returns true if
453 // such a version exists, false otherwise. 434 // such a version exists, false otherwise.
454 bool SelectMutualVersion(const QuicVersionVector& available_versions); 435 bool SelectMutualVersion(const QuicVersionVector& available_versions);
455 436
456 QuicFramer framer_;
457
458 private: 437 private:
459 // Stores current batch state for connection, puts the connection 438 // Stores current batch state for connection, puts the connection
460 // into batch mode, and destruction restores the stored batch state. 439 // into batch mode, and destruction restores the stored batch state.
461 // While the bundler is in scope, any generated frames are bundled 440 // While the bundler is in scope, any generated frames are bundled
462 // as densely as possible into packets. In addition, this bundler 441 // as densely as possible into packets. In addition, this bundler
463 // can be configured to ensure that an ACK frame is included in the 442 // can be configured to ensure that an ACK frame is included in the
464 // first packet created, if there's new ack information to be sent. 443 // first packet created, if there's new ack information to be sent.
465 class ScopedPacketBundler { 444 class ScopedPacketBundler {
466 public: 445 public:
467 // In addition to all outgoing frames being bundled when the 446 // In addition to all outgoing frames being bundled when the
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 TransmissionType transmission_type; 504 TransmissionType transmission_type;
526 HasRetransmittableData retransmittable; 505 HasRetransmittableData retransmittable;
527 EncryptionLevel level; 506 EncryptionLevel level;
528 bool is_fec_packet; 507 bool is_fec_packet;
529 size_t length; 508 size_t length;
530 }; 509 };
531 510
532 typedef std::list<QueuedPacket> QueuedPacketList; 511 typedef std::list<QueuedPacket> QueuedPacketList;
533 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap; 512 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap;
534 513
514 // Writes the given packet to socket, encrypted with |level|. Returns true on
515 // successful write. Behavior is undefined if connection is not established or
516 // broken. In any circumstance, a return value of true implies that |packet|
517 // has been transmitted and may be destroyed. If |sequence_number| is present
518 // in |retransmission_map_| it also sets up retransmission of the given packet
519 // in case of successful write. If |force| is FORCE, then the packet will be
520 // sent immediately and the send scheduler will not be consulted.
521 bool WritePacket(EncryptionLevel level,
522 QuicPacketSequenceNumber sequence_number,
523 const QuicPacket& packet,
524 TransmissionType transmission_type,
525 HasRetransmittableData retransmittable,
526 IsHandshake handshake,
527 Force force);
528
529 // Make sure an ack we got from our peer is sane.
530 bool ValidateAckFrame(const QuicAckFrame& incoming_ack);
531
535 // Sends a version negotiation packet to the peer. 532 // Sends a version negotiation packet to the peer.
536 void SendVersionNegotiationPacket(); 533 void SendVersionNegotiationPacket();
537 534
538 // Clears any accumulated frames from the last received packet. 535 // Clears any accumulated frames from the last received packet.
539 void ClearLastFrames(); 536 void ClearLastFrames();
540 537
541 // Calculates the smallest sequence number length that can also represent four 538 // Calculates the smallest sequence number length that can also represent four
542 // times the maximum of the congestion window and the difference between the 539 // times the maximum of the congestion window and the difference between the
543 // least_packet_awaited_by_peer_ and |sequence_number|. 540 // least_packet_awaited_by_peer_ and |sequence_number|.
544 QuicSequenceNumberLength CalculateSequenceNumberLength( 541 QuicSequenceNumberLength CalculateSequenceNumberLength(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 // acks and pending writes if an ack opened the congestion window. 586 // acks and pending writes if an ack opened the congestion window.
590 void MaybeSendInResponseToPacket(); 587 void MaybeSendInResponseToPacket();
591 588
592 // Get the FEC group associate with the last processed packet or NULL, if the 589 // Get the FEC group associate with the last processed packet or NULL, if the
593 // group has already been deleted. 590 // group has already been deleted.
594 QuicFecGroup* GetFecGroup(); 591 QuicFecGroup* GetFecGroup();
595 592
596 // Closes any FEC groups protecting packets before |sequence_number|. 593 // Closes any FEC groups protecting packets before |sequence_number|.
597 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); 594 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number);
598 595
596 QuicFramer framer_;
599 QuicConnectionHelperInterface* helper_; // Not owned. 597 QuicConnectionHelperInterface* helper_; // Not owned.
600 QuicPacketWriter* writer_; // Not owned. 598 QuicPacketWriter* writer_; // Not owned.
601 EncryptionLevel encryption_level_; 599 EncryptionLevel encryption_level_;
602 const QuicClock* clock_; 600 const QuicClock* clock_;
603 QuicRandom* random_generator_; 601 QuicRandom* random_generator_;
604 602
605 const QuicGuid guid_; 603 const QuicGuid guid_;
606 // Address on the last successfully processed packet received from the 604 // Address on the last successfully processed packet received from the
607 // client. 605 // client.
608 IPEndPoint self_address_; 606 IPEndPoint self_address_;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 // If non-empty this contains the set of versions received in a 714 // If non-empty this contains the set of versions received in a
717 // version negotiation packet. 715 // version negotiation packet.
718 QuicVersionVector server_supported_versions_; 716 QuicVersionVector server_supported_versions_;
719 717
720 DISALLOW_COPY_AND_ASSIGN(QuicConnection); 718 DISALLOW_COPY_AND_ASSIGN(QuicConnection);
721 }; 719 };
722 720
723 } // namespace net 721 } // namespace net
724 722
725 #endif // NET_QUIC_QUIC_CONNECTION_H_ 723 #endif // NET_QUIC_QUIC_CONNECTION_H_
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698