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 2 and 3 | 5 // This file contains some protocol structures for use with SPDY 2 and 3 |
6 // The SPDY 2 spec can be found at: | 6 // The SPDY 2 spec can be found at: |
7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft2 | 7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft2 |
8 // The SPDY 3 spec can be found at: | 8 // The SPDY 3 spec can be found at: |
9 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 | 9 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 |
10 | 10 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 329 |
330 // Flags for settings within a SETTINGS frame. | 330 // Flags for settings within a SETTINGS frame. |
331 enum SpdySettingsFlags { | 331 enum SpdySettingsFlags { |
332 SETTINGS_FLAG_NONE = 0x0, | 332 SETTINGS_FLAG_NONE = 0x0, |
333 SETTINGS_FLAG_PLEASE_PERSIST = 0x1, | 333 SETTINGS_FLAG_PLEASE_PERSIST = 0x1, |
334 SETTINGS_FLAG_PERSISTED = 0x2 | 334 SETTINGS_FLAG_PERSISTED = 0x2 |
335 }; | 335 }; |
336 | 336 |
337 // List of known settings. | 337 // List of known settings. |
338 enum SpdySettingsIds { | 338 enum SpdySettingsIds { |
339 SETTINGS_UPLOAD_BANDWIDTH = 0x1, | 339 SETTINGS_UPLOAD_BANDWIDTH, |
340 SETTINGS_DOWNLOAD_BANDWIDTH = 0x2, | 340 SETTINGS_DOWNLOAD_BANDWIDTH, |
341 // Network round trip time in milliseconds. | 341 // Network round trip time in milliseconds. |
342 SETTINGS_ROUND_TRIP_TIME = 0x3, | 342 SETTINGS_ROUND_TRIP_TIME, |
343 SETTINGS_MAX_CONCURRENT_STREAMS = 0x4, | 343 // The maximum number of simultaneous live streams in each direction. |
| 344 SETTINGS_MAX_CONCURRENT_STREAMS, |
344 // TCP congestion window in packets. | 345 // TCP congestion window in packets. |
345 SETTINGS_CURRENT_CWND = 0x5, | 346 SETTINGS_CURRENT_CWND, |
346 // Downstream byte retransmission rate in percentage. | 347 // Downstream byte retransmission rate in percentage. |
347 SETTINGS_DOWNLOAD_RETRANS_RATE = 0x6, | 348 SETTINGS_DOWNLOAD_RETRANS_RATE, |
348 // Initial window size in bytes | 349 // Initial window size in bytes |
349 SETTINGS_INITIAL_WINDOW_SIZE = 0x7 | 350 SETTINGS_INITIAL_WINDOW_SIZE, |
| 351 // HPACK header table maximum size. |
| 352 SETTINGS_HEADER_TABLE_SIZE, |
| 353 // Whether or not server push (PUSH_PROMISE) is enabled. |
| 354 SETTINGS_ENABLE_PUSH, |
350 }; | 355 }; |
351 | 356 |
352 // Status codes for RST_STREAM frames. | 357 // Status codes for RST_STREAM frames. |
353 enum SpdyRstStreamStatus { | 358 enum SpdyRstStreamStatus { |
354 RST_STREAM_INVALID = 0, | 359 RST_STREAM_INVALID = 0, |
355 RST_STREAM_PROTOCOL_ERROR = 1, | 360 RST_STREAM_PROTOCOL_ERROR = 1, |
356 RST_STREAM_INVALID_STREAM = 2, | 361 RST_STREAM_INVALID_STREAM = 2, |
357 RST_STREAM_REFUSED_STREAM = 3, | 362 RST_STREAM_REFUSED_STREAM = 3, |
358 RST_STREAM_UNSUPPORTED_VERSION = 4, | 363 RST_STREAM_UNSUPPORTED_VERSION = 4, |
359 RST_STREAM_CANCEL = 5, | 364 RST_STREAM_CANCEL = 5, |
(...skipping 19 matching lines...) Expand all Loading... |
379 // SPDY priority range is version-dependent. For SPDY 2 and below, priority is a | 384 // SPDY priority range is version-dependent. For SPDY 2 and below, priority is a |
380 // number between 0 and 3. | 385 // number between 0 and 3. |
381 typedef uint8 SpdyPriority; | 386 typedef uint8 SpdyPriority; |
382 | 387 |
383 typedef std::map<std::string, std::string> SpdyNameValueBlock; | 388 typedef std::map<std::string, std::string> SpdyNameValueBlock; |
384 | 389 |
385 typedef uint64 SpdyPingId; | 390 typedef uint64 SpdyPingId; |
386 | 391 |
387 // TODO(hkhalil): Add direct testing for this? It won't increase coverage any, | 392 // TODO(hkhalil): Add direct testing for this? It won't increase coverage any, |
388 // but is good to do anyway. | 393 // but is good to do anyway. |
389 class SpdyConstants { | 394 class NET_EXPORT_PRIVATE SpdyConstants { |
390 public: | 395 public: |
391 // Returns true if a given on-the-wire enumeration of a frame type is valid | 396 // Returns true if a given on-the-wire enumeration of a frame type is valid |
392 // for a given protocol version, false otherwise. | 397 // for a given protocol version, false otherwise. |
393 static bool IsValidFrameType(SpdyMajorVersion version, int frame_type_field); | 398 static bool IsValidFrameType(SpdyMajorVersion version, int frame_type_field); |
394 | 399 |
395 // Parses a frame type from an on-the-wire enumeration of a given protocol | 400 // Parses a frame type from an on-the-wire enumeration of a given protocol |
396 // version. | 401 // version. |
397 // Behavior is undefined for invalid frame type fields; consumers should first | 402 // Behavior is undefined for invalid frame type fields; consumers should first |
398 // use IsValidFrameType() to verify validity of frame type fields. | 403 // use IsValidFrameType() to verify validity of frame type fields. |
399 static SpdyFrameType ParseFrameType(SpdyMajorVersion version, | 404 static SpdyFrameType ParseFrameType(SpdyMajorVersion version, |
400 int frame_type_field); | 405 int frame_type_field); |
401 | 406 |
402 // Serializes a given frame type to the on-the-wire enumeration value for the | 407 // Serializes a given frame type to the on-the-wire enumeration value for the |
403 // given protocol version. | 408 // given protocol version. |
404 // Returns -1 on failure (I.E. Invalid frame type for the given version). | 409 // Returns -1 on failure (I.E. Invalid frame type for the given version). |
405 static int SerializeFrameType(SpdyMajorVersion version, | 410 static int SerializeFrameType(SpdyMajorVersion version, |
406 SpdyFrameType frame_type); | 411 SpdyFrameType frame_type); |
| 412 |
| 413 // Returns true if a given on-the-wire enumeration of a setting id is valid |
| 414 // for a given protocol version, false otherwise. |
| 415 static bool IsValidSettingId(SpdyMajorVersion version, int setting_id_field); |
| 416 |
| 417 // Parses a setting id from an on-the-wire enumeration of a given protocol |
| 418 // version. |
| 419 // Behavior is undefined for invalid setting id fields; consumers should first |
| 420 // use IsValidSettingId() to verify validity of setting id fields. |
| 421 static SpdySettingsIds ParseSettingId(SpdyMajorVersion version, |
| 422 int setting_id_field); |
| 423 |
| 424 // Serializes a given setting id to the on-the-wire enumeration value for the |
| 425 // given protocol version. |
| 426 // Returns -1 on failure (I.E. Invalid setting id for the given version). |
| 427 static int SerializeSettingId(SpdyMajorVersion version, SpdySettingsIds id); |
407 }; | 428 }; |
408 | 429 |
409 class SpdyFrame; | 430 class SpdyFrame; |
410 typedef SpdyFrame SpdySerializedFrame; | 431 typedef SpdyFrame SpdySerializedFrame; |
411 | 432 |
412 class SpdyFrameVisitor; | 433 class SpdyFrameVisitor; |
413 | 434 |
414 // Intermediate representation for SPDY frames. | 435 // Intermediate representation for SPDY frames. |
415 // TODO(hkhalil): Rename this class to SpdyFrame when the existing SpdyFrame is | 436 // TODO(hkhalil): Rename this class to SpdyFrame when the existing SpdyFrame is |
416 // gone. | 437 // gone. |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 SpdySettingsIR(); | 668 SpdySettingsIR(); |
648 | 669 |
649 virtual ~SpdySettingsIR(); | 670 virtual ~SpdySettingsIR(); |
650 | 671 |
651 // Overwrites as appropriate. | 672 // Overwrites as appropriate. |
652 const ValueMap& values() const { return values_; } | 673 const ValueMap& values() const { return values_; } |
653 void AddSetting(SpdySettingsIds id, | 674 void AddSetting(SpdySettingsIds id, |
654 bool persist_value, | 675 bool persist_value, |
655 bool persisted, | 676 bool persisted, |
656 int32 value) { | 677 int32 value) { |
657 // TODO(hkhalil): DCHECK_LE(SETTINGS_UPLOAD_BANDWIDTH, id); | |
658 // TODO(hkhalil): DCHECK_GE(SETTINGS_INITIAL_WINDOW_SIZE, id); | |
659 values_[id].persist_value = persist_value; | 678 values_[id].persist_value = persist_value; |
660 values_[id].persisted = persisted; | 679 values_[id].persisted = persisted; |
661 values_[id].value = value; | 680 values_[id].value = value; |
662 } | 681 } |
663 | 682 |
664 bool clear_settings() const { return clear_settings_; } | 683 bool clear_settings() const { return clear_settings_; } |
665 void set_clear_settings(bool clear_settings) { | 684 void set_clear_settings(bool clear_settings) { |
666 clear_settings_ = clear_settings; | 685 clear_settings_ = clear_settings; |
667 } | 686 } |
668 bool is_ack() const { return is_ack_; } | 687 bool is_ack() const { return is_ack_; } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 SpdyFrameVisitor() {} | 911 SpdyFrameVisitor() {} |
893 virtual ~SpdyFrameVisitor() {} | 912 virtual ~SpdyFrameVisitor() {} |
894 | 913 |
895 private: | 914 private: |
896 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); | 915 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); |
897 }; | 916 }; |
898 | 917 |
899 } // namespace net | 918 } // namespace net |
900 | 919 |
901 #endif // NET_SPDY_SPDY_PROTOCOL_H_ | 920 #endif // NET_SPDY_SPDY_PROTOCOL_H_ |
OLD | NEW |