| 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 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 |
| 11 #ifndef NET_SPDY_SPDY_PROTOCOL_H_ | 11 #ifndef NET_SPDY_SPDY_PROTOCOL_H_ |
| 12 #define NET_SPDY_SPDY_PROTOCOL_H_ | 12 #define NET_SPDY_SPDY_PROTOCOL_H_ |
| 13 | 13 |
| 14 #include <limits> | 14 #include <limits> |
| 15 #include <map> | 15 #include <map> |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
| 20 #include "base/compiler_specific.h" | 20 #include "base/compiler_specific.h" |
| 21 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "base/strings/string_piece.h" | 23 #include "base/strings/string_piece.h" |
| 24 #include "base/sys_byteorder.h" | 24 #include "base/sys_byteorder.h" |
| 25 #include "net/base/net_export.h" | 25 #include "net/base/net_export.h" |
| 26 #include "net/spdy/spdy_alt_svc_wire_format.h" |
| 26 #include "net/spdy/spdy_bitmasks.h" | 27 #include "net/spdy/spdy_bitmasks.h" |
| 27 | 28 |
| 28 namespace net { | 29 namespace net { |
| 29 | 30 |
| 30 // The major versions of SPDY. Major version differences indicate | 31 // The major versions of SPDY. Major version differences indicate |
| 31 // framer-layer incompatibility, as opposed to minor version numbers | 32 // framer-layer incompatibility, as opposed to minor version numbers |
| 32 // which indicate application-layer incompatibility. Do not rely on | 33 // which indicate application-layer incompatibility. Do not rely on |
| 33 // the mapping from enum value SPDYn to the integer n. | 34 // the mapping from enum value SPDYn to the integer n. |
| 34 enum SpdyMajorVersion { | 35 enum SpdyMajorVersion { |
| 35 SPDY2 = 2, | 36 SPDY2 = 2, |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 }; | 963 }; |
| 963 | 964 |
| 964 // TODO(bnc): Add probability. | 965 // TODO(bnc): Add probability. |
| 965 // TODO(bnc): Separate (protocol, port, host, max_age, probability) tuple into | 966 // TODO(bnc): Separate (protocol, port, host, max_age, probability) tuple into |
| 966 // struct, have a vector of that struct. A single HTTP/1.1 header field or | 967 // struct, have a vector of that struct. A single HTTP/1.1 header field or |
| 967 // HTTP/2 or QUIC frame can define multiple such tuples. | 968 // HTTP/2 or QUIC frame can define multiple such tuples. |
| 968 class NET_EXPORT_PRIVATE SpdyAltSvcIR : public SpdyFrameWithStreamIdIR { | 969 class NET_EXPORT_PRIVATE SpdyAltSvcIR : public SpdyFrameWithStreamIdIR { |
| 969 public: | 970 public: |
| 970 explicit SpdyAltSvcIR(SpdyStreamId stream_id); | 971 explicit SpdyAltSvcIR(SpdyStreamId stream_id); |
| 971 | 972 |
| 972 uint32 max_age() const { return max_age_; } | 973 std::string origin() const { return origin_; } |
| 973 uint16 port() const { return port_; } | 974 const SpdyAltSvcWireFormat::AlternativeService& altsvc() const { |
| 974 SpdyProtocolId protocol_id() const { | 975 return altsvc_; |
| 975 return protocol_id_; | |
| 976 } | 976 } |
| 977 std::string host() const { return host_; } | 977 SpdyProtocolId protocol_id() const { return altsvc_.protocol_id; } |
| 978 std::string origin() const { return origin_; } | 978 std::string host() const { return altsvc_.host; } |
| 979 uint16 port() const { return altsvc_.port; } |
| 980 uint32 max_age() const { return altsvc_.max_age; } |
| 981 double p() const { return altsvc_.p; } |
| 979 | 982 |
| 980 void set_max_age(uint32 max_age) { max_age_ = max_age; } | 983 void set_origin(std::string origin) { origin_ = origin; } |
| 981 void set_port(uint16 port) { port_ = port; } | |
| 982 void set_protocol_id(SpdyProtocolId protocol_id) { | 984 void set_protocol_id(SpdyProtocolId protocol_id) { |
| 983 protocol_id_ = protocol_id; | 985 altsvc_.protocol_id = protocol_id; |
| 984 } | 986 } |
| 985 void set_host(std::string host) { host_ = host; } | 987 void set_host(std::string host) { altsvc_.host = host; } |
| 986 void set_origin(std::string origin) { origin_ = origin; } | 988 void set_port(uint16 port) { altsvc_.port = port; } |
| 989 void set_max_age(uint32 max_age) { altsvc_.max_age = max_age; } |
| 990 void set_p(double p) { altsvc_.p = p; } |
| 987 | 991 |
| 988 void Visit(SpdyFrameVisitor* visitor) const override; | 992 void Visit(SpdyFrameVisitor* visitor) const override; |
| 989 | 993 |
| 990 private: | 994 private: |
| 991 uint32 max_age_; | |
| 992 uint16 port_; | |
| 993 SpdyProtocolId protocol_id_; | |
| 994 std::string host_; | |
| 995 std::string origin_; | 995 std::string origin_; |
| 996 SpdyAltSvcWireFormat::AlternativeService altsvc_; |
| 996 DISALLOW_COPY_AND_ASSIGN(SpdyAltSvcIR); | 997 DISALLOW_COPY_AND_ASSIGN(SpdyAltSvcIR); |
| 997 }; | 998 }; |
| 998 | 999 |
| 999 class NET_EXPORT_PRIVATE SpdyPriorityIR : public SpdyFrameWithStreamIdIR { | 1000 class NET_EXPORT_PRIVATE SpdyPriorityIR : public SpdyFrameWithStreamIdIR { |
| 1000 public: | 1001 public: |
| 1001 explicit SpdyPriorityIR(SpdyStreamId stream_id) | 1002 explicit SpdyPriorityIR(SpdyStreamId stream_id) |
| 1002 : SpdyFrameWithStreamIdIR(stream_id), | 1003 : SpdyFrameWithStreamIdIR(stream_id), |
| 1003 parent_stream_id_(0), | 1004 parent_stream_id_(0), |
| 1004 weight_(1), | 1005 weight_(1), |
| 1005 exclusive_(false) {} | 1006 exclusive_(false) {} |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 SpdyFrameVisitor() {} | 1096 SpdyFrameVisitor() {} |
| 1096 virtual ~SpdyFrameVisitor() {} | 1097 virtual ~SpdyFrameVisitor() {} |
| 1097 | 1098 |
| 1098 private: | 1099 private: |
| 1099 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); | 1100 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); |
| 1100 }; | 1101 }; |
| 1101 | 1102 |
| 1102 } // namespace net | 1103 } // namespace net |
| 1103 | 1104 |
| 1104 #endif // NET_SPDY_SPDY_PROTOCOL_H_ | 1105 #endif // NET_SPDY_SPDY_PROTOCOL_H_ |
| OLD | NEW |