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

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

Issue 243643002: Refactor RST_STREAM status code handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Expanded FRAME_TOO_LARGE/FRAME_SIZE_ERROR comment. Created 6 years, 7 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_test.cc ('k') | net/spdy/spdy_protocol.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 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 SETTINGS_HEADER_TABLE_SIZE = 0x8, 353 SETTINGS_HEADER_TABLE_SIZE = 0x8,
354 // Whether or not server push (PUSH_PROMISE) is enabled. 354 // Whether or not server push (PUSH_PROMISE) is enabled.
355 SETTINGS_ENABLE_PUSH = 0x9, 355 SETTINGS_ENABLE_PUSH = 0x9,
356 }; 356 };
357 357
358 // Status codes for RST_STREAM frames. 358 // Status codes for RST_STREAM frames.
359 enum SpdyRstStreamStatus { 359 enum SpdyRstStreamStatus {
360 RST_STREAM_INVALID = 0, 360 RST_STREAM_INVALID = 0,
361 RST_STREAM_PROTOCOL_ERROR = 1, 361 RST_STREAM_PROTOCOL_ERROR = 1,
362 RST_STREAM_INVALID_STREAM = 2, 362 RST_STREAM_INVALID_STREAM = 2,
363 RST_STREAM_STREAM_CLOSED = 2, // Equivalent to INVALID_STREAM
363 RST_STREAM_REFUSED_STREAM = 3, 364 RST_STREAM_REFUSED_STREAM = 3,
364 RST_STREAM_UNSUPPORTED_VERSION = 4, 365 RST_STREAM_UNSUPPORTED_VERSION = 4,
365 RST_STREAM_CANCEL = 5, 366 RST_STREAM_CANCEL = 5,
366 RST_STREAM_INTERNAL_ERROR = 6, 367 RST_STREAM_INTERNAL_ERROR = 6,
367 RST_STREAM_FLOW_CONTROL_ERROR = 7, 368 RST_STREAM_FLOW_CONTROL_ERROR = 7,
368 RST_STREAM_STREAM_IN_USE = 8, 369 RST_STREAM_STREAM_IN_USE = 8,
369 RST_STREAM_STREAM_ALREADY_CLOSED = 9, 370 RST_STREAM_STREAM_ALREADY_CLOSED = 9,
370 RST_STREAM_INVALID_CREDENTIALS = 10, 371 RST_STREAM_INVALID_CREDENTIALS = 10,
372 // FRAME_TOO_LARGE (defined by SPDY versions 3.1 and below), and
373 // FRAME_SIZE_ERROR (defined by HTTP/2) are mapped to the same internal
374 // reset status.
371 RST_STREAM_FRAME_TOO_LARGE = 11, 375 RST_STREAM_FRAME_TOO_LARGE = 11,
372 RST_STREAM_NUM_STATUS_CODES = 12 376 RST_STREAM_FRAME_SIZE_ERROR = 11,
377 RST_STREAM_SETTINGS_TIMEOUT = 12,
378 RST_STREAM_CONNECT_ERROR = 13,
379 RST_STREAM_ENHANCE_YOUR_CALM = 14,
380 RST_STREAM_NUM_STATUS_CODES = 15
373 }; 381 };
374 382
375 // Status codes for GOAWAY frames. 383 // Status codes for GOAWAY frames.
376 enum SpdyGoAwayStatus { 384 enum SpdyGoAwayStatus {
377 GOAWAY_INVALID = -1, 385 GOAWAY_INVALID = -1,
378 GOAWAY_OK = 0, 386 GOAWAY_OK = 0,
379 GOAWAY_PROTOCOL_ERROR = 1, 387 GOAWAY_PROTOCOL_ERROR = 1,
380 GOAWAY_INTERNAL_ERROR = 2, 388 GOAWAY_INTERNAL_ERROR = 2,
381 GOAWAY_NUM_STATUS_CODES = 3 // Must be last. 389 GOAWAY_NUM_STATUS_CODES = 3 // Must be last.
382 }; 390 };
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 // version. 427 // version.
420 // Behavior is undefined for invalid setting id fields; consumers should first 428 // Behavior is undefined for invalid setting id fields; consumers should first
421 // use IsValidSettingId() to verify validity of setting id fields. 429 // use IsValidSettingId() to verify validity of setting id fields.
422 static SpdySettingsIds ParseSettingId(SpdyMajorVersion version, 430 static SpdySettingsIds ParseSettingId(SpdyMajorVersion version,
423 int setting_id_field); 431 int setting_id_field);
424 432
425 // Serializes a given setting id to the on-the-wire enumeration value for the 433 // Serializes a given setting id to the on-the-wire enumeration value for the
426 // given protocol version. 434 // given protocol version.
427 // Returns -1 on failure (I.E. Invalid setting id for the given version). 435 // Returns -1 on failure (I.E. Invalid setting id for the given version).
428 static int SerializeSettingId(SpdyMajorVersion version, SpdySettingsIds id); 436 static int SerializeSettingId(SpdyMajorVersion version, SpdySettingsIds id);
437
438 // Returns true if a given on-the-wire enumeration of a RST_STREAM status code
439 // is valid for a given protocol version, false otherwise.
440 static bool IsValidRstStreamStatus(SpdyMajorVersion version,
441 int rst_stream_status_field);
442
443 // Parses a RST_STREAM status code from an on-the-wire enumeration of a given
444 // protocol version.
445 // Behavior is undefined for invalid RST_STREAM status code fields; consumers
446 // should first use IsValidRstStreamStatus() to verify validity of RST_STREAM
447 // status code fields..
448 static SpdyRstStreamStatus ParseRstStreamStatus(SpdyMajorVersion version,
449 int rst_stream_status_field);
450
451 // Serializes a given RST_STREAM status code to the on-the-wire enumeration
452 // value for the given protocol version.
453 // Returns -1 on failure (I.E. Invalid RST_STREAM status code for the given
454 // version).
455 static int SerializeRstStreamStatus(SpdyMajorVersion version,
456 SpdyRstStreamStatus rst_stream_status);
429 }; 457 };
430 458
431 class SpdyFrame; 459 class SpdyFrame;
432 typedef SpdyFrame SpdySerializedFrame; 460 typedef SpdyFrame SpdySerializedFrame;
433 461
434 class SpdyFrameVisitor; 462 class SpdyFrameVisitor;
435 463
436 // Intermediate representation for SPDY frames. 464 // Intermediate representation for SPDY frames.
437 // TODO(hkhalil): Rename this class to SpdyFrame when the existing SpdyFrame is 465 // TODO(hkhalil): Rename this class to SpdyFrame when the existing SpdyFrame is
438 // gone. 466 // gone.
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 public: 657 public:
630 SpdyRstStreamIR(SpdyStreamId stream_id, SpdyRstStreamStatus status, 658 SpdyRstStreamIR(SpdyStreamId stream_id, SpdyRstStreamStatus status,
631 base::StringPiece description); 659 base::StringPiece description);
632 660
633 virtual ~SpdyRstStreamIR(); 661 virtual ~SpdyRstStreamIR();
634 662
635 SpdyRstStreamStatus status() const { 663 SpdyRstStreamStatus status() const {
636 return status_; 664 return status_;
637 } 665 }
638 void set_status(SpdyRstStreamStatus status) { 666 void set_status(SpdyRstStreamStatus status) {
639 DCHECK_NE(status, RST_STREAM_INVALID);
640 DCHECK_LT(status, RST_STREAM_NUM_STATUS_CODES);
641 status_ = status; 667 status_ = status;
642 } 668 }
643 669
644 base::StringPiece description() const { return description_; } 670 base::StringPiece description() const { return description_; }
645 671
646 void set_description(base::StringPiece description) { 672 void set_description(base::StringPiece description) {
647 description_ = description; 673 description_ = description;
648 } 674 }
649 675
650 virtual void Visit(SpdyFrameVisitor* visitor) const OVERRIDE; 676 virtual void Visit(SpdyFrameVisitor* visitor) const OVERRIDE;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 SpdyFrameVisitor() {} 941 SpdyFrameVisitor() {}
916 virtual ~SpdyFrameVisitor() {} 942 virtual ~SpdyFrameVisitor() {}
917 943
918 private: 944 private:
919 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); 945 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor);
920 }; 946 };
921 947
922 } // namespace net 948 } // namespace net
923 949
924 #endif // NET_SPDY_SPDY_PROTOCOL_H_ 950 #endif // NET_SPDY_SPDY_PROTOCOL_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer_test.cc ('k') | net/spdy/spdy_protocol.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698