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

Side by Side Diff: net/quic/quic_protocol.cc

Issue 23464033: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix valgrind error Created 7 years, 3 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_protocol.h ('k') | net/quic/quic_session.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 #include "net/quic/quic_protocol.h" 5 #include "net/quic/quic_protocol.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/quic_utils.h" 8 #include "net/quic/quic_utils.h"
9 9
10 using base::StringPiece; 10 using base::StringPiece;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 QuicStreamFrame::QuicStreamFrame() {} 96 QuicStreamFrame::QuicStreamFrame() {}
97 97
98 QuicStreamFrame::QuicStreamFrame(QuicStreamId stream_id, 98 QuicStreamFrame::QuicStreamFrame(QuicStreamId stream_id,
99 bool fin, 99 bool fin,
100 QuicStreamOffset offset, 100 QuicStreamOffset offset,
101 StringPiece data) 101 StringPiece data)
102 : stream_id(stream_id), 102 : stream_id(stream_id),
103 fin(fin), 103 fin(fin),
104 offset(offset), 104 offset(offset),
105 data(data) { 105 data(data),
106 notifier(NULL) {
106 } 107 }
107 108
108 uint32 MakeQuicTag(char a, char b, char c, char d) { 109 uint32 MakeQuicTag(char a, char b, char c, char d) {
109 return static_cast<uint32>(a) | 110 return static_cast<uint32>(a) |
110 static_cast<uint32>(b) << 8 | 111 static_cast<uint32>(b) << 8 |
111 static_cast<uint32>(c) << 16 | 112 static_cast<uint32>(c) << 16 |
112 static_cast<uint32>(d) << 24; 113 static_cast<uint32>(d) << 24;
113 } 114 }
114 115
115 QuicVersion QuicVersionMax() { return kSupportedQuicVersions[0]; } 116 QuicVersion QuicVersionMax() { return kSupportedQuicVersions[0]; }
116 117
117 QuicVersion QuicVersionMin() { 118 QuicVersion QuicVersionMin() {
118 return kSupportedQuicVersions[arraysize(kSupportedQuicVersions) - 1]; 119 return kSupportedQuicVersions[arraysize(kSupportedQuicVersions) - 1];
119 } 120 }
120 121
121 QuicTag QuicVersionToQuicTag(const QuicVersion version) { 122 QuicTag QuicVersionToQuicTag(const QuicVersion version) {
122 switch (version) { 123 switch (version) {
123 case QUIC_VERSION_7: 124 case QUIC_VERSION_7:
124 return MakeQuicTag('Q', '0', '0', '7'); 125 return MakeQuicTag('Q', '0', '0', '7');
125 case QUIC_VERSION_8: 126 case QUIC_VERSION_8:
126 return MakeQuicTag('Q', '0', '0', '8'); 127 return MakeQuicTag('Q', '0', '0', '8');
127 case QUIC_VERSION_9: 128 case QUIC_VERSION_9:
128 return MakeQuicTag('Q', '0', '0', '9'); 129 return MakeQuicTag('Q', '0', '0', '9');
130 case QUIC_VERSION_10:
131 return MakeQuicTag('Q', '0', '1', '0');
129 default: 132 default:
130 // This shold be an ERROR because we should never attempt to convert an 133 // This shold be an ERROR because we should never attempt to convert an
131 // invalid QuicVersion to be written to the wire. 134 // invalid QuicVersion to be written to the wire.
132 LOG(ERROR) << "Unsupported QuicVersion: " << version; 135 LOG(ERROR) << "Unsupported QuicVersion: " << version;
133 return 0; 136 return 0;
134 } 137 }
135 } 138 }
136 139
137 QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) { 140 QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) {
138 const QuicTag quic_tag_v7 = MakeQuicTag('Q', '0', '0', '7'); 141 const QuicTag quic_tag_v7 = MakeQuicTag('Q', '0', '0', '7');
139 const QuicTag quic_tag_v8 = MakeQuicTag('Q', '0', '0', '8'); 142 const QuicTag quic_tag_v8 = MakeQuicTag('Q', '0', '0', '8');
140 const QuicTag quic_tag_v9 = MakeQuicTag('Q', '0', '0', '9'); 143 const QuicTag quic_tag_v9 = MakeQuicTag('Q', '0', '0', '9');
144 const QuicTag quic_tag_v10 = MakeQuicTag('Q', '0', '1', '0');
141 145
142 if (version_tag == quic_tag_v7) { 146 if (version_tag == quic_tag_v7) {
143 return QUIC_VERSION_7; 147 return QUIC_VERSION_7;
144 } else if (version_tag == quic_tag_v8) { 148 } else if (version_tag == quic_tag_v8) {
145 return QUIC_VERSION_8; 149 return QUIC_VERSION_8;
146 } else if (version_tag == quic_tag_v9) { 150 } else if (version_tag == quic_tag_v9) {
147 return QUIC_VERSION_9; 151 return QUIC_VERSION_9;
152 } else if (version_tag == quic_tag_v10) {
153 return QUIC_VERSION_10;
148 } else { 154 } else {
149 // Reading from the client so this should not be considered an ERROR. 155 // Reading from the client so this should not be considered an ERROR.
150 DLOG(INFO) << "Unsupported QuicTag version: " 156 DLOG(INFO) << "Unsupported QuicTag version: "
151 << QuicUtils::TagToString(version_tag); 157 << QuicUtils::TagToString(version_tag);
152 return QUIC_VERSION_UNSUPPORTED; 158 return QUIC_VERSION_UNSUPPORTED;
153 } 159 }
154 } 160 }
155 161
156 #define RETURN_STRING_LITERAL(x) \ 162 #define RETURN_STRING_LITERAL(x) \
157 case x: \ 163 case x: \
158 return #x 164 return #x
159 165
160 string QuicVersionToString(const QuicVersion version) { 166 string QuicVersionToString(const QuicVersion version) {
161 switch (version) { 167 switch (version) {
162 RETURN_STRING_LITERAL(QUIC_VERSION_7); 168 RETURN_STRING_LITERAL(QUIC_VERSION_7);
163 RETURN_STRING_LITERAL(QUIC_VERSION_8); 169 RETURN_STRING_LITERAL(QUIC_VERSION_8);
164 RETURN_STRING_LITERAL(QUIC_VERSION_9); 170 RETURN_STRING_LITERAL(QUIC_VERSION_9);
171 RETURN_STRING_LITERAL(QUIC_VERSION_10);
165 default: 172 default:
166 return "QUIC_VERSION_UNSUPPORTED"; 173 return "QUIC_VERSION_UNSUPPORTED";
167 } 174 }
168 } 175 }
169 176
170 string QuicVersionArrayToString(const QuicVersion versions[], 177 string QuicVersionArrayToString(const QuicVersion versions[],
171 int num_versions) { 178 int num_versions) {
172 string result = ""; 179 string result = "";
173 for (int i = 0; i < num_versions; ++i) { 180 for (int i = 0; i < num_versions; ++i) {
174 const QuicVersion& version = versions[i]; 181 const QuicVersion& version = versions[i];
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 const QuicFrame& frame) { 414 const QuicFrame& frame) {
408 DCHECK_NE(frame.type, STREAM_FRAME); 415 DCHECK_NE(frame.type, STREAM_FRAME);
409 frames_.push_back(frame); 416 frames_.push_back(frame);
410 return frames_.back(); 417 return frames_.back();
411 } 418 }
412 419
413 void RetransmittableFrames::set_encryption_level(EncryptionLevel level) { 420 void RetransmittableFrames::set_encryption_level(EncryptionLevel level) {
414 encryption_level_ = level; 421 encryption_level_ = level;
415 } 422 }
416 423
424 SerializedPacket::SerializedPacket(
425 QuicPacketSequenceNumber sequence_number,
426 QuicSequenceNumberLength sequence_number_length,
427 QuicPacket* packet,
428 QuicPacketEntropyHash entropy_hash,
429 RetransmittableFrames* retransmittable_frames)
430 : sequence_number(sequence_number),
431 sequence_number_length(sequence_number_length),
432 packet(packet),
433 entropy_hash(entropy_hash),
434 retransmittable_frames(retransmittable_frames) {
435 }
436
437 SerializedPacket::~SerializedPacket() {}
438
417 ostream& operator<<(ostream& os, const QuicEncryptedPacket& s) { 439 ostream& operator<<(ostream& os, const QuicEncryptedPacket& s) {
418 os << s.length() << "-byte data"; 440 os << s.length() << "-byte data";
419 return os; 441 return os;
420 } 442 }
421 443
422 ostream& operator<<(ostream& os, const QuicConsumedData& s) { 444 ostream& operator<<(ostream& os, const QuicConsumedData& s) {
423 os << "bytes_consumed: " << s.bytes_consumed 445 os << "bytes_consumed: " << s.bytes_consumed
424 << " fin_consumed: " << s.fin_consumed; 446 << " fin_consumed: " << s.fin_consumed;
425 return os; 447 return os;
426 } 448 }
427 449
428 } // namespace net 450 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_protocol.h ('k') | net/quic/quic_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698