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