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

Side by Side Diff: net/spdy/spdy_protocol.cc

Issue 485833002: HTTP2 draft 14 support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ignore_result(). Created 6 years, 4 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/spdy/spdy_protocol.h ('k') | net/spdy/spdy_session.h » ('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/spdy/spdy_protocol.h" 5 #include "net/spdy/spdy_protocol.h"
6 6
7 namespace net { 7 namespace net {
8 8
9 SpdyFrameWithNameValueBlockIR::SpdyFrameWithNameValueBlockIR( 9 SpdyFrameWithNameValueBlockIR::SpdyFrameWithNameValueBlockIR(
10 SpdyStreamId stream_id) : SpdyFrameWithFinIR(stream_id) {} 10 SpdyStreamId stream_id) : SpdyFrameWithFinIR(stream_id) {}
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 // WINDOW_UPDATE is the last valid frame. 38 // WINDOW_UPDATE is the last valid frame.
39 if (frame_type_field > SerializeFrameType(version, WINDOW_UPDATE)) { 39 if (frame_type_field > SerializeFrameType(version, WINDOW_UPDATE)) {
40 return false; 40 return false;
41 } 41 }
42 42
43 return true; 43 return true;
44 case SPDY4: 44 case SPDY4:
45 case SPDY5: 45 case SPDY5:
46 // Check for recognized extensions.
47 if (frame_type_field == SerializeFrameType(version, ALTSVC) ||
48 frame_type_field == SerializeFrameType(version, BLOCKED)) {
49 return true;
50 }
51
46 // DATA is the first valid frame. 52 // DATA is the first valid frame.
47 if (frame_type_field < SerializeFrameType(version, DATA)) { 53 if (frame_type_field < SerializeFrameType(version, DATA)) {
48 return false; 54 return false;
49 } 55 }
50 56
51 // BLOCKED is the last valid frame. 57 // CONTINUATION is the last valid frame.
52 if (frame_type_field > SerializeFrameType(version, BLOCKED)) { 58 if (frame_type_field > SerializeFrameType(version, CONTINUATION)) {
53 return false; 59 return false;
54 } 60 }
55 61
56 return true; 62 return true;
57 } 63 }
58 64
59 LOG(DFATAL) << "Unhandled SPDY version " << version; 65 LOG(DFATAL) << "Unhandled SPDY version " << version;
60 return false; 66 return false;
61 } 67 }
62 68
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 case PUSH_PROMISE: 167 case PUSH_PROMISE:
162 return 5; 168 return 5;
163 case PING: 169 case PING:
164 return 6; 170 return 6;
165 case GOAWAY: 171 case GOAWAY:
166 return 7; 172 return 7;
167 case WINDOW_UPDATE: 173 case WINDOW_UPDATE:
168 return 8; 174 return 8;
169 case CONTINUATION: 175 case CONTINUATION:
170 return 9; 176 return 9;
177 // ALTSVC and BLOCKED are extensions.
171 case ALTSVC: 178 case ALTSVC:
172 return 10; 179 return 10;
173 case BLOCKED: 180 case BLOCKED:
174 return 11; 181 return 11;
175 default: 182 default:
176 LOG(DFATAL) << "Serializing unhandled frame type " << frame_type; 183 LOG(DFATAL) << "Serializing unhandled frame type " << frame_type;
177 return -1; 184 return -1;
178 } 185 }
179 } 186 }
180 187
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 222
216 return true; 223 return true;
217 case SPDY4: 224 case SPDY4:
218 case SPDY5: 225 case SPDY5:
219 // HEADER_TABLE_SIZE is the first valid setting id. 226 // HEADER_TABLE_SIZE is the first valid setting id.
220 if (setting_id_field < 227 if (setting_id_field <
221 SerializeSettingId(version, SETTINGS_HEADER_TABLE_SIZE)) { 228 SerializeSettingId(version, SETTINGS_HEADER_TABLE_SIZE)) {
222 return false; 229 return false;
223 } 230 }
224 231
225 // INITIAL_WINDOW_SIZE is the last valid setting id. 232 // MAX_HEADER_LIST_SIZE is the last valid setting id.
226 if (setting_id_field > 233 if (setting_id_field >
227 SerializeSettingId(version, SETTINGS_INITIAL_WINDOW_SIZE)) { 234 SerializeSettingId(version, SETTINGS_MAX_HEADER_LIST_SIZE)) {
228 return false; 235 return false;
229 } 236 }
230 237
231 return true; 238 return true;
232 } 239 }
233 240
234 LOG(DFATAL) << "Unhandled SPDY version " << version; 241 LOG(DFATAL) << "Unhandled SPDY version " << version;
235 return false; 242 return false;
236 } 243 }
237 244
(...skipping 23 matching lines...) Expand all
261 case SPDY5: 268 case SPDY5:
262 switch (setting_id_field) { 269 switch (setting_id_field) {
263 case 1: 270 case 1:
264 return SETTINGS_HEADER_TABLE_SIZE; 271 return SETTINGS_HEADER_TABLE_SIZE;
265 case 2: 272 case 2:
266 return SETTINGS_ENABLE_PUSH; 273 return SETTINGS_ENABLE_PUSH;
267 case 3: 274 case 3:
268 return SETTINGS_MAX_CONCURRENT_STREAMS; 275 return SETTINGS_MAX_CONCURRENT_STREAMS;
269 case 4: 276 case 4:
270 return SETTINGS_INITIAL_WINDOW_SIZE; 277 return SETTINGS_INITIAL_WINDOW_SIZE;
278 case 5:
279 return SETTINGS_MAX_FRAME_SIZE;
280 case 6:
281 return SETTINGS_MAX_HEADER_LIST_SIZE;
271 } 282 }
272 break; 283 break;
273 } 284 }
274 285
275 LOG(DFATAL) << "Unhandled setting ID " << setting_id_field; 286 LOG(DFATAL) << "Unhandled setting ID " << setting_id_field;
276 return SETTINGS_UPLOAD_BANDWIDTH; 287 return SETTINGS_UPLOAD_BANDWIDTH;
277 } 288 }
278 289
279 int SpdyConstants::SerializeSettingId(SpdyMajorVersion version, 290 int SpdyConstants::SerializeSettingId(SpdyMajorVersion version,
280 SpdySettingsIds id) { 291 SpdySettingsIds id) {
(...skipping 23 matching lines...) Expand all
304 case SPDY5: 315 case SPDY5:
305 switch (id) { 316 switch (id) {
306 case SETTINGS_HEADER_TABLE_SIZE: 317 case SETTINGS_HEADER_TABLE_SIZE:
307 return 1; 318 return 1;
308 case SETTINGS_ENABLE_PUSH: 319 case SETTINGS_ENABLE_PUSH:
309 return 2; 320 return 2;
310 case SETTINGS_MAX_CONCURRENT_STREAMS: 321 case SETTINGS_MAX_CONCURRENT_STREAMS:
311 return 3; 322 return 3;
312 case SETTINGS_INITIAL_WINDOW_SIZE: 323 case SETTINGS_INITIAL_WINDOW_SIZE:
313 return 4; 324 return 4;
325 case SETTINGS_MAX_FRAME_SIZE:
326 return 5;
327 case SETTINGS_MAX_HEADER_LIST_SIZE:
328 return 6;
314 default: 329 default:
315 LOG(DFATAL) << "Serializing unhandled setting id " << id; 330 LOG(DFATAL) << "Serializing unhandled setting id " << id;
316 return -1; 331 return -1;
317 } 332 }
318 } 333 }
319 LOG(DFATAL) << "Unhandled SPDY version " << version; 334 LOG(DFATAL) << "Unhandled SPDY version " << version;
320 return -1; 335 return -1;
321 } 336 }
322 337
323 bool SpdyConstants::IsValidRstStreamStatus(SpdyMajorVersion version, 338 bool SpdyConstants::IsValidRstStreamStatus(SpdyMajorVersion version,
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 return 12; 702 return 12;
688 default: 703 default:
689 LOG(DFATAL) << "Serializing unhandled GOAWAY status " << status; 704 LOG(DFATAL) << "Serializing unhandled GOAWAY status " << status;
690 return -1; 705 return -1;
691 } 706 }
692 } 707 }
693 LOG(DFATAL) << "Unknown SpdyMajorVersion " << version; 708 LOG(DFATAL) << "Unknown SpdyMajorVersion " << version;
694 return -1; 709 return -1;
695 } 710 }
696 711
697 size_t SpdyConstants::GetDataFrameMinimumSize() { 712 size_t SpdyConstants::GetDataFrameMinimumSize(SpdyMajorVersion version) {
698 return 8; 713 switch (version) {
714 case SPDY2:
715 case SPDY3:
716 return 8;
717 case SPDY4:
718 case SPDY5:
719 return 9;
720 }
721 LOG(DFATAL) << "Unhandled SPDY version.";
722 return 0;
699 } 723 }
700 724
701 size_t SpdyConstants::GetControlFrameHeaderSize(SpdyMajorVersion version) { 725 size_t SpdyConstants::GetControlFrameHeaderSize(SpdyMajorVersion version) {
702 switch (version) { 726 switch (version) {
703 case SPDY2: 727 case SPDY2:
704 case SPDY3: 728 case SPDY3:
729 return 8;
705 case SPDY4: 730 case SPDY4:
706 case SPDY5: 731 case SPDY5:
707 return 8; 732 return 9;
708 } 733 }
709 LOG(DFATAL) << "Unhandled SPDY version."; 734 LOG(DFATAL) << "Unhandled SPDY version.";
710 return 0; 735 return 0;
711 } 736 }
712 737
713 size_t SpdyConstants::GetPrefixLength(SpdyFrameType type, 738 size_t SpdyConstants::GetPrefixLength(SpdyFrameType type,
714 SpdyMajorVersion version) { 739 SpdyMajorVersion version) {
715 if (type != DATA) { 740 if (type != DATA) {
716 return GetControlFrameHeaderSize(version); 741 return GetControlFrameHeaderSize(version);
717 } else { 742 } else {
718 return GetDataFrameMinimumSize(); 743 return GetDataFrameMinimumSize(version);
719 } 744 }
720 } 745 }
721 746
722 size_t SpdyConstants::GetFrameMaximumSize(SpdyMajorVersion version) { 747 size_t SpdyConstants::GetFrameMaximumSize(SpdyMajorVersion version) {
723 if (version < SPDY4) { 748 if (version < SPDY4) {
724 // 24-bit length field plus eight-byte frame header. 749 // 24-bit length field plus eight-byte frame header.
725 return ((1<<24) - 1) + 8; 750 return ((1<<24) - 1) + 8;
726 } else { 751 } else {
727 // 14-bit length field. 752 // Max payload of 2^14 plus nine-byte frame header.
728 return (1<<14) - 1; 753 // TODO(mlavan): In HTTP/2 this is actually not a constant;
754 // payload size can be set using the MAX_FRAME_SIZE setting to
755 // anything between 1 << 14 and (1 << 24) - 1
756 return (1 << 14) + 9;
729 } 757 }
730 } 758 }
731 759
732 size_t SpdyConstants::GetSizeOfSizeField(SpdyMajorVersion version) { 760 size_t SpdyConstants::GetSizeOfSizeField(SpdyMajorVersion version) {
733 return (version < SPDY3) ? sizeof(uint16) : sizeof(uint32); 761 return (version < SPDY3) ? sizeof(uint16) : sizeof(uint32);
734 } 762 }
735 763
736 size_t SpdyConstants::GetSettingSize(SpdyMajorVersion version) { 764 size_t SpdyConstants::GetSettingSize(SpdyMajorVersion version) {
737 return version <= SPDY3 ? 8 : 6; 765 return version <= SPDY3 ? 8 : 6;
738 } 766 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 parent_stream_id_(parent_stream_id), 864 parent_stream_id_(parent_stream_id),
837 weight_(weight), 865 weight_(weight),
838 exclusive_(exclusive) { 866 exclusive_(exclusive) {
839 } 867 }
840 868
841 void SpdyPriorityIR::Visit(SpdyFrameVisitor* visitor) const { 869 void SpdyPriorityIR::Visit(SpdyFrameVisitor* visitor) const {
842 return visitor->VisitPriority(*this); 870 return visitor->VisitPriority(*this);
843 } 871 }
844 872
845 } // namespace net 873 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_protocol.h ('k') | net/spdy/spdy_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698