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

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

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

Powered by Google App Engine
This is Rietveld 408576698