OLD | NEW |
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 Loading... |
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 RST_STREAM Control Frame structure. | |
495 struct SpdyRstStreamControlFrameBlock : SpdyFrameBlock { | |
496 SpdyStreamId stream_id_; | |
497 uint32 status_; | |
498 }; | |
499 | |
500 // A SETTINGS Control Frame structure. | 494 // A SETTINGS Control Frame structure. |
501 struct SpdySettingsControlFrameBlock : SpdyFrameBlock { | 495 struct SpdySettingsControlFrameBlock : SpdyFrameBlock { |
502 uint32 num_entries_; | 496 uint32 num_entries_; |
503 // Variable data here. | 497 // Variable data here. |
504 }; | 498 }; |
505 | 499 |
506 // TODO(avd): remove this struct | 500 // TODO(avd): remove this struct |
507 // A CREDENTIAL Control Frame structure. | 501 // A CREDENTIAL Control Frame structure. |
508 struct SpdyCredentialControlFrameBlock : SpdyFrameBlock { | 502 struct SpdyCredentialControlFrameBlock : SpdyFrameBlock { |
509 uint16 slot_; | 503 uint16 slot_; |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 private: | 1025 private: |
1032 const struct SpdySynStreamControlFrameBlock* block() const { | 1026 const struct SpdySynStreamControlFrameBlock* block() const { |
1033 return static_cast<SpdySynStreamControlFrameBlock*>(frame_); | 1027 return static_cast<SpdySynStreamControlFrameBlock*>(frame_); |
1034 } | 1028 } |
1035 struct SpdySynStreamControlFrameBlock* mutable_block() { | 1029 struct SpdySynStreamControlFrameBlock* mutable_block() { |
1036 return static_cast<SpdySynStreamControlFrameBlock*>(frame_); | 1030 return static_cast<SpdySynStreamControlFrameBlock*>(frame_); |
1037 } | 1031 } |
1038 DISALLOW_COPY_AND_ASSIGN(SpdySynStreamControlFrame); | 1032 DISALLOW_COPY_AND_ASSIGN(SpdySynStreamControlFrame); |
1039 }; | 1033 }; |
1040 | 1034 |
1041 // A RST_STREAM frame. | |
1042 class SpdyRstStreamControlFrame : public SpdyControlFrame { | |
1043 public: | |
1044 SpdyRstStreamControlFrame() : SpdyControlFrame(size()) {} | |
1045 SpdyRstStreamControlFrame(char* data, bool owns_buffer) | |
1046 : SpdyControlFrame(data, owns_buffer) {} | |
1047 | |
1048 SpdyStreamId stream_id() const { | |
1049 return ntohl(block()->stream_id_) & kStreamIdMask; | |
1050 } | |
1051 | |
1052 SpdyRstStreamStatus status() const { | |
1053 SpdyRstStreamStatus status = | |
1054 static_cast<SpdyRstStreamStatus>(ntohl(block()->status_)); | |
1055 if (status < RST_STREAM_INVALID || status >= RST_STREAM_NUM_STATUS_CODES) { | |
1056 status = RST_STREAM_INVALID; | |
1057 } | |
1058 return status; | |
1059 } | |
1060 void set_status(SpdyRstStreamStatus status) { | |
1061 mutable_block()->status_ = htonl(static_cast<uint32>(status)); | |
1062 } | |
1063 | |
1064 // Returns the size of the SpdyRstStreamControlFrameBlock structure. | |
1065 // Note: this is not the size of the SpdyRstStreamControlFrame class. | |
1066 static size_t size() { return sizeof(SpdyRstStreamControlFrameBlock); } | |
1067 | |
1068 private: | |
1069 const struct SpdyRstStreamControlFrameBlock* block() const { | |
1070 return static_cast<SpdyRstStreamControlFrameBlock*>(frame_); | |
1071 } | |
1072 struct SpdyRstStreamControlFrameBlock* mutable_block() { | |
1073 return static_cast<SpdyRstStreamControlFrameBlock*>(frame_); | |
1074 } | |
1075 DISALLOW_COPY_AND_ASSIGN(SpdyRstStreamControlFrame); | |
1076 }; | |
1077 | |
1078 class SpdySettingsControlFrame : public SpdyControlFrame { | 1035 class SpdySettingsControlFrame : public SpdyControlFrame { |
1079 public: | 1036 public: |
1080 SpdySettingsControlFrame() : SpdyControlFrame(size()) {} | 1037 SpdySettingsControlFrame() : SpdyControlFrame(size()) {} |
1081 SpdySettingsControlFrame(char* data, bool owns_buffer) | 1038 SpdySettingsControlFrame(char* data, bool owns_buffer) |
1082 : SpdyControlFrame(data, owns_buffer) {} | 1039 : SpdyControlFrame(data, owns_buffer) {} |
1083 | 1040 |
1084 uint32 num_entries() const { | 1041 uint32 num_entries() const { |
1085 return ntohl(block()->num_entries_); | 1042 return ntohl(block()->num_entries_); |
1086 } | 1043 } |
1087 | 1044 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 } | 1114 } |
1158 struct SpdyHeadersControlFrameBlock* mutable_block() { | 1115 struct SpdyHeadersControlFrameBlock* mutable_block() { |
1159 return static_cast<SpdyHeadersControlFrameBlock*>(frame_); | 1116 return static_cast<SpdyHeadersControlFrameBlock*>(frame_); |
1160 } | 1117 } |
1161 DISALLOW_COPY_AND_ASSIGN(SpdyHeadersControlFrame); | 1118 DISALLOW_COPY_AND_ASSIGN(SpdyHeadersControlFrame); |
1162 }; | 1119 }; |
1163 | 1120 |
1164 } // namespace net | 1121 } // namespace net |
1165 | 1122 |
1166 #endif // NET_SPDY_SPDY_PROTOCOL_H_ | 1123 #endif // NET_SPDY_SPDY_PROTOCOL_H_ |
OLD | NEW |