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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // TODO(avd): remove this struct | 516 // TODO(avd): remove this struct |
517 // A CREDENTIAL Control Frame structure. | 517 // A CREDENTIAL Control Frame structure. |
518 struct SpdyCredentialControlFrameBlock : SpdyFrameBlock { | 518 struct SpdyCredentialControlFrameBlock : SpdyFrameBlock { |
519 uint16 slot_; | 519 uint16 slot_; |
520 uint32 proof_len_; | 520 uint32 proof_len_; |
521 // Variable data here. | 521 // Variable data here. |
522 // proof data | 522 // proof data |
523 // for each certificate: unit32 certificate_len + certificate_data[i] | 523 // for each certificate: unit32 certificate_len + certificate_data[i] |
524 }; | 524 }; |
525 | 525 |
526 // A GOAWAY Control Frame structure. | |
527 struct SpdyGoAwayControlFrameBlock : SpdyFrameBlock { | |
528 SpdyStreamId last_accepted_stream_id_; | |
529 SpdyGoAwayStatus status_; | |
530 }; | |
531 | |
532 // A HEADERS Control Frame structure. | 526 // A HEADERS Control Frame structure. |
533 struct SpdyHeadersControlFrameBlock : SpdyFrameBlock { | 527 struct SpdyHeadersControlFrameBlock : SpdyFrameBlock { |
534 SpdyStreamId stream_id_; | 528 SpdyStreamId stream_id_; |
535 }; | 529 }; |
536 | 530 |
537 // A WINDOW_UPDATE Control Frame structure | 531 // A WINDOW_UPDATE Control Frame structure |
538 struct SpdyWindowUpdateControlFrameBlock : SpdyFrameBlock { | 532 struct SpdyWindowUpdateControlFrameBlock : SpdyFrameBlock { |
539 SpdyStreamId stream_id_; | 533 SpdyStreamId stream_id_; |
540 uint32 delta_window_size_; | 534 uint32 delta_window_size_; |
541 }; | 535 }; |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 | 1203 |
1210 static size_t size() { return sizeof(SpdyCredentialControlFrameBlock); } | 1204 static size_t size() { return sizeof(SpdyCredentialControlFrameBlock); } |
1211 | 1205 |
1212 private: | 1206 private: |
1213 const struct SpdyCredentialControlFrameBlock* block() const { | 1207 const struct SpdyCredentialControlFrameBlock* block() const { |
1214 return static_cast<SpdyCredentialControlFrameBlock*>(frame_); | 1208 return static_cast<SpdyCredentialControlFrameBlock*>(frame_); |
1215 } | 1209 } |
1216 DISALLOW_COPY_AND_ASSIGN(SpdyCredentialControlFrame); | 1210 DISALLOW_COPY_AND_ASSIGN(SpdyCredentialControlFrame); |
1217 }; | 1211 }; |
1218 | 1212 |
1219 class SpdyGoAwayControlFrame : public SpdyControlFrame { | |
1220 public: | |
1221 SpdyGoAwayControlFrame() : SpdyControlFrame(size()) {} | |
1222 SpdyGoAwayControlFrame(char* data, bool owns_buffer) | |
1223 : SpdyControlFrame(data, owns_buffer) {} | |
1224 | |
1225 SpdyStreamId last_accepted_stream_id() const { | |
1226 return ntohl(block()->last_accepted_stream_id_) & kStreamIdMask; | |
1227 } | |
1228 | |
1229 SpdyGoAwayStatus status() const { | |
1230 if (version() < 3) { | |
1231 LOG(DFATAL) << "Attempted to access status of SPDY 2 GOAWAY."; | |
1232 return GOAWAY_INVALID; | |
1233 } else { | |
1234 uint32 status = ntohl(block()->status_); | |
1235 if (status >= GOAWAY_NUM_STATUS_CODES) { | |
1236 return GOAWAY_INVALID; | |
1237 } else { | |
1238 return static_cast<SpdyGoAwayStatus>(status); | |
1239 } | |
1240 } | |
1241 } | |
1242 | |
1243 static size_t size() { return sizeof(SpdyGoAwayControlFrameBlock); } | |
1244 | |
1245 private: | |
1246 const struct SpdyGoAwayControlFrameBlock* block() const { | |
1247 return static_cast<SpdyGoAwayControlFrameBlock*>(frame_); | |
1248 } | |
1249 struct SpdyGoAwayControlFrameBlock* mutable_block() { | |
1250 return static_cast<SpdyGoAwayControlFrameBlock*>(frame_); | |
1251 } | |
1252 DISALLOW_COPY_AND_ASSIGN(SpdyGoAwayControlFrame); | |
1253 }; | |
1254 | |
1255 // A HEADERS frame. | 1213 // A HEADERS frame. |
1256 class SpdyHeadersControlFrame : public SpdyControlFrame { | 1214 class SpdyHeadersControlFrame : public SpdyControlFrame { |
1257 public: | 1215 public: |
1258 SpdyHeadersControlFrame() : SpdyControlFrame(size()) {} | 1216 SpdyHeadersControlFrame() : SpdyControlFrame(size()) {} |
1259 SpdyHeadersControlFrame(char* data, bool owns_buffer) | 1217 SpdyHeadersControlFrame(char* data, bool owns_buffer) |
1260 : SpdyControlFrame(data, owns_buffer) {} | 1218 : SpdyControlFrame(data, owns_buffer) {} |
1261 | 1219 |
1262 SpdyStreamId stream_id() const { | 1220 SpdyStreamId stream_id() const { |
1263 return ntohl(block()->stream_id_) & kStreamIdMask; | 1221 return ntohl(block()->stream_id_) & kStreamIdMask; |
1264 } | 1222 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 struct SpdyWindowUpdateControlFrameBlock* mutable_block() { | 1275 struct SpdyWindowUpdateControlFrameBlock* mutable_block() { |
1318 return static_cast<SpdyWindowUpdateControlFrameBlock*>(frame_); | 1276 return static_cast<SpdyWindowUpdateControlFrameBlock*>(frame_); |
1319 } | 1277 } |
1320 | 1278 |
1321 DISALLOW_COPY_AND_ASSIGN(SpdyWindowUpdateControlFrame); | 1279 DISALLOW_COPY_AND_ASSIGN(SpdyWindowUpdateControlFrame); |
1322 }; | 1280 }; |
1323 | 1281 |
1324 } // namespace net | 1282 } // namespace net |
1325 | 1283 |
1326 #endif // NET_SPDY_SPDY_PROTOCOL_H_ | 1284 #endif // NET_SPDY_SPDY_PROTOCOL_H_ |
OLD | NEW |