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

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

Issue 12259003: Clean up the last remaining bits of SpdySynReplyControlFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol_test.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 // This file contains some protocol structures for use with Spdy. 5 // This file contains some protocol structures for use with Spdy.
6 6
7 #ifndef NET_SPDY_SPDY_PROTOCOL_H_ 7 #ifndef NET_SPDY_SPDY_PROTOCOL_H_
8 #define NET_SPDY_SPDY_PROTOCOL_H_ 8 #define NET_SPDY_SPDY_PROTOCOL_H_
9 9
10 #include <limits> 10 #include <limits>
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 }; 484 };
485 485
486 // A SYN_STREAM Control Frame structure. 486 // A SYN_STREAM Control Frame structure.
487 struct SpdySynStreamControlFrameBlock : SpdyFrameBlock { 487 struct SpdySynStreamControlFrameBlock : SpdyFrameBlock {
488 SpdyStreamId stream_id_; 488 SpdyStreamId stream_id_;
489 SpdyStreamId associated_stream_id_; 489 SpdyStreamId associated_stream_id_;
490 SpdyPriority priority_; 490 SpdyPriority priority_;
491 uint8 credential_slot_; 491 uint8 credential_slot_;
492 }; 492 };
493 493
494 // A SYN_REPLY Control Frame structure.
495 struct SpdySynReplyControlFrameBlock : SpdyFrameBlock {
496 SpdyStreamId stream_id_;
497 };
498
499 // A RST_STREAM Control Frame structure. 494 // A RST_STREAM Control Frame structure.
500 struct SpdyRstStreamControlFrameBlock : SpdyFrameBlock { 495 struct SpdyRstStreamControlFrameBlock : SpdyFrameBlock {
501 SpdyStreamId stream_id_; 496 SpdyStreamId stream_id_;
502 uint32 status_; 497 uint32 status_;
503 }; 498 };
504 499
505 // A SETTINGS Control Frame structure. 500 // A SETTINGS Control Frame structure.
506 struct SpdySettingsControlFrameBlock : SpdyFrameBlock { 501 struct SpdySettingsControlFrameBlock : SpdyFrameBlock {
507 uint32 num_entries_; 502 uint32 num_entries_;
508 // Variable data here. 503 // Variable data here.
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 private: 1042 private:
1048 const struct SpdySynStreamControlFrameBlock* block() const { 1043 const struct SpdySynStreamControlFrameBlock* block() const {
1049 return static_cast<SpdySynStreamControlFrameBlock*>(frame_); 1044 return static_cast<SpdySynStreamControlFrameBlock*>(frame_);
1050 } 1045 }
1051 struct SpdySynStreamControlFrameBlock* mutable_block() { 1046 struct SpdySynStreamControlFrameBlock* mutable_block() {
1052 return static_cast<SpdySynStreamControlFrameBlock*>(frame_); 1047 return static_cast<SpdySynStreamControlFrameBlock*>(frame_);
1053 } 1048 }
1054 DISALLOW_COPY_AND_ASSIGN(SpdySynStreamControlFrame); 1049 DISALLOW_COPY_AND_ASSIGN(SpdySynStreamControlFrame);
1055 }; 1050 };
1056 1051
1057 // A SYN_REPLY frame.
1058 class SpdySynReplyControlFrame : public SpdyControlFrame {
1059 public:
1060 SpdySynReplyControlFrame() : SpdyControlFrame(size()) {}
1061 SpdySynReplyControlFrame(char* data, bool owns_buffer)
1062 : SpdyControlFrame(data, owns_buffer) {}
1063
1064 SpdyStreamId stream_id() const {
1065 return ntohl(block()->stream_id_) & kStreamIdMask;
1066 }
1067
1068 int header_block_len() const {
1069 size_t header_block_len = length() - (size() - SpdyFrame::kHeaderSize);
1070 // SPDY 2 had 2 bytes of unused space preceeding the header block.
1071 if (version() < 3) {
1072 header_block_len -= 2;
1073 }
1074 return header_block_len;
1075 }
1076
1077 const char* header_block() const {
1078 const char* header_block = reinterpret_cast<const char*>(block()) + size();
1079 // SPDY 2 had 2 bytes of unused space preceeding the header block.
1080 if (version() < 3) {
1081 header_block += 2;
1082 }
1083 return header_block;
1084 }
1085
1086 // Returns the size of the SpdySynReplyControlFrameBlock structure.
1087 // Note: this is not the size of the SpdySynReplyControlFrame class.
1088 static size_t size() { return sizeof(SpdySynReplyControlFrameBlock); }
1089
1090 private:
1091 const struct SpdySynReplyControlFrameBlock* block() const {
1092 return static_cast<SpdySynReplyControlFrameBlock*>(frame_);
1093 }
1094 struct SpdySynReplyControlFrameBlock* mutable_block() {
1095 return static_cast<SpdySynReplyControlFrameBlock*>(frame_);
1096 }
1097 DISALLOW_COPY_AND_ASSIGN(SpdySynReplyControlFrame);
1098 };
1099
1100 // A RST_STREAM frame. 1052 // A RST_STREAM frame.
1101 class SpdyRstStreamControlFrame : public SpdyControlFrame { 1053 class SpdyRstStreamControlFrame : public SpdyControlFrame {
1102 public: 1054 public:
1103 SpdyRstStreamControlFrame() : SpdyControlFrame(size()) {} 1055 SpdyRstStreamControlFrame() : SpdyControlFrame(size()) {}
1104 SpdyRstStreamControlFrame(char* data, bool owns_buffer) 1056 SpdyRstStreamControlFrame(char* data, bool owns_buffer)
1105 : SpdyControlFrame(data, owns_buffer) {} 1057 : SpdyControlFrame(data, owns_buffer) {}
1106 1058
1107 SpdyStreamId stream_id() const { 1059 SpdyStreamId stream_id() const {
1108 return ntohl(block()->stream_id_) & kStreamIdMask; 1060 return ntohl(block()->stream_id_) & kStreamIdMask;
1109 } 1061 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 struct SpdyWindowUpdateControlFrameBlock* mutable_block() { 1227 struct SpdyWindowUpdateControlFrameBlock* mutable_block() {
1276 return static_cast<SpdyWindowUpdateControlFrameBlock*>(frame_); 1228 return static_cast<SpdyWindowUpdateControlFrameBlock*>(frame_);
1277 } 1229 }
1278 1230
1279 DISALLOW_COPY_AND_ASSIGN(SpdyWindowUpdateControlFrame); 1231 DISALLOW_COPY_AND_ASSIGN(SpdyWindowUpdateControlFrame);
1280 }; 1232 };
1281 1233
1282 } // namespace net 1234 } // namespace net
1283 1235
1284 #endif // NET_SPDY_SPDY_PROTOCOL_H_ 1236 #endif // NET_SPDY_SPDY_PROTOCOL_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698