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 3 and HTTP 2 | 5 // This file contains some protocol structures for use with SPDY 3 and HTTP 2 |
6 // The SPDY 3 spec can be found at: | 6 // The SPDY 3 spec can be found at: |
7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 | 7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 |
8 | 8 |
9 #ifndef NET_SPDY_CORE_SPDY_PROTOCOL_H_ | 9 #ifndef NET_SPDY_CORE_SPDY_PROTOCOL_H_ |
10 #define NET_SPDY_CORE_SPDY_PROTOCOL_H_ | 10 #define NET_SPDY_CORE_SPDY_PROTOCOL_H_ |
11 | 11 |
12 #include <stddef.h> | 12 #include <stddef.h> |
13 #include <stdint.h> | 13 #include <stdint.h> |
14 | 14 |
15 #include <iosfwd> | 15 #include <iosfwd> |
16 #include <limits> | 16 #include <limits> |
17 #include <map> | 17 #include <map> |
18 #include <memory> | 18 #include <memory> |
19 #include <new> | 19 #include <new> |
20 #include <utility> | 20 #include <utility> |
21 | 21 |
22 #include "base/compiler_specific.h" | 22 #include "base/compiler_specific.h" |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "base/macros.h" | 24 #include "base/macros.h" |
25 #include "base/sys_byteorder.h" | 25 #include "base/sys_byteorder.h" |
26 #include "net/base/net_export.h" | |
27 #include "net/spdy/core/spdy_alt_svc_wire_format.h" | 26 #include "net/spdy/core/spdy_alt_svc_wire_format.h" |
28 #include "net/spdy/core/spdy_bitmasks.h" | 27 #include "net/spdy/core/spdy_bitmasks.h" |
29 #include "net/spdy/core/spdy_bug_tracker.h" | 28 #include "net/spdy/core/spdy_bug_tracker.h" |
30 #include "net/spdy/core/spdy_header_block.h" | 29 #include "net/spdy/core/spdy_header_block.h" |
| 30 #include "net/spdy/platform/api/spdy_export.h" |
31 #include "net/spdy/platform/api/spdy_ptr_util.h" | 31 #include "net/spdy/platform/api/spdy_ptr_util.h" |
32 #include "net/spdy/platform/api/spdy_string.h" | 32 #include "net/spdy/platform/api/spdy_string.h" |
33 #include "net/spdy/platform/api/spdy_string_piece.h" | 33 #include "net/spdy/platform/api/spdy_string_piece.h" |
34 | 34 |
35 namespace net { | 35 namespace net { |
36 | 36 |
37 // A stream id is a 31 bit entity. | 37 // A stream id is a 31 bit entity. |
38 typedef uint32_t SpdyStreamId; | 38 typedef uint32_t SpdyStreamId; |
39 | 39 |
40 // Specifies the stream ID used to denote the current session (for | 40 // Specifies the stream ID used to denote the current session (for |
(...skipping 19 matching lines...) Expand all Loading... |
60 | 60 |
61 // Maximum padding size in octets for one DATA or HEADERS or PUSH_PROMISE frame. | 61 // Maximum padding size in octets for one DATA or HEADERS or PUSH_PROMISE frame. |
62 const int32_t kPaddingSizePerFrame = 256; | 62 const int32_t kPaddingSizePerFrame = 256; |
63 | 63 |
64 // The HTTP/2 connection preface, which must be the first bytes sent by the | 64 // The HTTP/2 connection preface, which must be the first bytes sent by the |
65 // client upon starting an HTTP/2 connection, and which must be followed by a | 65 // client upon starting an HTTP/2 connection, and which must be followed by a |
66 // SETTINGS frame. Note that even though |kHttp2ConnectionHeaderPrefix| is | 66 // SETTINGS frame. Note that even though |kHttp2ConnectionHeaderPrefix| is |
67 // defined as a string literal with a null terminator, the actual connection | 67 // defined as a string literal with a null terminator, the actual connection |
68 // preface is only the first |kHttp2ConnectionHeaderPrefixSize| bytes, which | 68 // preface is only the first |kHttp2ConnectionHeaderPrefixSize| bytes, which |
69 // excludes the null terminator. | 69 // excludes the null terminator. |
70 NET_EXPORT_PRIVATE extern const char* const kHttp2ConnectionHeaderPrefix; | 70 SPDY_EXPORT_PRIVATE extern const char* const kHttp2ConnectionHeaderPrefix; |
71 const int kHttp2ConnectionHeaderPrefixSize = 24; | 71 const int kHttp2ConnectionHeaderPrefixSize = 24; |
72 | 72 |
73 // Wire values for HTTP2 frame types. | 73 // Wire values for HTTP2 frame types. |
74 enum class SpdyFrameType : uint8_t { | 74 enum class SpdyFrameType : uint8_t { |
75 DATA = 0x00, | 75 DATA = 0x00, |
76 HEADERS = 0x01, | 76 HEADERS = 0x01, |
77 PRIORITY = 0x02, | 77 PRIORITY = 0x02, |
78 RST_STREAM = 0x03, | 78 RST_STREAM = 0x03, |
79 SETTINGS = 0x04, | 79 SETTINGS = 0x04, |
80 PUSH_PROMISE = 0x05, | 80 PUSH_PROMISE = 0x05, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 SETTINGS_INITIAL_WINDOW_SIZE = 0x4, | 143 SETTINGS_INITIAL_WINDOW_SIZE = 0x4, |
144 // The size of the largest frame payload that a receiver is willing to accept. | 144 // The size of the largest frame payload that a receiver is willing to accept. |
145 SETTINGS_MAX_FRAME_SIZE = 0x5, | 145 SETTINGS_MAX_FRAME_SIZE = 0x5, |
146 // The maximum size of header list that the sender is prepared to accept. | 146 // The maximum size of header list that the sender is prepared to accept. |
147 SETTINGS_MAX_HEADER_LIST_SIZE = 0x6, | 147 SETTINGS_MAX_HEADER_LIST_SIZE = 0x6, |
148 SETTINGS_MAX = SETTINGS_MAX_HEADER_LIST_SIZE | 148 SETTINGS_MAX = SETTINGS_MAX_HEADER_LIST_SIZE |
149 }; | 149 }; |
150 | 150 |
151 // This explicit operator is needed, otherwise compiler finds | 151 // This explicit operator is needed, otherwise compiler finds |
152 // overloaded operator to be ambiguous. | 152 // overloaded operator to be ambiguous. |
153 NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, | 153 SPDY_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, |
154 SpdySettingsIds id); | 154 SpdySettingsIds id); |
155 | 155 |
156 // This operator is needed, because SpdyFrameType is an enum class, | 156 // This operator is needed, because SpdyFrameType is an enum class, |
157 // therefore implicit conversion to underlying integer type is not allowed. | 157 // therefore implicit conversion to underlying integer type is not allowed. |
158 NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, | 158 SPDY_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, |
159 SpdyFrameType frame_type); | 159 SpdyFrameType frame_type); |
160 | 160 |
161 using SettingsMap = std::map<SpdySettingsIds, uint32_t>; | 161 using SettingsMap = std::map<SpdySettingsIds, uint32_t>; |
162 | 162 |
163 // HTTP/2 error codes, RFC 7540 Section 7. | 163 // HTTP/2 error codes, RFC 7540 Section 7. |
164 enum SpdyErrorCode : uint32_t { | 164 enum SpdyErrorCode : uint32_t { |
165 ERROR_CODE_NO_ERROR = 0x0, | 165 ERROR_CODE_NO_ERROR = 0x0, |
166 ERROR_CODE_PROTOCOL_ERROR = 0x1, | 166 ERROR_CODE_PROTOCOL_ERROR = 0x1, |
167 ERROR_CODE_INTERNAL_ERROR = 0x2, | 167 ERROR_CODE_INTERNAL_ERROR = 0x2, |
168 ERROR_CODE_FLOW_CONTROL_ERROR = 0x3, | 168 ERROR_CODE_FLOW_CONTROL_ERROR = 0x3, |
169 ERROR_CODE_SETTINGS_TIMEOUT = 0x4, | 169 ERROR_CODE_SETTINGS_TIMEOUT = 0x4, |
(...skipping 12 matching lines...) Expand all Loading... |
182 // A SPDY priority is a number between 0 and 7 (inclusive). | 182 // A SPDY priority is a number between 0 and 7 (inclusive). |
183 typedef uint8_t SpdyPriority; | 183 typedef uint8_t SpdyPriority; |
184 | 184 |
185 // Lowest and Highest here refer to SPDY priorities as described in | 185 // Lowest and Highest here refer to SPDY priorities as described in |
186 | 186 |
187 // https://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3-1#TOC-2.3.3-
Stream-priority | 187 // https://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3-1#TOC-2.3.3-
Stream-priority |
188 const SpdyPriority kV3HighestPriority = 0; | 188 const SpdyPriority kV3HighestPriority = 0; |
189 const SpdyPriority kV3LowestPriority = 7; | 189 const SpdyPriority kV3LowestPriority = 7; |
190 | 190 |
191 // Returns SPDY 3.x priority value clamped to the valid range of [0, 7]. | 191 // Returns SPDY 3.x priority value clamped to the valid range of [0, 7]. |
192 NET_EXPORT_PRIVATE SpdyPriority ClampSpdy3Priority(SpdyPriority priority); | 192 SPDY_EXPORT_PRIVATE SpdyPriority ClampSpdy3Priority(SpdyPriority priority); |
193 | 193 |
194 // HTTP/2 stream weights are integers in range [1, 256], as specified in RFC | 194 // HTTP/2 stream weights are integers in range [1, 256], as specified in RFC |
195 // 7540 section 5.3.2. Default stream weight is defined in section 5.3.5. | 195 // 7540 section 5.3.2. Default stream weight is defined in section 5.3.5. |
196 const int kHttp2MinStreamWeight = 1; | 196 const int kHttp2MinStreamWeight = 1; |
197 const int kHttp2MaxStreamWeight = 256; | 197 const int kHttp2MaxStreamWeight = 256; |
198 const int kHttp2DefaultStreamWeight = 16; | 198 const int kHttp2DefaultStreamWeight = 16; |
199 | 199 |
200 // Returns HTTP/2 weight clamped to the valid range of [1, 256]. | 200 // Returns HTTP/2 weight clamped to the valid range of [1, 256]. |
201 NET_EXPORT_PRIVATE int ClampHttp2Weight(int weight); | 201 SPDY_EXPORT_PRIVATE int ClampHttp2Weight(int weight); |
202 | 202 |
203 // Maps SPDY 3.x priority value in range [0, 7] to HTTP/2 weight value in range | 203 // Maps SPDY 3.x priority value in range [0, 7] to HTTP/2 weight value in range |
204 // [1, 256], where priority 0 (i.e. highest precedence) corresponds to maximum | 204 // [1, 256], where priority 0 (i.e. highest precedence) corresponds to maximum |
205 // weight 256 and priority 7 (lowest precedence) corresponds to minimum weight | 205 // weight 256 and priority 7 (lowest precedence) corresponds to minimum weight |
206 // 1. | 206 // 1. |
207 NET_EXPORT_PRIVATE int Spdy3PriorityToHttp2Weight(SpdyPriority priority); | 207 SPDY_EXPORT_PRIVATE int Spdy3PriorityToHttp2Weight(SpdyPriority priority); |
208 | 208 |
209 // Maps HTTP/2 weight value in range [1, 256] to SPDY 3.x priority value in | 209 // Maps HTTP/2 weight value in range [1, 256] to SPDY 3.x priority value in |
210 // range [0, 7], where minimum weight 1 corresponds to priority 7 (lowest | 210 // range [0, 7], where minimum weight 1 corresponds to priority 7 (lowest |
211 // precedence) and maximum weight 256 corresponds to priority 0 (highest | 211 // precedence) and maximum weight 256 corresponds to priority 0 (highest |
212 // precedence). | 212 // precedence). |
213 NET_EXPORT_PRIVATE SpdyPriority Http2WeightToSpdy3Priority(int weight); | 213 SPDY_EXPORT_PRIVATE SpdyPriority Http2WeightToSpdy3Priority(int weight); |
214 | 214 |
215 // Reserved ID for root stream of HTTP/2 stream dependency tree, as specified | 215 // Reserved ID for root stream of HTTP/2 stream dependency tree, as specified |
216 // in RFC 7540 section 5.3.1. | 216 // in RFC 7540 section 5.3.1. |
217 const unsigned int kHttp2RootStreamId = 0; | 217 const unsigned int kHttp2RootStreamId = 0; |
218 | 218 |
219 typedef uint64_t SpdyPingId; | 219 typedef uint64_t SpdyPingId; |
220 | 220 |
221 // Returns true if a given on-the-wire enumeration of a frame type is defined | 221 // Returns true if a given on-the-wire enumeration of a frame type is defined |
222 // in a standardized HTTP/2 specification, false otherwise. | 222 // in a standardized HTTP/2 specification, false otherwise. |
223 NET_EXPORT_PRIVATE bool IsDefinedFrameType(uint8_t frame_type_field); | 223 SPDY_EXPORT_PRIVATE bool IsDefinedFrameType(uint8_t frame_type_field); |
224 | 224 |
225 // Parses a frame type from an on-the-wire enumeration. | 225 // Parses a frame type from an on-the-wire enumeration. |
226 // Behavior is undefined for invalid frame type fields; consumers should first | 226 // Behavior is undefined for invalid frame type fields; consumers should first |
227 // use IsValidFrameType() to verify validity of frame type fields. | 227 // use IsValidFrameType() to verify validity of frame type fields. |
228 NET_EXPORT_PRIVATE SpdyFrameType ParseFrameType(uint8_t frame_type_field); | 228 SPDY_EXPORT_PRIVATE SpdyFrameType ParseFrameType(uint8_t frame_type_field); |
229 | 229 |
230 // Serializes a frame type to the on-the-wire value. | 230 // Serializes a frame type to the on-the-wire value. |
231 NET_EXPORT_PRIVATE uint8_t SerializeFrameType(SpdyFrameType frame_type); | 231 SPDY_EXPORT_PRIVATE uint8_t SerializeFrameType(SpdyFrameType frame_type); |
232 | 232 |
233 // (HTTP/2) All standard frame types except WINDOW_UPDATE are | 233 // (HTTP/2) All standard frame types except WINDOW_UPDATE are |
234 // (stream-specific xor connection-level). Returns false iff we know | 234 // (stream-specific xor connection-level). Returns false iff we know |
235 // the given frame type does not align with the given streamID. | 235 // the given frame type does not align with the given streamID. |
236 NET_EXPORT_PRIVATE bool IsValidHTTP2FrameStreamId( | 236 SPDY_EXPORT_PRIVATE bool IsValidHTTP2FrameStreamId( |
237 SpdyStreamId current_frame_stream_id, | 237 SpdyStreamId current_frame_stream_id, |
238 SpdyFrameType frame_type_field); | 238 SpdyFrameType frame_type_field); |
239 | 239 |
240 // Serialize |frame_type| to string for logging/debugging. | 240 // Serialize |frame_type| to string for logging/debugging. |
241 const char* FrameTypeToString(SpdyFrameType frame_type); | 241 const char* FrameTypeToString(SpdyFrameType frame_type); |
242 | 242 |
243 // If |wire_setting_id| is the on-the-wire representation of a defined SETTINGS | 243 // If |wire_setting_id| is the on-the-wire representation of a defined SETTINGS |
244 // parameter, parse it to |*setting_id| and return true. | 244 // parameter, parse it to |*setting_id| and return true. |
245 NET_EXPORT_PRIVATE bool ParseSettingsId(uint16_t wire_setting_id, | 245 SPDY_EXPORT_PRIVATE bool ParseSettingsId(uint16_t wire_setting_id, |
246 SpdySettingsIds* setting_id); | 246 SpdySettingsIds* setting_id); |
247 | 247 |
248 // Return if |id| corresponds to a defined setting; | 248 // Return if |id| corresponds to a defined setting; |
249 // stringify |id| to |*settings_id_string| regardless. | 249 // stringify |id| to |*settings_id_string| regardless. |
250 NET_EXPORT_PRIVATE bool SettingsIdToString(SpdySettingsIds id, | 250 SPDY_EXPORT_PRIVATE bool SettingsIdToString(SpdySettingsIds id, |
251 const char** settings_id_string); | 251 const char** settings_id_string); |
252 | 252 |
253 // Parse |wire_error_code| to a SpdyErrorCode. | 253 // Parse |wire_error_code| to a SpdyErrorCode. |
254 // Treat unrecognized error codes as INTERNAL_ERROR | 254 // Treat unrecognized error codes as INTERNAL_ERROR |
255 // as recommended by the HTTP/2 specification. | 255 // as recommended by the HTTP/2 specification. |
256 NET_EXPORT_PRIVATE SpdyErrorCode ParseErrorCode(uint32_t wire_error_code); | 256 SPDY_EXPORT_PRIVATE SpdyErrorCode ParseErrorCode(uint32_t wire_error_code); |
257 | 257 |
258 // Serialize RST_STREAM or GOAWAY frame error code to string | 258 // Serialize RST_STREAM or GOAWAY frame error code to string |
259 // for logging/debugging. | 259 // for logging/debugging. |
260 const char* ErrorCodeToString(SpdyErrorCode error_code); | 260 const char* ErrorCodeToString(SpdyErrorCode error_code); |
261 | 261 |
262 // Number of octets in the frame header. | 262 // Number of octets in the frame header. |
263 const size_t kFrameHeaderSize = 9; | 263 const size_t kFrameHeaderSize = 9; |
264 // Size, in bytes, of the data frame header. | 264 // Size, in bytes, of the data frame header. |
265 const size_t kDataFrameMinimumSize = kFrameHeaderSize; | 265 const size_t kDataFrameMinimumSize = kFrameHeaderSize; |
266 // Maximum possible configurable size of a frame in octets. | 266 // Maximum possible configurable size of a frame in octets. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 SpdyPriority spdy3_priority_; | 368 SpdyPriority spdy3_priority_; |
369 Http2StreamDependency http2_stream_dependency_; | 369 Http2StreamDependency http2_stream_dependency_; |
370 }; | 370 }; |
371 }; | 371 }; |
372 | 372 |
373 typedef StreamPrecedence<SpdyStreamId> SpdyStreamPrecedence; | 373 typedef StreamPrecedence<SpdyStreamId> SpdyStreamPrecedence; |
374 | 374 |
375 class SpdyFrameVisitor; | 375 class SpdyFrameVisitor; |
376 | 376 |
377 // Intermediate representation for HTTP2 frames. | 377 // Intermediate representation for HTTP2 frames. |
378 class NET_EXPORT_PRIVATE SpdyFrameIR { | 378 class SPDY_EXPORT_PRIVATE SpdyFrameIR { |
379 public: | 379 public: |
380 virtual ~SpdyFrameIR() {} | 380 virtual ~SpdyFrameIR() {} |
381 | 381 |
382 virtual void Visit(SpdyFrameVisitor* visitor) const = 0; | 382 virtual void Visit(SpdyFrameVisitor* visitor) const = 0; |
383 virtual SpdyFrameType frame_type() const = 0; | 383 virtual SpdyFrameType frame_type() const = 0; |
384 | 384 |
385 protected: | 385 protected: |
386 SpdyFrameIR() {} | 386 SpdyFrameIR() {} |
387 | 387 |
388 private: | 388 private: |
389 DISALLOW_COPY_AND_ASSIGN(SpdyFrameIR); | 389 DISALLOW_COPY_AND_ASSIGN(SpdyFrameIR); |
390 }; | 390 }; |
391 | 391 |
392 // Abstract class intended to be inherited by IRs that have a stream associated | 392 // Abstract class intended to be inherited by IRs that have a stream associated |
393 // to them. | 393 // to them. |
394 class NET_EXPORT_PRIVATE SpdyFrameWithStreamIdIR : public SpdyFrameIR { | 394 class SPDY_EXPORT_PRIVATE SpdyFrameWithStreamIdIR : public SpdyFrameIR { |
395 public: | 395 public: |
396 ~SpdyFrameWithStreamIdIR() override {} | 396 ~SpdyFrameWithStreamIdIR() override {} |
397 SpdyStreamId stream_id() const { return stream_id_; } | 397 SpdyStreamId stream_id() const { return stream_id_; } |
398 void set_stream_id(SpdyStreamId stream_id) { | 398 void set_stream_id(SpdyStreamId stream_id) { |
399 DCHECK_EQ(0u, stream_id & ~kStreamIdMask); | 399 DCHECK_EQ(0u, stream_id & ~kStreamIdMask); |
400 stream_id_ = stream_id; | 400 stream_id_ = stream_id; |
401 } | 401 } |
402 | 402 |
403 protected: | 403 protected: |
404 explicit SpdyFrameWithStreamIdIR(SpdyStreamId stream_id) { | 404 explicit SpdyFrameWithStreamIdIR(SpdyStreamId stream_id) { |
405 set_stream_id(stream_id); | 405 set_stream_id(stream_id); |
406 } | 406 } |
407 | 407 |
408 private: | 408 private: |
409 SpdyStreamId stream_id_; | 409 SpdyStreamId stream_id_; |
410 | 410 |
411 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithStreamIdIR); | 411 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithStreamIdIR); |
412 }; | 412 }; |
413 | 413 |
414 // Abstract class intended to be inherited by IRs that have the option of a FIN | 414 // Abstract class intended to be inherited by IRs that have the option of a FIN |
415 // flag. Implies SpdyFrameWithStreamIdIR. | 415 // flag. Implies SpdyFrameWithStreamIdIR. |
416 class NET_EXPORT_PRIVATE SpdyFrameWithFinIR : public SpdyFrameWithStreamIdIR { | 416 class SPDY_EXPORT_PRIVATE SpdyFrameWithFinIR : public SpdyFrameWithStreamIdIR { |
417 public: | 417 public: |
418 ~SpdyFrameWithFinIR() override {} | 418 ~SpdyFrameWithFinIR() override {} |
419 bool fin() const { return fin_; } | 419 bool fin() const { return fin_; } |
420 void set_fin(bool fin) { fin_ = fin; } | 420 void set_fin(bool fin) { fin_ = fin; } |
421 | 421 |
422 protected: | 422 protected: |
423 explicit SpdyFrameWithFinIR(SpdyStreamId stream_id) | 423 explicit SpdyFrameWithFinIR(SpdyStreamId stream_id) |
424 : SpdyFrameWithStreamIdIR(stream_id), | 424 : SpdyFrameWithStreamIdIR(stream_id), |
425 fin_(false) {} | 425 fin_(false) {} |
426 | 426 |
427 private: | 427 private: |
428 bool fin_; | 428 bool fin_; |
429 | 429 |
430 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithFinIR); | 430 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithFinIR); |
431 }; | 431 }; |
432 | 432 |
433 // Abstract class intended to be inherited by IRs that contain a header | 433 // Abstract class intended to be inherited by IRs that contain a header |
434 // block. Implies SpdyFrameWithFinIR. | 434 // block. Implies SpdyFrameWithFinIR. |
435 class NET_EXPORT_PRIVATE SpdyFrameWithHeaderBlockIR | 435 class SPDY_EXPORT_PRIVATE SpdyFrameWithHeaderBlockIR |
436 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { | 436 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { |
437 public: | 437 public: |
438 ~SpdyFrameWithHeaderBlockIR() override; | 438 ~SpdyFrameWithHeaderBlockIR() override; |
439 | 439 |
440 const SpdyHeaderBlock& header_block() const { return header_block_; } | 440 const SpdyHeaderBlock& header_block() const { return header_block_; } |
441 void set_header_block(SpdyHeaderBlock header_block) { | 441 void set_header_block(SpdyHeaderBlock header_block) { |
442 // Deep copy. | 442 // Deep copy. |
443 header_block_ = std::move(header_block); | 443 header_block_ = std::move(header_block); |
444 } | 444 } |
445 void SetHeader(SpdyStringPiece name, SpdyStringPiece value) { | 445 void SetHeader(SpdyStringPiece name, SpdyStringPiece value) { |
446 header_block_[name] = value; | 446 header_block_[name] = value; |
447 } | 447 } |
448 bool end_headers() const { return end_headers_; } | 448 bool end_headers() const { return end_headers_; } |
449 void set_end_headers(bool end_headers) { end_headers_ = end_headers; } | 449 void set_end_headers(bool end_headers) { end_headers_ = end_headers; } |
450 | 450 |
451 protected: | 451 protected: |
452 SpdyFrameWithHeaderBlockIR(SpdyStreamId stream_id, | 452 SpdyFrameWithHeaderBlockIR(SpdyStreamId stream_id, |
453 SpdyHeaderBlock header_block); | 453 SpdyHeaderBlock header_block); |
454 | 454 |
455 private: | 455 private: |
456 SpdyHeaderBlock header_block_; | 456 SpdyHeaderBlock header_block_; |
457 bool end_headers_ = false; | 457 bool end_headers_ = false; |
458 | 458 |
459 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithHeaderBlockIR); | 459 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithHeaderBlockIR); |
460 }; | 460 }; |
461 | 461 |
462 class NET_EXPORT_PRIVATE SpdyDataIR | 462 class SPDY_EXPORT_PRIVATE SpdyDataIR |
463 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { | 463 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { |
464 public: | 464 public: |
465 // Performs a deep copy on data. | 465 // Performs a deep copy on data. |
466 SpdyDataIR(SpdyStreamId stream_id, SpdyStringPiece data); | 466 SpdyDataIR(SpdyStreamId stream_id, SpdyStringPiece data); |
467 | 467 |
468 // Performs a deep copy on data. | 468 // Performs a deep copy on data. |
469 SpdyDataIR(SpdyStreamId stream_id, const char* data); | 469 SpdyDataIR(SpdyStreamId stream_id, const char* data); |
470 | 470 |
471 // Moves data into data_store_. Makes a copy if passed a non-movable string. | 471 // Moves data into data_store_. Makes a copy if passed a non-movable string. |
472 SpdyDataIR(SpdyStreamId stream_id, SpdyString data); | 472 SpdyDataIR(SpdyStreamId stream_id, SpdyString data); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 const char* data_; | 523 const char* data_; |
524 size_t data_len_; | 524 size_t data_len_; |
525 | 525 |
526 bool padded_; | 526 bool padded_; |
527 // padding_payload_len_ = desired padding length - len(padding length field). | 527 // padding_payload_len_ = desired padding length - len(padding length field). |
528 int padding_payload_len_; | 528 int padding_payload_len_; |
529 | 529 |
530 DISALLOW_COPY_AND_ASSIGN(SpdyDataIR); | 530 DISALLOW_COPY_AND_ASSIGN(SpdyDataIR); |
531 }; | 531 }; |
532 | 532 |
533 class NET_EXPORT_PRIVATE SpdyRstStreamIR : public SpdyFrameWithStreamIdIR { | 533 class SPDY_EXPORT_PRIVATE SpdyRstStreamIR : public SpdyFrameWithStreamIdIR { |
534 public: | 534 public: |
535 SpdyRstStreamIR(SpdyStreamId stream_id, SpdyErrorCode error_code); | 535 SpdyRstStreamIR(SpdyStreamId stream_id, SpdyErrorCode error_code); |
536 | 536 |
537 ~SpdyRstStreamIR() override; | 537 ~SpdyRstStreamIR() override; |
538 | 538 |
539 SpdyErrorCode error_code() const { return error_code_; } | 539 SpdyErrorCode error_code() const { return error_code_; } |
540 void set_error_code(SpdyErrorCode error_code) { error_code_ = error_code; } | 540 void set_error_code(SpdyErrorCode error_code) { error_code_ = error_code; } |
541 | 541 |
542 void Visit(SpdyFrameVisitor* visitor) const override; | 542 void Visit(SpdyFrameVisitor* visitor) const override; |
543 | 543 |
544 SpdyFrameType frame_type() const override; | 544 SpdyFrameType frame_type() const override; |
545 | 545 |
546 private: | 546 private: |
547 SpdyErrorCode error_code_; | 547 SpdyErrorCode error_code_; |
548 | 548 |
549 DISALLOW_COPY_AND_ASSIGN(SpdyRstStreamIR); | 549 DISALLOW_COPY_AND_ASSIGN(SpdyRstStreamIR); |
550 }; | 550 }; |
551 | 551 |
552 class NET_EXPORT_PRIVATE SpdySettingsIR : public SpdyFrameIR { | 552 class SPDY_EXPORT_PRIVATE SpdySettingsIR : public SpdyFrameIR { |
553 public: | 553 public: |
554 SpdySettingsIR(); | 554 SpdySettingsIR(); |
555 ~SpdySettingsIR() override; | 555 ~SpdySettingsIR() override; |
556 | 556 |
557 // Overwrites as appropriate. | 557 // Overwrites as appropriate. |
558 const SettingsMap& values() const { return values_; } | 558 const SettingsMap& values() const { return values_; } |
559 void AddSetting(SpdySettingsIds id, int32_t value) { values_[id] = value; } | 559 void AddSetting(SpdySettingsIds id, int32_t value) { values_[id] = value; } |
560 | 560 |
561 bool is_ack() const { return is_ack_; } | 561 bool is_ack() const { return is_ack_; } |
562 void set_is_ack(bool is_ack) { | 562 void set_is_ack(bool is_ack) { |
563 is_ack_ = is_ack; | 563 is_ack_ = is_ack; |
564 } | 564 } |
565 | 565 |
566 void Visit(SpdyFrameVisitor* visitor) const override; | 566 void Visit(SpdyFrameVisitor* visitor) const override; |
567 | 567 |
568 SpdyFrameType frame_type() const override; | 568 SpdyFrameType frame_type() const override; |
569 | 569 |
570 private: | 570 private: |
571 SettingsMap values_; | 571 SettingsMap values_; |
572 bool is_ack_; | 572 bool is_ack_; |
573 | 573 |
574 DISALLOW_COPY_AND_ASSIGN(SpdySettingsIR); | 574 DISALLOW_COPY_AND_ASSIGN(SpdySettingsIR); |
575 }; | 575 }; |
576 | 576 |
577 class NET_EXPORT_PRIVATE SpdyPingIR : public SpdyFrameIR { | 577 class SPDY_EXPORT_PRIVATE SpdyPingIR : public SpdyFrameIR { |
578 public: | 578 public: |
579 explicit SpdyPingIR(SpdyPingId id) : id_(id), is_ack_(false) {} | 579 explicit SpdyPingIR(SpdyPingId id) : id_(id), is_ack_(false) {} |
580 SpdyPingId id() const { return id_; } | 580 SpdyPingId id() const { return id_; } |
581 | 581 |
582 bool is_ack() const { return is_ack_; } | 582 bool is_ack() const { return is_ack_; } |
583 void set_is_ack(bool is_ack) { is_ack_ = is_ack; } | 583 void set_is_ack(bool is_ack) { is_ack_ = is_ack; } |
584 | 584 |
585 void Visit(SpdyFrameVisitor* visitor) const override; | 585 void Visit(SpdyFrameVisitor* visitor) const override; |
586 | 586 |
587 SpdyFrameType frame_type() const override; | 587 SpdyFrameType frame_type() const override; |
588 | 588 |
589 private: | 589 private: |
590 SpdyPingId id_; | 590 SpdyPingId id_; |
591 bool is_ack_; | 591 bool is_ack_; |
592 | 592 |
593 DISALLOW_COPY_AND_ASSIGN(SpdyPingIR); | 593 DISALLOW_COPY_AND_ASSIGN(SpdyPingIR); |
594 }; | 594 }; |
595 | 595 |
596 class NET_EXPORT_PRIVATE SpdyGoAwayIR : public SpdyFrameIR { | 596 class SPDY_EXPORT_PRIVATE SpdyGoAwayIR : public SpdyFrameIR { |
597 public: | 597 public: |
598 // References description, doesn't copy it, so description must outlast | 598 // References description, doesn't copy it, so description must outlast |
599 // this SpdyGoAwayIR. | 599 // this SpdyGoAwayIR. |
600 SpdyGoAwayIR(SpdyStreamId last_good_stream_id, | 600 SpdyGoAwayIR(SpdyStreamId last_good_stream_id, |
601 SpdyErrorCode error_code, | 601 SpdyErrorCode error_code, |
602 SpdyStringPiece description); | 602 SpdyStringPiece description); |
603 | 603 |
604 // References description, doesn't copy it, so description must outlast | 604 // References description, doesn't copy it, so description must outlast |
605 // this SpdyGoAwayIR. | 605 // this SpdyGoAwayIR. |
606 SpdyGoAwayIR(SpdyStreamId last_good_stream_id, | 606 SpdyGoAwayIR(SpdyStreamId last_good_stream_id, |
(...skipping 26 matching lines...) Expand all Loading... |
633 | 633 |
634 private: | 634 private: |
635 SpdyStreamId last_good_stream_id_; | 635 SpdyStreamId last_good_stream_id_; |
636 SpdyErrorCode error_code_; | 636 SpdyErrorCode error_code_; |
637 const SpdyString description_store_; | 637 const SpdyString description_store_; |
638 const SpdyStringPiece description_; | 638 const SpdyStringPiece description_; |
639 | 639 |
640 DISALLOW_COPY_AND_ASSIGN(SpdyGoAwayIR); | 640 DISALLOW_COPY_AND_ASSIGN(SpdyGoAwayIR); |
641 }; | 641 }; |
642 | 642 |
643 class NET_EXPORT_PRIVATE SpdyHeadersIR : public SpdyFrameWithHeaderBlockIR { | 643 class SPDY_EXPORT_PRIVATE SpdyHeadersIR : public SpdyFrameWithHeaderBlockIR { |
644 public: | 644 public: |
645 explicit SpdyHeadersIR(SpdyStreamId stream_id) | 645 explicit SpdyHeadersIR(SpdyStreamId stream_id) |
646 : SpdyHeadersIR(stream_id, SpdyHeaderBlock()) {} | 646 : SpdyHeadersIR(stream_id, SpdyHeaderBlock()) {} |
647 SpdyHeadersIR(SpdyStreamId stream_id, SpdyHeaderBlock header_block) | 647 SpdyHeadersIR(SpdyStreamId stream_id, SpdyHeaderBlock header_block) |
648 : SpdyFrameWithHeaderBlockIR(stream_id, std::move(header_block)) {} | 648 : SpdyFrameWithHeaderBlockIR(stream_id, std::move(header_block)) {} |
649 | 649 |
650 void Visit(SpdyFrameVisitor* visitor) const override; | 650 void Visit(SpdyFrameVisitor* visitor) const override; |
651 | 651 |
652 SpdyFrameType frame_type() const override; | 652 SpdyFrameType frame_type() const override; |
653 | 653 |
(...skipping 19 matching lines...) Expand all Loading... |
673 bool has_priority_ = false; | 673 bool has_priority_ = false; |
674 int weight_ = kHttp2DefaultStreamWeight; | 674 int weight_ = kHttp2DefaultStreamWeight; |
675 SpdyStreamId parent_stream_id_ = 0; | 675 SpdyStreamId parent_stream_id_ = 0; |
676 bool exclusive_ = false; | 676 bool exclusive_ = false; |
677 bool padded_ = false; | 677 bool padded_ = false; |
678 int padding_payload_len_ = 0; | 678 int padding_payload_len_ = 0; |
679 | 679 |
680 DISALLOW_COPY_AND_ASSIGN(SpdyHeadersIR); | 680 DISALLOW_COPY_AND_ASSIGN(SpdyHeadersIR); |
681 }; | 681 }; |
682 | 682 |
683 class NET_EXPORT_PRIVATE SpdyWindowUpdateIR : public SpdyFrameWithStreamIdIR { | 683 class SPDY_EXPORT_PRIVATE SpdyWindowUpdateIR : public SpdyFrameWithStreamIdIR { |
684 public: | 684 public: |
685 SpdyWindowUpdateIR(SpdyStreamId stream_id, int32_t delta) | 685 SpdyWindowUpdateIR(SpdyStreamId stream_id, int32_t delta) |
686 : SpdyFrameWithStreamIdIR(stream_id) { | 686 : SpdyFrameWithStreamIdIR(stream_id) { |
687 set_delta(delta); | 687 set_delta(delta); |
688 } | 688 } |
689 int32_t delta() const { return delta_; } | 689 int32_t delta() const { return delta_; } |
690 void set_delta(int32_t delta) { | 690 void set_delta(int32_t delta) { |
691 DCHECK_LE(0, delta); | 691 DCHECK_LE(0, delta); |
692 DCHECK_LE(delta, kSpdyMaximumWindowSize); | 692 DCHECK_LE(delta, kSpdyMaximumWindowSize); |
693 delta_ = delta; | 693 delta_ = delta; |
694 } | 694 } |
695 | 695 |
696 void Visit(SpdyFrameVisitor* visitor) const override; | 696 void Visit(SpdyFrameVisitor* visitor) const override; |
697 | 697 |
698 SpdyFrameType frame_type() const override; | 698 SpdyFrameType frame_type() const override; |
699 | 699 |
700 private: | 700 private: |
701 int32_t delta_; | 701 int32_t delta_; |
702 | 702 |
703 DISALLOW_COPY_AND_ASSIGN(SpdyWindowUpdateIR); | 703 DISALLOW_COPY_AND_ASSIGN(SpdyWindowUpdateIR); |
704 }; | 704 }; |
705 | 705 |
706 class NET_EXPORT_PRIVATE SpdyPushPromiseIR : public SpdyFrameWithHeaderBlockIR { | 706 class SPDY_EXPORT_PRIVATE SpdyPushPromiseIR |
| 707 : public SpdyFrameWithHeaderBlockIR { |
707 public: | 708 public: |
708 SpdyPushPromiseIR(SpdyStreamId stream_id, SpdyStreamId promised_stream_id) | 709 SpdyPushPromiseIR(SpdyStreamId stream_id, SpdyStreamId promised_stream_id) |
709 : SpdyPushPromiseIR(stream_id, promised_stream_id, SpdyHeaderBlock()) {} | 710 : SpdyPushPromiseIR(stream_id, promised_stream_id, SpdyHeaderBlock()) {} |
710 SpdyPushPromiseIR(SpdyStreamId stream_id, | 711 SpdyPushPromiseIR(SpdyStreamId stream_id, |
711 SpdyStreamId promised_stream_id, | 712 SpdyStreamId promised_stream_id, |
712 SpdyHeaderBlock header_block) | 713 SpdyHeaderBlock header_block) |
713 : SpdyFrameWithHeaderBlockIR(stream_id, std::move(header_block)), | 714 : SpdyFrameWithHeaderBlockIR(stream_id, std::move(header_block)), |
714 promised_stream_id_(promised_stream_id), | 715 promised_stream_id_(promised_stream_id), |
715 padded_(false), | 716 padded_(false), |
716 padding_payload_len_(0) {} | 717 padding_payload_len_(0) {} |
(...skipping 15 matching lines...) Expand all Loading... |
732 | 733 |
733 private: | 734 private: |
734 SpdyStreamId promised_stream_id_; | 735 SpdyStreamId promised_stream_id_; |
735 | 736 |
736 bool padded_; | 737 bool padded_; |
737 int padding_payload_len_; | 738 int padding_payload_len_; |
738 | 739 |
739 DISALLOW_COPY_AND_ASSIGN(SpdyPushPromiseIR); | 740 DISALLOW_COPY_AND_ASSIGN(SpdyPushPromiseIR); |
740 }; | 741 }; |
741 | 742 |
742 class NET_EXPORT_PRIVATE SpdyContinuationIR : public SpdyFrameWithStreamIdIR { | 743 class SPDY_EXPORT_PRIVATE SpdyContinuationIR : public SpdyFrameWithStreamIdIR { |
743 public: | 744 public: |
744 explicit SpdyContinuationIR(SpdyStreamId stream_id); | 745 explicit SpdyContinuationIR(SpdyStreamId stream_id); |
745 ~SpdyContinuationIR() override; | 746 ~SpdyContinuationIR() override; |
746 | 747 |
747 void Visit(SpdyFrameVisitor* visitor) const override; | 748 void Visit(SpdyFrameVisitor* visitor) const override; |
748 | 749 |
749 SpdyFrameType frame_type() const override; | 750 SpdyFrameType frame_type() const override; |
750 | 751 |
751 bool end_headers() const { return end_headers_; } | 752 bool end_headers() const { return end_headers_; } |
752 void set_end_headers(bool end_headers) {end_headers_ = end_headers;} | 753 void set_end_headers(bool end_headers) {end_headers_ = end_headers;} |
753 const SpdyString& encoding() const { return *encoding_; } | 754 const SpdyString& encoding() const { return *encoding_; } |
754 void take_encoding(std::unique_ptr<SpdyString> encoding) { | 755 void take_encoding(std::unique_ptr<SpdyString> encoding) { |
755 encoding_ = std::move(encoding); | 756 encoding_ = std::move(encoding); |
756 } | 757 } |
757 | 758 |
758 private: | 759 private: |
759 std::unique_ptr<SpdyString> encoding_; | 760 std::unique_ptr<SpdyString> encoding_; |
760 bool end_headers_; | 761 bool end_headers_; |
761 DISALLOW_COPY_AND_ASSIGN(SpdyContinuationIR); | 762 DISALLOW_COPY_AND_ASSIGN(SpdyContinuationIR); |
762 }; | 763 }; |
763 | 764 |
764 class NET_EXPORT_PRIVATE SpdyAltSvcIR : public SpdyFrameWithStreamIdIR { | 765 class SPDY_EXPORT_PRIVATE SpdyAltSvcIR : public SpdyFrameWithStreamIdIR { |
765 public: | 766 public: |
766 explicit SpdyAltSvcIR(SpdyStreamId stream_id); | 767 explicit SpdyAltSvcIR(SpdyStreamId stream_id); |
767 ~SpdyAltSvcIR() override; | 768 ~SpdyAltSvcIR() override; |
768 | 769 |
769 SpdyString origin() const { return origin_; } | 770 SpdyString origin() const { return origin_; } |
770 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector() const { | 771 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector() const { |
771 return altsvc_vector_; | 772 return altsvc_vector_; |
772 } | 773 } |
773 | 774 |
774 void set_origin(SpdyString origin) { origin_ = std::move(origin); } | 775 void set_origin(SpdyString origin) { origin_ = std::move(origin); } |
775 void add_altsvc(const SpdyAltSvcWireFormat::AlternativeService& altsvc) { | 776 void add_altsvc(const SpdyAltSvcWireFormat::AlternativeService& altsvc) { |
776 altsvc_vector_.push_back(altsvc); | 777 altsvc_vector_.push_back(altsvc); |
777 } | 778 } |
778 | 779 |
779 void Visit(SpdyFrameVisitor* visitor) const override; | 780 void Visit(SpdyFrameVisitor* visitor) const override; |
780 | 781 |
781 SpdyFrameType frame_type() const override; | 782 SpdyFrameType frame_type() const override; |
782 | 783 |
783 private: | 784 private: |
784 SpdyString origin_; | 785 SpdyString origin_; |
785 SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector_; | 786 SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector_; |
786 DISALLOW_COPY_AND_ASSIGN(SpdyAltSvcIR); | 787 DISALLOW_COPY_AND_ASSIGN(SpdyAltSvcIR); |
787 }; | 788 }; |
788 | 789 |
789 class NET_EXPORT_PRIVATE SpdyPriorityIR : public SpdyFrameWithStreamIdIR { | 790 class SPDY_EXPORT_PRIVATE SpdyPriorityIR : public SpdyFrameWithStreamIdIR { |
790 public: | 791 public: |
791 SpdyPriorityIR(SpdyStreamId stream_id, | 792 SpdyPriorityIR(SpdyStreamId stream_id, |
792 SpdyStreamId parent_stream_id, | 793 SpdyStreamId parent_stream_id, |
793 int weight, | 794 int weight, |
794 bool exclusive) | 795 bool exclusive) |
795 : SpdyFrameWithStreamIdIR(stream_id), | 796 : SpdyFrameWithStreamIdIR(stream_id), |
796 parent_stream_id_(parent_stream_id), | 797 parent_stream_id_(parent_stream_id), |
797 weight_(weight), | 798 weight_(weight), |
798 exclusive_(exclusive) {} | 799 exclusive_(exclusive) {} |
799 SpdyStreamId parent_stream_id() const { return parent_stream_id_; } | 800 SpdyStreamId parent_stream_id() const { return parent_stream_id_; } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 SpdyFrameVisitor() {} | 912 SpdyFrameVisitor() {} |
912 virtual ~SpdyFrameVisitor() {} | 913 virtual ~SpdyFrameVisitor() {} |
913 | 914 |
914 private: | 915 private: |
915 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); | 916 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); |
916 }; | 917 }; |
917 | 918 |
918 } // namespace net | 919 } // namespace net |
919 | 920 |
920 #endif // NET_SPDY_CORE_SPDY_PROTOCOL_H_ | 921 #endif // NET_SPDY_CORE_SPDY_PROTOCOL_H_ |
OLD | NEW |