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 #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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } // namespace test | 49 } // namespace test |
50 | 50 |
51 // A datastructure for holding a set of headers from a HEADERS, PUSH_PROMISE, | 51 // A datastructure for holding a set of headers from a HEADERS, PUSH_PROMISE, |
52 // SYN_STREAM, or SYN_REPLY frame. | 52 // SYN_STREAM, or SYN_REPLY frame. |
53 typedef std::map<std::string, std::string> SpdyHeaderBlock; | 53 typedef std::map<std::string, std::string> SpdyHeaderBlock; |
54 | 54 |
55 // A datastructure for holding the ID and flag fields for SETTINGS. | 55 // A datastructure for holding the ID and flag fields for SETTINGS. |
56 // Conveniently handles converstion to/from wire format. | 56 // Conveniently handles converstion to/from wire format. |
57 class NET_EXPORT_PRIVATE SettingsFlagsAndId { | 57 class NET_EXPORT_PRIVATE SettingsFlagsAndId { |
58 public: | 58 public: |
59 static SettingsFlagsAndId FromWireFormat(int version, uint32 wire); | 59 static SettingsFlagsAndId FromWireFormat(net::SpdyMajorVersion version, |
| 60 uint32 wire); |
60 | 61 |
61 SettingsFlagsAndId() : flags_(0), id_(0) {} | 62 SettingsFlagsAndId() : flags_(0), id_(0) {} |
62 | 63 |
63 // TODO(hkhalil): restrict to enums instead of free-form ints. | 64 // TODO(hkhalil): restrict to enums instead of free-form ints. |
64 SettingsFlagsAndId(uint8 flags, uint32 id); | 65 SettingsFlagsAndId(uint8 flags, uint32 id); |
65 | 66 |
66 uint32 GetWireFormat(int version) const; | 67 uint32 GetWireFormat(net::SpdyMajorVersion version) const; |
67 | 68 |
68 uint32 id() const { return id_; } | 69 uint32 id() const { return id_; } |
69 uint8 flags() const { return flags_; } | 70 uint8 flags() const { return flags_; } |
70 | 71 |
71 private: | 72 private: |
72 static void ConvertFlagsAndIdForSpdy2(uint32* val); | 73 static void ConvertFlagsAndIdForSpdy2(uint32* val); |
73 | 74 |
74 uint8 flags_; | 75 uint8 flags_; |
75 uint32 id_; | 76 uint32 id_; |
76 }; | 77 }; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // Constant for invalid (or unknown) stream IDs. | 314 // Constant for invalid (or unknown) stream IDs. |
314 static const SpdyStreamId kInvalidStream; | 315 static const SpdyStreamId kInvalidStream; |
315 | 316 |
316 // The maximum size of header data chunks delivered to the framer visitor | 317 // The maximum size of header data chunks delivered to the framer visitor |
317 // through OnControlFrameHeaderData. (It is exposed here for unit test | 318 // through OnControlFrameHeaderData. (It is exposed here for unit test |
318 // purposes.) | 319 // purposes.) |
319 static const size_t kHeaderDataChunkMaxSize; | 320 static const size_t kHeaderDataChunkMaxSize; |
320 | 321 |
321 // Serializes a SpdyHeaderBlock. | 322 // Serializes a SpdyHeaderBlock. |
322 static void WriteHeaderBlock(SpdyFrameBuilder* frame, | 323 static void WriteHeaderBlock(SpdyFrameBuilder* frame, |
323 const int spdy_version, | 324 const net::SpdyMajorVersion spdy_version, |
324 const SpdyHeaderBlock* headers); | 325 const SpdyHeaderBlock* headers); |
325 | 326 |
326 // Retrieve serialized length of SpdyHeaderBlock. | 327 // Retrieve serialized length of SpdyHeaderBlock. |
327 // TODO(hkhalil): Remove, or move to quic code. | 328 // TODO(hkhalil): Remove, or move to quic code. |
328 static size_t GetSerializedLength(const int spdy_version, | 329 static size_t GetSerializedLength( |
329 const SpdyHeaderBlock* headers); | 330 const net::SpdyMajorVersion spdy_version, |
| 331 const SpdyHeaderBlock* headers); |
330 | 332 |
331 // Create a new Framer, provided a SPDY version. | 333 // Create a new Framer, provided a SPDY version. |
332 explicit SpdyFramer(SpdyMajorVersion version); | 334 explicit SpdyFramer(SpdyMajorVersion version); |
333 virtual ~SpdyFramer(); | 335 virtual ~SpdyFramer(); |
334 | 336 |
335 // Set callbacks to be called from the framer. A visitor must be set, or | 337 // Set callbacks to be called from the framer. A visitor must be set, or |
336 // else the framer will likely crash. It is acceptable for the visitor | 338 // else the framer will likely crash. It is acceptable for the visitor |
337 // to do nothing. If this is called multiple times, only the last visitor | 339 // to do nothing. If this is called multiple times, only the last visitor |
338 // will be used. | 340 // will be used. |
339 void set_visitor(SpdyFramerVisitorInterface* visitor) { | 341 void set_visitor(SpdyFramerVisitorInterface* visitor) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 static const char* ErrorCodeToString(int error_code); | 497 static const char* ErrorCodeToString(int error_code); |
496 static const char* StatusCodeToString(int status_code); | 498 static const char* StatusCodeToString(int status_code); |
497 static const char* FrameTypeToString(SpdyFrameType type); | 499 static const char* FrameTypeToString(SpdyFrameType type); |
498 | 500 |
499 SpdyMajorVersion protocol_version() const { return spdy_version_; } | 501 SpdyMajorVersion protocol_version() const { return spdy_version_; } |
500 | 502 |
501 bool probable_http_response() const { return probable_http_response_; } | 503 bool probable_http_response() const { return probable_http_response_; } |
502 | 504 |
503 SpdyStreamId expect_continuation() const { return expect_continuation_; } | 505 SpdyStreamId expect_continuation() const { return expect_continuation_; } |
504 | 506 |
505 SpdyPriority GetLowestPriority() const { return spdy_version_ < 3 ? 3 : 7; } | 507 SpdyPriority GetLowestPriority() const { |
| 508 return spdy_version_ < SPDY3 ? 3 : 7; |
| 509 } |
| 510 |
506 SpdyPriority GetHighestPriority() const { return 0; } | 511 SpdyPriority GetHighestPriority() const { return 0; } |
507 | 512 |
508 // Deliver the given control frame's compressed headers block to the visitor | 513 // Deliver the given control frame's compressed headers block to the visitor |
509 // in decompressed form, in chunks. Returns true if the visitor has | 514 // in decompressed form, in chunks. Returns true if the visitor has |
510 // accepted all of the chunks. | 515 // accepted all of the chunks. |
511 bool IncrementallyDecompressControlFrameHeaderData( | 516 bool IncrementallyDecompressControlFrameHeaderData( |
512 SpdyStreamId stream_id, | 517 SpdyStreamId stream_id, |
513 const char* data, | 518 const char* data, |
514 size_t len); | 519 size_t len); |
515 | 520 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 | 741 |
737 // Returns true if the given StringPiece contains any upper case | 742 // Returns true if the given StringPiece contains any upper case |
738 // characters. Assumes ASCII input. | 743 // characters. Assumes ASCII input. |
739 // Implemented here for cross-compatibility with Chromium. | 744 // Implemented here for cross-compatibility with Chromium. |
740 bool ContainsUpperASCII(base::StringPiece s) const; | 745 bool ContainsUpperASCII(base::StringPiece s) const; |
741 }; | 746 }; |
742 | 747 |
743 } // namespace net | 748 } // namespace net |
744 | 749 |
745 #endif // NET_SPDY_SPDY_FRAMER_H_ | 750 #endif // NET_SPDY_SPDY_FRAMER_H_ |
OLD | NEW |