summaryrefslogtreecommitdiff
path: root/chromium/net/quic/core/quic_data_reader.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/quic/core/quic_data_reader.h')
-rw-r--r--chromium/net/quic/core/quic_data_reader.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/chromium/net/quic/core/quic_data_reader.h b/chromium/net/quic/core/quic_data_reader.h
index 9507ec19bf4..755f2fcc66f 100644
--- a/chromium/net/quic/core/quic_data_reader.h
+++ b/chromium/net/quic/core/quic_data_reader.h
@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "net/base/int128.h"
#include "net/quic/core/quic_types.h"
+#include "net/quic/platform/api/quic_endian.h"
#include "net/quic/platform/api/quic_export.h"
#include "net/quic/platform/api/quic_string_piece.h"
@@ -33,26 +34,26 @@ namespace net {
class QUIC_EXPORT_PRIVATE QuicDataReader {
public:
// Caller must provide an underlying buffer to work on.
- QuicDataReader(const char* data, const size_t len, Perspective perspective);
+ QuicDataReader(const char* data,
+ const size_t len,
+ Perspective perspective,
+ Endianness endianness);
// Empty destructor.
~QuicDataReader() {}
- // Reads a 16-bit unsigned integer into the given output parameter.
- // Forwards the internal iterator on success.
- // Returns true on success, false otherwise.
+ // Reads an 8/16/32/64-bit unsigned integer into the given output
+ // parameter. Forwards the internal iterator on success. Returns true on
+ // success, false otherwise.
+ bool ReadUInt8(uint8_t* result);
bool ReadUInt16(uint16_t* result);
-
- // Reads a 32-bit unsigned integer into the given output parameter.
- // Forwards the internal iterator on success.
- // Returns true on success, false otherwise.
bool ReadUInt32(uint32_t* result);
-
- // Reads a 64-bit unsigned integer into the given output parameter.
- // Forwards the internal iterator on success.
- // Returns true on success, false otherwise.
bool ReadUInt64(uint64_t* result);
+ // Reads |num_bytes| bytes in the correct byte order into least significant
+ // bytes of |result|.
+ bool ReadBytesToUInt64(size_t num_bytes, uint64_t* result);
+
// Reads a 16-bit unsigned float into the given output parameter.
// Forwards the internal iterator on success.
// Returns true on success, false otherwise.
@@ -118,6 +119,14 @@ class QUIC_EXPORT_PRIVATE QuicDataReader {
// Returns the number of bytes remaining to be read.
size_t BytesRemaining() const;
+ // Returns the next byte that to be read. Must not be called when there are no
+ // bytes to be read.
+ //
+ // DOES NOT forward the internal iterator.
+ uint8_t PeekByte() const;
+
+ void set_endianness(Endianness endianness) { endianness_ = endianness; }
+
private:
// Returns true if the underlying buffer has enough room to read the given
// amount of bytes.
@@ -140,6 +149,9 @@ class QUIC_EXPORT_PRIVATE QuicDataReader {
// representation must be consistent.
Perspective perspective_;
+ // The endianness to read integers and floating numbers.
+ Endianness endianness_;
+
DISALLOW_COPY_AND_ASSIGN(QuicDataReader);
};