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

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

Issue 1466693002: Cleanup: clang-formatting gfe/quic/quic_framer* to comply with Chromium style guide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@107509393
Patch Set: Created 5 years, 1 month 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 | « no previous file | 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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // Size in bytes of the entropy hash sent in ack frames. 44 // Size in bytes of the entropy hash sent in ack frames.
45 const size_t kQuicEntropyHashSize = 1; 45 const size_t kQuicEntropyHashSize = 1;
46 // Size in bytes reserved for the delta time of the largest observed 46 // Size in bytes reserved for the delta time of the largest observed
47 // packet number in ack frames. 47 // packet number in ack frames.
48 const size_t kQuicDeltaTimeLargestObservedSize = 2; 48 const size_t kQuicDeltaTimeLargestObservedSize = 2;
49 // Size in bytes reserved for the number of received packets with timestamps. 49 // Size in bytes reserved for the number of received packets with timestamps.
50 const size_t kQuicNumTimestampsSize = 1; 50 const size_t kQuicNumTimestampsSize = 1;
51 // Size in bytes reserved for the number of missing packets in ack frames. 51 // Size in bytes reserved for the number of missing packets in ack frames.
52 const size_t kNumberOfNackRangesSize = 1; 52 const size_t kNumberOfNackRangesSize = 1;
53 // Maximum number of missing packet ranges that can fit within an ack frame. 53 // Maximum number of missing packet ranges that can fit within an ack frame.
54 const size_t kMaxNackRanges = 54 const size_t kMaxNackRanges = (1 << (kNumberOfNackRangesSize * 8)) - 1;
55 (1 << (kNumberOfNackRangesSize * 8)) - 1;
56 // Size in bytes reserved for the number of revived packets in ack frames. 55 // Size in bytes reserved for the number of revived packets in ack frames.
57 const size_t kNumberOfRevivedPacketsSize = 1; 56 const size_t kNumberOfRevivedPacketsSize = 1;
58 // Maximum number of revived packets that can fit within an ack frame. 57 // Maximum number of revived packets that can fit within an ack frame.
59 const size_t kMaxRevivedPackets = 58 const size_t kMaxRevivedPackets = (1 << (kNumberOfRevivedPacketsSize * 8)) - 1;
60 (1 << (kNumberOfRevivedPacketsSize * 8)) - 1;
61 59
62 // This class receives callbacks from the framer when packets 60 // This class receives callbacks from the framer when packets
63 // are processed. 61 // are processed.
64 class NET_EXPORT_PRIVATE QuicFramerVisitorInterface { 62 class NET_EXPORT_PRIVATE QuicFramerVisitorInterface {
65 public: 63 public:
66 virtual ~QuicFramerVisitorInterface() {} 64 virtual ~QuicFramerVisitorInterface() {}
67 65
68 // Called if an error is detected in the QUIC protocol. 66 // Called if an error is detected in the QUIC protocol.
69 virtual void OnError(QuicFramer* framer) = 0; 67 virtual void OnError(QuicFramer* framer) = 0;
70 68
71 // Called only when |perspective_| is IS_SERVER and the the framer gets a 69 // Called only when |perspective_| is IS_SERVER and the the framer gets a
72 // packet with version flag true and the version on the packet doesn't match 70 // packet with version flag true and the version on the packet doesn't match
73 // |quic_version_|. The visitor should return true after it updates the 71 // |quic_version_|. The visitor should return true after it updates the
74 // version of the |framer_| to |received_version| or false to stop processing 72 // version of the |framer_| to |received_version| or false to stop processing
75 // this packet. 73 // this packet.
76 virtual bool OnProtocolVersionMismatch(QuicVersion received_version) = 0; 74 virtual bool OnProtocolVersionMismatch(QuicVersion received_version) = 0;
77 75
78 // Called when a new packet has been received, before it 76 // Called when a new packet has been received, before it
79 // has been validated or processed. 77 // has been validated or processed.
80 virtual void OnPacket() = 0; 78 virtual void OnPacket() = 0;
81 79
82 // Called when a public reset packet has been parsed but has not yet 80 // Called when a public reset packet has been parsed but has not yet
83 // been validated. 81 // been validated.
84 virtual void OnPublicResetPacket( 82 virtual void OnPublicResetPacket(const QuicPublicResetPacket& packet) = 0;
85 const QuicPublicResetPacket& packet) = 0;
86 83
87 // Called only when |perspective_| is IS_CLIENT and a version negotiation 84 // Called only when |perspective_| is IS_CLIENT and a version negotiation
88 // packet has been parsed. 85 // packet has been parsed.
89 virtual void OnVersionNegotiationPacket( 86 virtual void OnVersionNegotiationPacket(
90 const QuicVersionNegotiationPacket& packet) = 0; 87 const QuicVersionNegotiationPacket& packet) = 0;
91 88
92 // Called when a lost packet has been recovered via FEC, 89 // Called when a lost packet has been recovered via FEC,
93 // before it has been processed. 90 // before it has been processed.
94 virtual void OnRevivedPacket() = 0; 91 virtual void OnRevivedPacket() = 0;
95 92
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 179
183 virtual ~QuicFramer(); 180 virtual ~QuicFramer();
184 181
185 // Returns true if |version| is a supported protocol version. 182 // Returns true if |version| is a supported protocol version.
186 bool IsSupportedVersion(const QuicVersion version) const; 183 bool IsSupportedVersion(const QuicVersion version) const;
187 184
188 // Set callbacks to be called from the framer. A visitor must be set, or 185 // Set callbacks to be called from the framer. A visitor must be set, or
189 // else the framer will likely crash. It is acceptable for the visitor 186 // else the framer will likely crash. It is acceptable for the visitor
190 // to do nothing. If this is called multiple times, only the last visitor 187 // to do nothing. If this is called multiple times, only the last visitor
191 // will be used. 188 // will be used.
192 void set_visitor(QuicFramerVisitorInterface* visitor) { 189 void set_visitor(QuicFramerVisitorInterface* visitor) { visitor_ = visitor; }
193 visitor_ = visitor;
194 }
195 190
196 const QuicVersionVector& supported_versions() const { 191 const QuicVersionVector& supported_versions() const {
197 return supported_versions_; 192 return supported_versions_;
198 } 193 }
199 194
200 QuicVersion version() const { 195 QuicVersion version() const { return quic_version_; }
201 return quic_version_;
202 }
203 196
204 void set_version(const QuicVersion version); 197 void set_version(const QuicVersion version);
205 198
206 // Does not DCHECK for supported version. Used by tests to set unsupported 199 // Does not DCHECK for supported version. Used by tests to set unsupported
207 // version to trigger version negotiation. 200 // version to trigger version negotiation.
208 void set_version_for_tests(const QuicVersion version) { 201 void set_version_for_tests(const QuicVersion version) {
209 quic_version_ = version; 202 quic_version_ = version;
210 } 203 }
211 204
212 // Set entropy calculator to be called from the framer when it needs the 205 // Set entropy calculator to be called from the framer when it needs the
213 // entropy of a truncated ack frame. An entropy calculator must be set or else 206 // entropy of a truncated ack frame. An entropy calculator must be set or else
214 // the framer will likely crash. If this is called multiple times, only the 207 // the framer will likely crash. If this is called multiple times, only the
215 // last calculator will be used. 208 // last calculator will be used.
216 void set_received_entropy_calculator( 209 void set_received_entropy_calculator(
217 QuicReceivedEntropyHashCalculatorInterface* entropy_calculator) { 210 QuicReceivedEntropyHashCalculatorInterface* entropy_calculator) {
218 entropy_calculator_ = entropy_calculator; 211 entropy_calculator_ = entropy_calculator;
219 } 212 }
220 213
221 QuicErrorCode error() const { 214 QuicErrorCode error() const { return error_; }
222 return error_;
223 }
224 215
225 // Pass a UDP packet into the framer for parsing. 216 // Pass a UDP packet into the framer for parsing.
226 // Return true if the packet was processed succesfully. |packet| must be a 217 // Return true if the packet was processed succesfully. |packet| must be a
227 // single, complete UDP packet (not a frame of a packet). This packet 218 // single, complete UDP packet (not a frame of a packet). This packet
228 // might be null padded past the end of the payload, which will be correctly 219 // might be null padded past the end of the payload, which will be correctly
229 // ignored. 220 // ignored.
230 bool ProcessPacket(const QuicEncryptedPacket& packet); 221 bool ProcessPacket(const QuicEncryptedPacket& packet);
231 222
232 // Pass a data packet that was revived from FEC data into the framer 223 // Pass a data packet that was revived from FEC data into the framer
233 // for parsing. 224 // for parsing.
234 // Return true if the packet was processed succesfully. |payload| must be 225 // Return true if the packet was processed succesfully. |payload| must be
235 // the complete DECRYPTED payload of the revived packet. 226 // the complete DECRYPTED payload of the revived packet.
236 bool ProcessRevivedPacket(QuicPacketHeader* header, 227 bool ProcessRevivedPacket(QuicPacketHeader* header, base::StringPiece payload) ;
237 base::StringPiece payload);
238 228
239 // Largest size in bytes of all stream frame fields without the payload. 229 // Largest size in bytes of all stream frame fields without the payload.
240 static size_t GetMinStreamFrameSize(QuicStreamId stream_id, 230 static size_t GetMinStreamFrameSize(QuicStreamId stream_id,
241 QuicStreamOffset offset, 231 QuicStreamOffset offset,
242 bool last_frame_in_packet, 232 bool last_frame_in_packet,
243 InFecGroup is_in_fec_group); 233 InFecGroup is_in_fec_group);
244 // Size in bytes of all ack frame fields without the missing packets. 234 // Size in bytes of all ack frame fields without the missing packets.
245 static size_t GetMinAckFrameSize( 235 static size_t GetMinAckFrameSize(
246 QuicPacketNumberLength largest_observed_length); 236 QuicPacketNumberLength largest_observed_length);
247 // Size in bytes of a stop waiting frame. 237 // Size in bytes of a stop waiting frame.
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 bool AppendConnectionCloseFrame(const QuicConnectionCloseFrame& frame, 479 bool AppendConnectionCloseFrame(const QuicConnectionCloseFrame& frame,
490 QuicDataWriter* builder); 480 QuicDataWriter* builder);
491 bool AppendGoAwayFrame(const QuicGoAwayFrame& frame, QuicDataWriter* writer); 481 bool AppendGoAwayFrame(const QuicGoAwayFrame& frame, QuicDataWriter* writer);
492 bool AppendWindowUpdateFrame(const QuicWindowUpdateFrame& frame, 482 bool AppendWindowUpdateFrame(const QuicWindowUpdateFrame& frame,
493 QuicDataWriter* writer); 483 QuicDataWriter* writer);
494 bool AppendBlockedFrame(const QuicBlockedFrame& frame, 484 bool AppendBlockedFrame(const QuicBlockedFrame& frame,
495 QuicDataWriter* writer); 485 QuicDataWriter* writer);
496 486
497 bool RaiseError(QuicErrorCode error); 487 bool RaiseError(QuicErrorCode error);
498 488
499 void set_error(QuicErrorCode error) { 489 void set_error(QuicErrorCode error) { error_ = error; }
500 error_ = error;
501 }
502 490
503 void set_detailed_error(const char* error) { 491 void set_detailed_error(const char* error) { detailed_error_ = error; }
504 detailed_error_ = error;
505 }
506 492
507 std::string detailed_error_; 493 std::string detailed_error_;
508 QuicFramerVisitorInterface* visitor_; 494 QuicFramerVisitorInterface* visitor_;
509 QuicReceivedEntropyHashCalculatorInterface* entropy_calculator_; 495 QuicReceivedEntropyHashCalculatorInterface* entropy_calculator_;
510 QuicErrorCode error_; 496 QuicErrorCode error_;
511 // Updated by ProcessPacketHeader when it succeeds. 497 // Updated by ProcessPacketHeader when it succeeds.
512 QuicPacketNumber last_packet_number_; 498 QuicPacketNumber last_packet_number_;
513 // Updated by WritePacketHeader. 499 // Updated by WritePacketHeader.
514 QuicConnectionId last_serialized_connection_id_; 500 QuicConnectionId last_serialized_connection_id_;
515 // Version of the protocol being used. 501 // Version of the protocol being used.
(...skipping 28 matching lines...) Expand all
544 // The time delta computed for the last timestamp frame. This is relative to 530 // The time delta computed for the last timestamp frame. This is relative to
545 // the creation_time. 531 // the creation_time.
546 QuicTime::Delta last_timestamp_; 532 QuicTime::Delta last_timestamp_;
547 533
548 DISALLOW_COPY_AND_ASSIGN(QuicFramer); 534 DISALLOW_COPY_AND_ASSIGN(QuicFramer);
549 }; 535 };
550 536
551 } // namespace net 537 } // namespace net
552 538
553 #endif // NET_QUIC_QUIC_FRAMER_H_ 539 #endif // NET_QUIC_QUIC_FRAMER_H_
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698