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

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

Issue 290003006: Land recent SPDY changes (through 67282679) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on nullptr => NULL 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_headers_block_parser_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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 SETTINGS, 280 SETTINGS,
281 NOOP, // Because it is valid in SPDY/2, kept for identifiability/enum order. 281 NOOP, // Because it is valid in SPDY/2, kept for identifiability/enum order.
282 PING, 282 PING,
283 GOAWAY, 283 GOAWAY,
284 HEADERS, 284 HEADERS,
285 WINDOW_UPDATE, 285 WINDOW_UPDATE,
286 CREDENTIAL, // No longer valid. Kept for identifiability/enum order. 286 CREDENTIAL, // No longer valid. Kept for identifiability/enum order.
287 BLOCKED, 287 BLOCKED,
288 PUSH_PROMISE, 288 PUSH_PROMISE,
289 CONTINUATION, 289 CONTINUATION,
290 LAST_CONTROL_TYPE = CONTINUATION 290 ALTSVC,
291 PRIORITY,
292 LAST_CONTROL_TYPE = PRIORITY
291 }; 293 };
292 294
293 // Flags on data packets. 295 // Flags on data packets.
294 enum SpdyDataFlags { 296 enum SpdyDataFlags {
295 DATA_FLAG_NONE = 0x00, 297 DATA_FLAG_NONE = 0x00,
296 DATA_FLAG_FIN = 0x01, 298 DATA_FLAG_FIN = 0x01,
297 DATA_FLAG_END_SEGMENT = 0x02, 299 DATA_FLAG_END_SEGMENT = 0x02,
298 DATA_FLAG_PAD_LOW = 0x10, 300 DATA_FLAG_PAD_LOW = 0x08,
299 DATA_FLAG_PAD_HIGH = 0x20 301 DATA_FLAG_PAD_HIGH = 0x10,
302 DATA_FLAG_COMPRESSED = 0x20,
300 }; 303 };
301 304
302 // Flags on control packets 305 // Flags on control packets
303 enum SpdyControlFlags { 306 enum SpdyControlFlags {
304 CONTROL_FLAG_NONE = 0, 307 CONTROL_FLAG_NONE = 0x00,
305 CONTROL_FLAG_FIN = 1, 308 CONTROL_FLAG_FIN = 0x01,
306 CONTROL_FLAG_UNIDIRECTIONAL = 2 309 CONTROL_FLAG_UNIDIRECTIONAL = 0x02,
307 }; 310 };
308 311
309 enum SpdyPingFlags { 312 enum SpdyPingFlags {
310 PING_FLAG_ACK = 0x1, 313 PING_FLAG_ACK = 0x01,
311 }; 314 };
312 315
316 // Used by HEADERS, PUSH_PROMISE, and CONTINUATION.
313 enum SpdyHeadersFlags { 317 enum SpdyHeadersFlags {
314 HEADERS_FLAG_END_HEADERS = 0x4, 318 HEADERS_FLAG_END_SEGMENT = 0x02,
315 HEADERS_FLAG_PRIORITY = 0x8 319 HEADERS_FLAG_END_HEADERS = 0x04,
320 HEADERS_FLAG_PAD_LOW = 0x08,
321 HEADERS_FLAG_PAD_HIGH = 0x10,
322 HEADERS_FLAG_PRIORITY = 0x20,
316 }; 323 };
317 324
318 enum SpdyPushPromiseFlags { 325 enum SpdyPushPromiseFlags {
319 PUSH_PROMISE_FLAG_END_PUSH_PROMISE = 0x4 326 PUSH_PROMISE_FLAG_END_PUSH_PROMISE = 0x04,
320 }; 327 };
321 328
322 // Flags on the SETTINGS control frame. 329 // Flags on the SETTINGS control frame.
323 enum SpdySettingsControlFlags { 330 enum SpdySettingsControlFlags {
324 SETTINGS_FLAG_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS = 0x1 331 SETTINGS_FLAG_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS = 0x01,
325 }; 332 };
326 333
327 enum Http2SettingsControlFlags { 334 enum Http2SettingsControlFlags {
328 SETTINGS_FLAG_ACK = 0x1, 335 SETTINGS_FLAG_ACK = 0x01,
329 }; 336 };
330 337
331 // Flags for settings within a SETTINGS frame. 338 // Flags for settings within a SETTINGS frame.
332 enum SpdySettingsFlags { 339 enum SpdySettingsFlags {
333 SETTINGS_FLAG_NONE = 0x0, 340 SETTINGS_FLAG_NONE = 0x00,
334 SETTINGS_FLAG_PLEASE_PERSIST = 0x1, 341 SETTINGS_FLAG_PLEASE_PERSIST = 0x01,
335 SETTINGS_FLAG_PERSISTED = 0x2 342 SETTINGS_FLAG_PERSISTED = 0x02,
336 }; 343 };
337 344
338 // List of known settings. Avoid changing these enum values, as persisted 345 // List of known settings. Avoid changing these enum values, as persisted
339 // settings are keyed on them, and they are also exposed in net-internals. 346 // settings are keyed on them, and they are also exposed in net-internals.
340 enum SpdySettingsIds { 347 enum SpdySettingsIds {
341 SETTINGS_UPLOAD_BANDWIDTH = 0x1, 348 SETTINGS_UPLOAD_BANDWIDTH = 0x1,
342 SETTINGS_DOWNLOAD_BANDWIDTH = 0x2, 349 SETTINGS_DOWNLOAD_BANDWIDTH = 0x2,
343 // Network round trip time in milliseconds. 350 // Network round trip time in milliseconds.
344 SETTINGS_ROUND_TRIP_TIME = 0x3, 351 SETTINGS_ROUND_TRIP_TIME = 0x3,
345 // The maximum number of simultaneous live streams in each direction. 352 // The maximum number of simultaneous live streams in each direction.
346 SETTINGS_MAX_CONCURRENT_STREAMS = 0x4, 353 SETTINGS_MAX_CONCURRENT_STREAMS = 0x4,
347 // TCP congestion window in packets. 354 // TCP congestion window in packets.
348 SETTINGS_CURRENT_CWND = 0x5, 355 SETTINGS_CURRENT_CWND = 0x5,
349 // Downstream byte retransmission rate in percentage. 356 // Downstream byte retransmission rate in percentage.
350 SETTINGS_DOWNLOAD_RETRANS_RATE = 0x6, 357 SETTINGS_DOWNLOAD_RETRANS_RATE = 0x6,
351 // Initial window size in bytes 358 // Initial window size in bytes
352 SETTINGS_INITIAL_WINDOW_SIZE = 0x7, 359 SETTINGS_INITIAL_WINDOW_SIZE = 0x7,
353 // HPACK header table maximum size. 360 // HPACK header table maximum size.
354 SETTINGS_HEADER_TABLE_SIZE = 0x8, 361 SETTINGS_HEADER_TABLE_SIZE = 0x8,
355 // Whether or not server push (PUSH_PROMISE) is enabled. 362 // Whether or not server push (PUSH_PROMISE) is enabled.
356 SETTINGS_ENABLE_PUSH = 0x9, 363 SETTINGS_ENABLE_PUSH = 0x9,
364 // Whether or not to enable GZip compression of DATA frames.
365 SETTINGS_COMPRESS_DATA = 0xa,
357 }; 366 };
358 367
359 // Status codes for RST_STREAM frames. 368 // Status codes for RST_STREAM frames.
360 enum SpdyRstStreamStatus { 369 enum SpdyRstStreamStatus {
361 RST_STREAM_INVALID = 0, 370 RST_STREAM_INVALID = 0,
362 RST_STREAM_PROTOCOL_ERROR = 1, 371 RST_STREAM_PROTOCOL_ERROR = 1,
363 RST_STREAM_INVALID_STREAM = 2, 372 RST_STREAM_INVALID_STREAM = 2,
364 RST_STREAM_STREAM_CLOSED = 2, // Equivalent to INVALID_STREAM 373 RST_STREAM_STREAM_CLOSED = 2, // Equivalent to INVALID_STREAM
365 RST_STREAM_REFUSED_STREAM = 3, 374 RST_STREAM_REFUSED_STREAM = 3,
366 RST_STREAM_UNSUPPORTED_VERSION = 4, 375 RST_STREAM_UNSUPPORTED_VERSION = 4,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 410
402 // A SPDY priority is a number between 0 and 7 (inclusive). 411 // A SPDY priority is a number between 0 and 7 (inclusive).
403 // SPDY priority range is version-dependent. For SPDY 2 and below, priority is a 412 // SPDY priority range is version-dependent. For SPDY 2 and below, priority is a
404 // number between 0 and 3. 413 // number between 0 and 3.
405 typedef uint8 SpdyPriority; 414 typedef uint8 SpdyPriority;
406 415
407 typedef std::map<std::string, std::string> SpdyNameValueBlock; 416 typedef std::map<std::string, std::string> SpdyNameValueBlock;
408 417
409 typedef uint64 SpdyPingId; 418 typedef uint64 SpdyPingId;
410 419
420 typedef std::string SpdyProtocolId;
421
411 // TODO(hkhalil): Add direct testing for this? It won't increase coverage any, 422 // TODO(hkhalil): Add direct testing for this? It won't increase coverage any,
412 // but is good to do anyway. 423 // but is good to do anyway.
413 class NET_EXPORT_PRIVATE SpdyConstants { 424 class NET_EXPORT_PRIVATE SpdyConstants {
414 public: 425 public:
415 // Returns true if a given on-the-wire enumeration of a frame type is valid 426 // Returns true if a given on-the-wire enumeration of a frame type is valid
416 // for a given protocol version, false otherwise. 427 // for a given protocol version, false otherwise.
417 static bool IsValidFrameType(SpdyMajorVersion version, int frame_type_field); 428 static bool IsValidFrameType(SpdyMajorVersion version, int frame_type_field);
418 429
419 // Parses a frame type from an on-the-wire enumeration of a given protocol 430 // Parses a frame type from an on-the-wire enumeration of a given protocol
420 // version. 431 // version.
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 virtual void Visit(SpdyFrameVisitor* visitor) const OVERRIDE; 919 virtual void Visit(SpdyFrameVisitor* visitor) const OVERRIDE;
909 920
910 bool end_headers() const { return end_headers_; } 921 bool end_headers() const { return end_headers_; }
911 void set_end_headers(bool end_headers) {end_headers_ = end_headers;} 922 void set_end_headers(bool end_headers) {end_headers_ = end_headers;}
912 923
913 private: 924 private:
914 bool end_headers_; 925 bool end_headers_;
915 DISALLOW_COPY_AND_ASSIGN(SpdyContinuationIR); 926 DISALLOW_COPY_AND_ASSIGN(SpdyContinuationIR);
916 }; 927 };
917 928
929 class NET_EXPORT_PRIVATE SpdyAltSvcIR : public SpdyFrameWithStreamIdIR {
930 public:
931 explicit SpdyAltSvcIR(SpdyStreamId stream_id);
932
933 uint32 max_age() const { return max_age_; }
934 uint16 port() const { return port_; }
935 SpdyProtocolId protocol_id() const {
936 return protocol_id_;
937 }
938 std::string host() const { return host_; }
939 std::string origin() const { return origin_; }
940
941 void set_max_age(uint32 max_age) { max_age_ = max_age; }
942 void set_port(uint16 port) { port_ = port; }
943 void set_protocol_id(SpdyProtocolId protocol_id) {
944 protocol_id_ = protocol_id;
945 }
946 void set_host(std::string host) {
947 host_ = host;
948 }
949 void set_origin(std::string origin) {
950 origin_ = origin;
951 }
952
953 virtual void Visit(SpdyFrameVisitor* visitor) const OVERRIDE;
954
955 private:
956 uint32 max_age_;
957 uint16 port_;
958 SpdyProtocolId protocol_id_;
959 std::string host_;
960 std::string origin_;
961 DISALLOW_COPY_AND_ASSIGN(SpdyAltSvcIR);
962 };
963
918 // ------------------------------------------------------------------------- 964 // -------------------------------------------------------------------------
919 // Wrapper classes for various SPDY frames. 965 // Wrapper classes for various SPDY frames.
920 966
921 // All Spdy Frame types derive from this SpdyFrame class. 967 // All Spdy Frame types derive from this SpdyFrame class.
922 class SpdyFrame { 968 class SpdyFrame {
923 public: 969 public:
924 // Create a SpdyFrame using a pre-created buffer. 970 // Create a SpdyFrame using a pre-created buffer.
925 // If |owns_buffer| is true, this class takes ownership of the buffer 971 // If |owns_buffer| is true, this class takes ownership of the buffer
926 // and will delete it on cleanup. The buffer must have been created using 972 // and will delete it on cleanup. The buffer must have been created using
927 // new char[]. 973 // new char[].
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 virtual void VisitSynReply(const SpdySynReplyIR& syn_reply) = 0; 1014 virtual void VisitSynReply(const SpdySynReplyIR& syn_reply) = 0;
969 virtual void VisitRstStream(const SpdyRstStreamIR& rst_stream) = 0; 1015 virtual void VisitRstStream(const SpdyRstStreamIR& rst_stream) = 0;
970 virtual void VisitSettings(const SpdySettingsIR& settings) = 0; 1016 virtual void VisitSettings(const SpdySettingsIR& settings) = 0;
971 virtual void VisitPing(const SpdyPingIR& ping) = 0; 1017 virtual void VisitPing(const SpdyPingIR& ping) = 0;
972 virtual void VisitGoAway(const SpdyGoAwayIR& goaway) = 0; 1018 virtual void VisitGoAway(const SpdyGoAwayIR& goaway) = 0;
973 virtual void VisitHeaders(const SpdyHeadersIR& headers) = 0; 1019 virtual void VisitHeaders(const SpdyHeadersIR& headers) = 0;
974 virtual void VisitWindowUpdate(const SpdyWindowUpdateIR& window_update) = 0; 1020 virtual void VisitWindowUpdate(const SpdyWindowUpdateIR& window_update) = 0;
975 virtual void VisitBlocked(const SpdyBlockedIR& blocked) = 0; 1021 virtual void VisitBlocked(const SpdyBlockedIR& blocked) = 0;
976 virtual void VisitPushPromise(const SpdyPushPromiseIR& push_promise) = 0; 1022 virtual void VisitPushPromise(const SpdyPushPromiseIR& push_promise) = 0;
977 virtual void VisitContinuation(const SpdyContinuationIR& continuation) = 0; 1023 virtual void VisitContinuation(const SpdyContinuationIR& continuation) = 0;
1024 virtual void VisitAltSvc(const SpdyAltSvcIR& altsvc) = 0;
978 virtual void VisitData(const SpdyDataIR& data) = 0; 1025 virtual void VisitData(const SpdyDataIR& data) = 0;
979 1026
980 protected: 1027 protected:
981 SpdyFrameVisitor() {} 1028 SpdyFrameVisitor() {}
982 virtual ~SpdyFrameVisitor() {} 1029 virtual ~SpdyFrameVisitor() {}
983 1030
984 private: 1031 private:
985 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); 1032 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor);
986 }; 1033 };
987 1034
988 } // namespace net 1035 } // namespace net
989 1036
990 #endif // NET_SPDY_SPDY_PROTOCOL_H_ 1037 #endif // NET_SPDY_SPDY_PROTOCOL_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_headers_block_parser_test.cc ('k') | net/spdy/spdy_protocol.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698