| 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 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
| 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 BROKEN_ALTERNATE_PROTOCOL_LOCATION_QUIC_STREAM_FACTORY = 1, | 59 BROKEN_ALTERNATE_PROTOCOL_LOCATION_QUIC_STREAM_FACTORY = 1, |
| 60 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT = 2, | 60 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT = 2, |
| 61 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN = 3, | 61 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN = 3, |
| 62 BROKEN_ALTERNATE_PROTOCOL_LOCATION_MAX, | 62 BROKEN_ALTERNATE_PROTOCOL_LOCATION_MAX, |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // Log a histogram to reflect |location|. | 65 // Log a histogram to reflect |location|. |
| 66 NET_EXPORT void HistogramBrokenAlternateProtocolLocation( | 66 NET_EXPORT void HistogramBrokenAlternateProtocolLocation( |
| 67 BrokenAlternateProtocolLocation location); | 67 BrokenAlternateProtocolLocation location); |
| 68 | 68 |
| 69 enum AlternateProtocol { | 69 NET_EXPORT bool IsAlternateProtocolValid(NextProto protocol); |
| 70 NPN_HTTP_2, | |
| 71 QUIC, | |
| 72 UNINITIALIZED_ALTERNATE_PROTOCOL, | |
| 73 }; | |
| 74 | |
| 75 NET_EXPORT bool IsAlternateProtocolValid(AlternateProtocol protocol); | |
| 76 | |
| 77 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol); | |
| 78 NET_EXPORT AlternateProtocol AlternateProtocolFromString( | |
| 79 const std::string& str); | |
| 80 NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto( | |
| 81 NextProto next_proto); | |
| 82 | 70 |
| 83 // (protocol, host, port) triple as defined in | 71 // (protocol, host, port) triple as defined in |
| 84 // https://tools.ietf.org/id/draft-ietf-httpbis-alt-svc-06.html | 72 // https://tools.ietf.org/id/draft-ietf-httpbis-alt-svc-06.html |
| 85 struct NET_EXPORT AlternativeService { | 73 struct NET_EXPORT AlternativeService { |
| 86 AlternativeService() | 74 AlternativeService() : protocol(kProtoUnknown), host(), port(0) {} |
| 87 : protocol(UNINITIALIZED_ALTERNATE_PROTOCOL), host(), port(0) {} | |
| 88 | 75 |
| 89 AlternativeService(AlternateProtocol protocol, | 76 AlternativeService(NextProto protocol, const std::string& host, uint16_t port) |
| 90 const std::string& host, | |
| 91 uint16_t port) | |
| 92 : protocol(protocol), host(host), port(port) {} | 77 : protocol(protocol), host(host), port(port) {} |
| 93 | 78 |
| 94 AlternativeService(AlternateProtocol protocol, | 79 AlternativeService(NextProto protocol, const HostPortPair& host_port_pair) |
| 95 const HostPortPair& host_port_pair) | |
| 96 : protocol(protocol), | 80 : protocol(protocol), |
| 97 host(host_port_pair.host()), | 81 host(host_port_pair.host()), |
| 98 port(host_port_pair.port()) {} | 82 port(host_port_pair.port()) {} |
| 99 | 83 |
| 100 AlternativeService(const AlternativeService& alternative_service) = default; | 84 AlternativeService(const AlternativeService& alternative_service) = default; |
| 101 AlternativeService& operator=(const AlternativeService& alternative_service) = | 85 AlternativeService& operator=(const AlternativeService& alternative_service) = |
| 102 default; | 86 default; |
| 103 | 87 |
| 104 HostPortPair host_port_pair() const { return HostPortPair(host, port); } | 88 HostPortPair host_port_pair() const { return HostPortPair(host, port); } |
| 105 | 89 |
| 106 bool operator==(const AlternativeService& other) const { | 90 bool operator==(const AlternativeService& other) const { |
| 107 return protocol == other.protocol && host == other.host && | 91 return protocol == other.protocol && host == other.host && |
| 108 port == other.port; | 92 port == other.port; |
| 109 } | 93 } |
| 110 | 94 |
| 111 bool operator!=(const AlternativeService& other) const { | 95 bool operator!=(const AlternativeService& other) const { |
| 112 return !this->operator==(other); | 96 return !this->operator==(other); |
| 113 } | 97 } |
| 114 | 98 |
| 115 bool operator<(const AlternativeService& other) const { | 99 bool operator<(const AlternativeService& other) const { |
| 116 return std::tie(protocol, host, port) < | 100 return std::tie(protocol, host, port) < |
| 117 std::tie(other.protocol, other.host, other.port); | 101 std::tie(other.protocol, other.host, other.port); |
| 118 } | 102 } |
| 119 | 103 |
| 120 std::string ToString() const; | 104 std::string ToString() const; |
| 121 | 105 |
| 122 AlternateProtocol protocol; | 106 NextProto protocol; |
| 123 std::string host; | 107 std::string host; |
| 124 uint16_t port; | 108 uint16_t port; |
| 125 }; | 109 }; |
| 126 | 110 |
| 127 struct NET_EXPORT AlternativeServiceInfo { | 111 struct NET_EXPORT AlternativeServiceInfo { |
| 128 AlternativeServiceInfo() : alternative_service() {} | 112 AlternativeServiceInfo() : alternative_service() {} |
| 129 | 113 |
| 130 AlternativeServiceInfo(const AlternativeService& alternative_service, | 114 AlternativeServiceInfo(const AlternativeService& alternative_service, |
| 131 base::Time expiration) | 115 base::Time expiration) |
| 132 : alternative_service(alternative_service), | 116 : alternative_service(alternative_service), |
| 133 expiration(expiration) {} | 117 expiration(expiration) {} |
| 134 | 118 |
| 135 AlternativeServiceInfo(AlternateProtocol protocol, | 119 AlternativeServiceInfo(NextProto protocol, |
| 136 const std::string& host, | 120 const std::string& host, |
| 137 uint16_t port, | 121 uint16_t port, |
| 138 base::Time expiration) | 122 base::Time expiration) |
| 139 : alternative_service(protocol, host, port), | 123 : alternative_service(protocol, host, port), expiration(expiration) {} |
| 140 expiration(expiration) {} | |
| 141 | 124 |
| 142 AlternativeServiceInfo( | 125 AlternativeServiceInfo( |
| 143 const AlternativeServiceInfo& alternative_service_info) = default; | 126 const AlternativeServiceInfo& alternative_service_info) = default; |
| 144 AlternativeServiceInfo& operator=( | 127 AlternativeServiceInfo& operator=( |
| 145 const AlternativeServiceInfo& alternative_service_info) = default; | 128 const AlternativeServiceInfo& alternative_service_info) = default; |
| 146 | 129 |
| 147 bool operator==(const AlternativeServiceInfo& other) const { | 130 bool operator==(const AlternativeServiceInfo& other) const { |
| 148 return alternative_service == other.alternative_service && | 131 return alternative_service == other.alternative_service && |
| 149 expiration == other.expiration; | 132 expiration == other.expiration; |
| 150 } | 133 } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 virtual void SetMaxServerConfigsStoredInProperties( | 343 virtual void SetMaxServerConfigsStoredInProperties( |
| 361 size_t max_server_configs_stored_in_properties) = 0; | 344 size_t max_server_configs_stored_in_properties) = 0; |
| 362 | 345 |
| 363 private: | 346 private: |
| 364 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); | 347 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); |
| 365 }; | 348 }; |
| 366 | 349 |
| 367 } // namespace net | 350 } // namespace net |
| 368 | 351 |
| 369 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 352 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
| OLD | NEW |