| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 data structures and utility functions used for serializing | 5 // This file contains data structures and utility functions used for serializing |
| 6 // and parsing alternative service header values, common to HTTP/1.1 header | 6 // and parsing alternative service header values, common to HTTP/1.1 header |
| 7 // fields and HTTP/2 and QUIC ALTSVC frames. See specification at | 7 // fields and HTTP/2 and QUIC ALTSVC frames. See specification at |
| 8 // https://httpwg.github.io/http-extensions/alt-svc.html. | 8 // https://httpwg.github.io/http-extensions/alt-svc.html. |
| 9 | 9 |
| 10 #ifndef NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ | 10 #ifndef NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ |
| 11 #define NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ | 11 #define NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ |
| 12 | 12 |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
| 17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 18 | 18 |
| 19 using base::StringPiece; | 19 using base::StringPiece; |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 namespace test { | 23 namespace test { |
| 24 class SpdyAltSvcWireFormatPeer; | 24 class SpdyAltSvcWireFormatPeer; |
| 25 } // namespace test | 25 } // namespace test |
| 26 | 26 |
| 27 class NET_EXPORT_PRIVATE SpdyAltSvcWireFormat { | 27 class NET_EXPORT_PRIVATE SpdyAltSvcWireFormat { |
| 28 public: | 28 public: |
| 29 using VersionVector = std::vector<uint16>; |
| 30 |
| 29 struct NET_EXPORT_PRIVATE AlternativeService { | 31 struct NET_EXPORT_PRIVATE AlternativeService { |
| 30 std::string protocol_id; | 32 std::string protocol_id; |
| 31 std::string host; | 33 std::string host; |
| 34 |
| 32 // Default is 0: invalid port. | 35 // Default is 0: invalid port. |
| 33 uint16 port = 0; | 36 uint16 port = 0; |
| 34 // Default is 0: unspecified version. | |
| 35 uint16 version = 0; | |
| 36 // Default is one day. | 37 // Default is one day. |
| 37 uint32 max_age = 86400; | 38 uint32 max_age = 86400; |
| 38 // Default is always use. | 39 // Default is always use. |
| 39 double probability = 1.0; | 40 double probability = 1.0; |
| 41 // Default is empty: unspecified version. |
| 42 VersionVector version; |
| 40 | 43 |
| 41 AlternativeService(); | 44 AlternativeService(); |
| 42 AlternativeService(const std::string& protocol_id, | 45 AlternativeService(const std::string& protocol_id, |
| 43 const std::string& host, | 46 const std::string& host, |
| 44 uint16 port, | 47 uint16 port, |
| 45 uint16 version, | |
| 46 uint32 max_age, | 48 uint32 max_age, |
| 47 double probability); | 49 double probability, |
| 50 VersionVector version); |
| 51 ~AlternativeService(); |
| 48 | 52 |
| 49 bool operator==(const AlternativeService& other) const { | 53 bool operator==(const AlternativeService& other) const { |
| 50 return protocol_id == other.protocol_id && host == other.host && | 54 return protocol_id == other.protocol_id && host == other.host && |
| 51 port == other.port && version == other.version && | 55 port == other.port && version == other.version && |
| 52 max_age == other.max_age && probability == other.probability; | 56 max_age == other.max_age && probability == other.probability; |
| 53 } | 57 } |
| 54 }; | 58 }; |
| 55 // An empty vector means alternative services should be cleared for given | 59 // An empty vector means alternative services should be cleared for given |
| 56 // origin. Note that the wire format for this is the string "clear", not an | 60 // origin. Note that the wire format for this is the string "clear", not an |
| 57 // empty value (which is invalid). | 61 // empty value (which is invalid). |
| (...skipping 22 matching lines...) Expand all Loading... |
| 80 StringPiece::const_iterator end, | 84 StringPiece::const_iterator end, |
| 81 uint32* value); | 85 uint32* value); |
| 82 static bool ParseProbability(StringPiece::const_iterator c, | 86 static bool ParseProbability(StringPiece::const_iterator c, |
| 83 StringPiece::const_iterator end, | 87 StringPiece::const_iterator end, |
| 84 double* probability); | 88 double* probability); |
| 85 }; | 89 }; |
| 86 | 90 |
| 87 } // namespace net | 91 } // namespace net |
| 88 | 92 |
| 89 #endif // NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ | 93 #endif // NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ |
| OLD | NEW |