| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_QUIC_PLATFORM_API_QUIC_ENDIAN_H_ | 5 #ifndef NET_QUIC_PLATFORM_API_QUIC_ENDIAN_H_ |
| 6 #define NET_QUIC_PLATFORM_API_QUIC_ENDIAN_H_ | 6 #define NET_QUIC_PLATFORM_API_QUIC_ENDIAN_H_ |
| 7 | 7 |
| 8 #include "net/quic/platform/impl/quic_endian_impl.h" | 8 #include "net/quic/platform/impl/quic_endian_impl.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 | 11 |
| 12 enum Endianness { |
| 13 NETWORK_BYTE_ORDER, // big endian |
| 14 HOST_BYTE_ORDER // little endian |
| 15 }; |
| 16 |
| 12 // Provide utility functions that convert from/to network order (big endian) | 17 // Provide utility functions that convert from/to network order (big endian) |
| 13 // to/from host order (can be either little or big endian depending on the | 18 // to/from host order (can be either little or big endian depending on the |
| 14 // platform). | 19 // platform). |
| 15 class QuicEndian { | 20 class QuicEndian { |
| 16 public: | 21 public: |
| 17 // Convert |x| from host order (can be either little or big endian depending | 22 // Convert |x| from host order (can be either little or big endian depending |
| 18 // on the platform) to network order (big endian). | 23 // on the platform) to network order (big endian). |
| 19 static uint16_t HostToNet16(uint16_t x) { | 24 static uint16_t HostToNet16(uint16_t x) { |
| 20 return QuicEndianImpl::HostToNet16(x); | 25 return QuicEndianImpl::HostToNet16(x); |
| 21 } | 26 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 | 45 |
| 41 // Returns true if current host order is little endian. | 46 // Returns true if current host order is little endian. |
| 42 static bool HostIsLittleEndian() { | 47 static bool HostIsLittleEndian() { |
| 43 return QuicEndianImpl::HostIsLittleEndian(); | 48 return QuicEndianImpl::HostIsLittleEndian(); |
| 44 } | 49 } |
| 45 }; | 50 }; |
| 46 | 51 |
| 47 } // namespace net | 52 } // namespace net |
| 48 | 53 |
| 49 #endif // NET_QUIC_PLATFORM_API_QUIC_ENDIAN_H_ | 54 #endif // NET_QUIC_PLATFORM_API_QUIC_ENDIAN_H_ |
| OLD | NEW |