Merge "Support for IPv6 in HTTP socket and BufferReader unittests"

This commit is contained in:
Rahul Frias
2015-10-02 23:24:35 +00:00
committed by Android (Google) Code Review
11 changed files with 955 additions and 70 deletions

View File

@@ -24,9 +24,9 @@ namespace wvcdm {
class BufferReader {
public:
BufferReader(const uint8_t* buf, size_t size)
: buf_(buf), size_(size), pos_(0) {}
: buf_(buf), size_(buf != NULL ? size : 0), pos_(0) {}
bool HasBytes(int count) { return (pos() + count <= size()); }
bool HasBytes(size_t count) { return (pos() + count <= size()); }
// Read a value from the stream, performing endian correction,
// and advance the stream pointer.
@@ -38,8 +38,8 @@ class BufferReader {
bool Read8(uint64_t* v) WARN_UNUSED_RESULT;
bool Read8s(int64_t* v) WARN_UNUSED_RESULT;
bool ReadString(std::string* str, int count) WARN_UNUSED_RESULT;
bool ReadVec(std::vector<uint8_t>* t, int count) WARN_UNUSED_RESULT;
bool ReadString(std::string* str, size_t count) WARN_UNUSED_RESULT;
bool ReadVec(std::vector<uint8_t>* t, size_t count) WARN_UNUSED_RESULT;
// These variants read a 4-byte integer of the corresponding signedness and
// store it in the 8-byte return type.
@@ -47,7 +47,7 @@ class BufferReader {
bool Read4sInto8s(int64_t* v) WARN_UNUSED_RESULT;
// Advance the stream by this many bytes.
bool SkipBytes(int nbytes) WARN_UNUSED_RESULT;
bool SkipBytes(size_t nbytes) WARN_UNUSED_RESULT;
const uint8_t* data() const { return buf_; }
size_t size() const { return size_; }