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

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

Issue 1009543004: Create a Perspective enum to use instead of a bool is_server to improve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NET_EXPORT_PRIVATE to fix compiler error Created 5 years, 9 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
« no previous file with comments | « net/quic/quic_flow_controller_test.cc ('k') | net/quic/quic_framer.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 #ifndef NET_QUIC_QUIC_FRAMER_H_ 5 #ifndef NET_QUIC_QUIC_FRAMER_H_
6 #define NET_QUIC_QUIC_FRAMER_H_ 6 #define NET_QUIC_QUIC_FRAMER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // This class receives callbacks from the framer when packets 61 // This class receives callbacks from the framer when packets
62 // are processed. 62 // are processed.
63 class NET_EXPORT_PRIVATE QuicFramerVisitorInterface { 63 class NET_EXPORT_PRIVATE QuicFramerVisitorInterface {
64 public: 64 public:
65 virtual ~QuicFramerVisitorInterface() {} 65 virtual ~QuicFramerVisitorInterface() {}
66 66
67 // Called if an error is detected in the QUIC protocol. 67 // Called if an error is detected in the QUIC protocol.
68 virtual void OnError(QuicFramer* framer) = 0; 68 virtual void OnError(QuicFramer* framer) = 0;
69 69
70 // Called only when |is_server_| is true and the the framer gets a packet with 70 // Called only when |perspective_| is IS_SERVER and the the framer gets a
71 // version flag true and the version on the packet doesn't match 71 // packet with version flag true and the version on the packet doesn't match
72 // |quic_version_|. The visitor should return true after it updates the 72 // |quic_version_|. The visitor should return true after it updates the
73 // version of the |framer_| to |received_version| or false to stop processing 73 // version of the |framer_| to |received_version| or false to stop processing
74 // this packet. 74 // this packet.
75 virtual bool OnProtocolVersionMismatch(QuicVersion received_version) = 0; 75 virtual bool OnProtocolVersionMismatch(QuicVersion received_version) = 0;
76 76
77 // Called when a new packet has been received, before it 77 // Called when a new packet has been received, before it
78 // has been validated or processed. 78 // has been validated or processed.
79 virtual void OnPacket() = 0; 79 virtual void OnPacket() = 0;
80 80
81 // Called when a public reset packet has been parsed but has not yet 81 // Called when a public reset packet has been parsed but has not yet
82 // been validated. 82 // been validated.
83 virtual void OnPublicResetPacket( 83 virtual void OnPublicResetPacket(
84 const QuicPublicResetPacket& packet) = 0; 84 const QuicPublicResetPacket& packet) = 0;
85 85
86 // Called only when |is_server_| is false and a version negotiation packet has 86 // Called only when |perspective_| is IS_CLIENT and a version negotiation
87 // been parsed. 87 // packet has been parsed.
88 virtual void OnVersionNegotiationPacket( 88 virtual void OnVersionNegotiationPacket(
89 const QuicVersionNegotiationPacket& packet) = 0; 89 const QuicVersionNegotiationPacket& packet) = 0;
90 90
91 // Called when a lost packet has been recovered via FEC, 91 // Called when a lost packet has been recovered via FEC,
92 // before it has been processed. 92 // before it has been processed.
93 virtual void OnRevivedPacket() = 0; 93 virtual void OnRevivedPacket() = 0;
94 94
95 // Called when the public header has been parsed, but has not been 95 // Called when the public header has been parsed, but has not been
96 // authenticated. If it returns false, framing for this packet will cease. 96 // authenticated. If it returns false, framing for this packet will cease.
97 virtual bool OnUnauthenticatedPublicHeader( 97 virtual bool OnUnauthenticatedPublicHeader(
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // It also has a QuicFecBuilder that is called when packets are constructed 180 // It also has a QuicFecBuilder that is called when packets are constructed
181 // in order to generate FEC data for subsequently building FEC packets. 181 // in order to generate FEC data for subsequently building FEC packets.
182 class NET_EXPORT_PRIVATE QuicFramer { 182 class NET_EXPORT_PRIVATE QuicFramer {
183 public: 183 public:
184 // Constructs a new framer that installs a kNULL QuicEncrypter and 184 // Constructs a new framer that installs a kNULL QuicEncrypter and
185 // QuicDecrypter for level ENCRYPTION_NONE. |supported_versions| specifies the 185 // QuicDecrypter for level ENCRYPTION_NONE. |supported_versions| specifies the
186 // list of supported QUIC versions. |quic_version_| is set to the maximum 186 // list of supported QUIC versions. |quic_version_| is set to the maximum
187 // version in |supported_versions|. 187 // version in |supported_versions|.
188 QuicFramer(const QuicVersionVector& supported_versions, 188 QuicFramer(const QuicVersionVector& supported_versions,
189 QuicTime creation_time, 189 QuicTime creation_time,
190 bool is_server); 190 Perspective perspective);
191 191
192 virtual ~QuicFramer(); 192 virtual ~QuicFramer();
193 193
194 // Returns true if |version| is a supported protocol version. 194 // Returns true if |version| is a supported protocol version.
195 bool IsSupportedVersion(const QuicVersion version) const; 195 bool IsSupportedVersion(const QuicVersion version) const;
196 196
197 // Set callbacks to be called from the framer. A visitor must be set, or 197 // Set callbacks to be called from the framer. A visitor must be set, or
198 // else the framer will likely crash. It is acceptable for the visitor 198 // else the framer will likely crash. It is acceptable for the visitor
199 // to do nothing. If this is called multiple times, only the last visitor 199 // to do nothing. If this is called multiple times, only the last visitor
200 // will be used. 200 // will be used.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 static QuicSequenceNumberLength GetMinSequenceNumberLength( 363 static QuicSequenceNumberLength GetMinSequenceNumberLength(
364 QuicPacketSequenceNumber sequence_number); 364 QuicPacketSequenceNumber sequence_number);
365 365
366 void SetSupportedVersions(const QuicVersionVector& versions) { 366 void SetSupportedVersions(const QuicVersionVector& versions) {
367 supported_versions_ = versions; 367 supported_versions_ = versions;
368 quic_version_ = versions[0]; 368 quic_version_ = versions[0];
369 } 369 }
370 370
371 void set_validate_flags(bool value) { validate_flags_ = value; } 371 void set_validate_flags(bool value) { validate_flags_ = value; }
372 372
373 bool is_server() const { return is_server_; } 373 Perspective perspective() const { return perspective_; }
374 374
375 static QuicPacketEntropyHash GetPacketEntropyHash( 375 static QuicPacketEntropyHash GetPacketEntropyHash(
376 const QuicPacketHeader& header); 376 const QuicPacketHeader& header);
377 377
378 private: 378 private:
379 friend class test::QuicFramerPeer; 379 friend class test::QuicFramerPeer;
380 380
381 typedef std::map<QuicPacketSequenceNumber, uint8> NackRangeMap; 381 typedef std::map<QuicPacketSequenceNumber, uint8> NackRangeMap;
382 382
383 struct AckFrameInfo { 383 struct AckFrameInfo {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 // The encryption level of |alternative_decrypter_|. 522 // The encryption level of |alternative_decrypter_|.
523 EncryptionLevel alternative_decrypter_level_; 523 EncryptionLevel alternative_decrypter_level_;
524 // |alternative_decrypter_latch_| is true if, when |alternative_decrypter_| 524 // |alternative_decrypter_latch_| is true if, when |alternative_decrypter_|
525 // successfully decrypts a packet, we should install it as the only 525 // successfully decrypts a packet, we should install it as the only
526 // decrypter. 526 // decrypter.
527 bool alternative_decrypter_latch_; 527 bool alternative_decrypter_latch_;
528 // Encrypters used to encrypt packets via EncryptPacket(). 528 // Encrypters used to encrypt packets via EncryptPacket().
529 scoped_ptr<QuicEncrypter> encrypter_[NUM_ENCRYPTION_LEVELS]; 529 scoped_ptr<QuicEncrypter> encrypter_[NUM_ENCRYPTION_LEVELS];
530 // Tracks if the framer is being used by the entity that received the 530 // Tracks if the framer is being used by the entity that received the
531 // connection or the entity that initiated it. 531 // connection or the entity that initiated it.
532 bool is_server_; 532 Perspective perspective_;
533 // If false, skip validation that the public flags are set to legal values. 533 // If false, skip validation that the public flags are set to legal values.
534 bool validate_flags_; 534 bool validate_flags_;
535 // The time this framer was created. Time written to the wire will be 535 // The time this framer was created. Time written to the wire will be
536 // written as a delta from this value. 536 // written as a delta from this value.
537 QuicTime creation_time_; 537 QuicTime creation_time_;
538 // The time delta computed for the last timestamp frame. This is relative to 538 // The time delta computed for the last timestamp frame. This is relative to
539 // the creation_time. 539 // the creation_time.
540 QuicTime::Delta last_timestamp_; 540 QuicTime::Delta last_timestamp_;
541 541
542 DISALLOW_COPY_AND_ASSIGN(QuicFramer); 542 DISALLOW_COPY_AND_ASSIGN(QuicFramer);
543 }; 543 };
544 544
545 } // namespace net 545 } // namespace net
546 546
547 #endif // NET_QUIC_QUIC_FRAMER_H_ 547 #endif // NET_QUIC_QUIC_FRAMER_H_
OLDNEW
« no previous file with comments | « net/quic/quic_flow_controller_test.cc ('k') | net/quic/quic_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698