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

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

Issue 12224137: Centralize logic for calculating (minimum) size of SPDY frames, by type, in SpdyFramer. (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 | « no previous file | net/spdy/spdy_framer.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 #ifndef NET_SPDY_SPDY_FRAMER_H_ 5 #ifndef NET_SPDY_SPDY_FRAMER_H_
6 #define NET_SPDY_SPDY_FRAMER_H_ 6 #define NET_SPDY_SPDY_FRAMER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // On failure, returns NULL. 468 // On failure, returns NULL.
469 SpdyFrame* CompressFrame(const SpdyFrame& frame); 469 SpdyFrame* CompressFrame(const SpdyFrame& frame);
470 470
471 // Create a copy of a frame. 471 // Create a copy of a frame.
472 // Returned frame must be freed with "delete". 472 // Returned frame must be freed with "delete".
473 SpdyFrame* DuplicateFrame(const SpdyFrame& frame); 473 SpdyFrame* DuplicateFrame(const SpdyFrame& frame);
474 474
475 // Returns true if a frame could be compressed. 475 // Returns true if a frame could be compressed.
476 bool IsCompressible(const SpdyFrame& frame) const; 476 bool IsCompressible(const SpdyFrame& frame) const;
477 477
478 // Get the minimum size of the control frame for the given control frame
479 // type. This is useful for validating frame blocks.
480 static size_t GetMinimumControlFrameSize(int version, SpdyControlType type);
481
482 // Get the stream ID for the given control frame (SYN_STREAM, SYN_REPLY, and 478 // Get the stream ID for the given control frame (SYN_STREAM, SYN_REPLY, and
483 // HEADERS). If the control frame is NULL or of another type, this 479 // HEADERS). If the control frame is NULL or of another type, this
484 // function returns kInvalidStream. 480 // function returns kInvalidStream.
485 static SpdyStreamId GetControlFrameStreamId( 481 static SpdyStreamId GetControlFrameStreamId(
486 const SpdyControlFrame* control_frame); 482 const SpdyControlFrame* control_frame);
487 483
488 // For ease of testing and experimentation we can tweak compression on/off. 484 // For ease of testing and experimentation we can tweak compression on/off.
489 void set_enable_compression(bool value) { 485 void set_enable_compression(bool value) {
490 enable_compression_ = value; 486 enable_compression_ = value;
491 } 487 }
492 488
493 // Used only in log messages. 489 // Used only in log messages.
494 void set_display_protocol(const std::string& protocol) { 490 void set_display_protocol(const std::string& protocol) {
495 display_protocol_ = protocol; 491 display_protocol_ = protocol;
496 } 492 }
497 493
494 // Returns the (minimum) size of control frames (sans variable-length
495 // portions).
496 size_t GetControlFrameMinimumSize() const;
497 size_t GetSynStreamMinimumSize() const;
498 size_t GetSynReplyMinimumSize() const;
499 size_t GetRstStreamSize() const;
500 size_t GetSettingsMinimumSize() const;
501 size_t GetPingSize() const;
502 size_t GetGoAwaySize() const;
503 size_t GetHeadersMinimumSize() const;
504 size_t GetWindowUpdateSize() const;
505 size_t GetCredentialMinimumSize() const;
506
498 // For debugging. 507 // For debugging.
499 static const char* StateToString(int state); 508 static const char* StateToString(int state);
500 static const char* ErrorCodeToString(int error_code); 509 static const char* ErrorCodeToString(int error_code);
501 static const char* StatusCodeToString(int status_code); 510 static const char* StatusCodeToString(int status_code);
502 static const char* ControlTypeToString(SpdyControlType type); 511 static const char* ControlTypeToString(SpdyControlType type);
503 512
504 int protocol_version() const { return spdy_version_; } 513 int protocol_version() const { return spdy_version_; }
505 514
506 bool probable_http_response() const { return probable_http_response_; } 515 bool probable_http_response() const { return probable_http_response_; }
507 516
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // starts with HTTP. If it does, we likely have an HTTP response. This 668 // starts with HTTP. If it does, we likely have an HTTP response. This
660 // isn't guaranteed though: we could have gotten a settings frame and then 669 // isn't guaranteed though: we could have gotten a settings frame and then
661 // corrupt data that just looks like HTTP, but deterministic checking requires 670 // corrupt data that just looks like HTTP, but deterministic checking requires
662 // a lot more state. 671 // a lot more state.
663 bool probable_http_response_; 672 bool probable_http_response_;
664 }; 673 };
665 674
666 } // namespace net 675 } // namespace net
667 676
668 #endif // NET_SPDY_SPDY_FRAMER_H_ 677 #endif // NET_SPDY_SPDY_FRAMER_H_
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698