Revert "Remove deprecated ByteBufferReader and ByteBufferWriter functions"
This reverts commit e0e03ba73a0859924a55c4dfa4ce20ff80820f0b. Reason for revert: Speculative rollback (breaks WebKit Linux Leak) Original change's description: > Remove deprecated ByteBufferReader and ByteBufferWriter functions > > This completes the conversion of ByteBufferReader and ByteBufferWriter > to uint8_t. > > No-Try: True > Bug: webrtc:15661 > Change-Id: I4152a8a4fd2462282d4107b3c2eed19acc8b29b0 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/331640 > Commit-Queue: Harald Alvestrand <hta@webrtc.org> > Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#41403} Bug: webrtc:15661, chromium:1513059 Change-Id: I3938b8209f5cc1596307deadac157a8f6c2b2253 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/331940 Owners-Override: Mirko Bonadei <mbonadei@webrtc.org> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41411}
This commit is contained in:
parent
c5daa63cef
commit
ca58f0eb9d
@ -587,7 +587,7 @@ bool StunMessage::AddFingerprint() {
|
|||||||
|
|
||||||
bool StunMessage::Read(ByteBufferReader* buf) {
|
bool StunMessage::Read(ByteBufferReader* buf) {
|
||||||
// Keep a copy of the buffer data around for later verification.
|
// Keep a copy of the buffer data around for later verification.
|
||||||
buffer_.assign(reinterpret_cast<const char*>(buf->Data()), buf->Length());
|
buffer_.assign(buf->Data(), buf->Length());
|
||||||
|
|
||||||
if (!buf->ReadUInt16(&type_)) {
|
if (!buf->ReadUInt16(&type_)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -1213,7 +1213,7 @@ void PseudoTcp::parseOptions(const char* data, uint32_t len) {
|
|||||||
|
|
||||||
// Content of this option.
|
// Content of this option.
|
||||||
if (opt_len <= buf.Length()) {
|
if (opt_len <= buf.Length()) {
|
||||||
applyOption(kind, reinterpret_cast<const char*>(buf.Data()), opt_len);
|
applyOption(kind, buf.Data(), opt_len);
|
||||||
buf.Consume(opt_len);
|
buf.Consume(opt_len);
|
||||||
} else {
|
} else {
|
||||||
RTC_LOG(LS_ERROR) << "Invalid option length received.";
|
RTC_LOG(LS_ERROR) << "Invalid option length received.";
|
||||||
|
|||||||
@ -139,6 +139,10 @@ bool ByteBufferReader::ReadBytes(rtc::ArrayView<uint8_t> val) {
|
|||||||
return ReadBytes(val.data(), val.size());
|
return ReadBytes(val.data(), val.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ByteBufferReader::ReadBytes(char* val, size_t len) {
|
||||||
|
return ReadBytes(reinterpret_cast<uint8_t*>(val), len);
|
||||||
|
}
|
||||||
|
|
||||||
// Private function supporting the other Read* functions.
|
// Private function supporting the other Read* functions.
|
||||||
bool ByteBufferReader::ReadBytes(uint8_t* val, size_t len) {
|
bool ByteBufferReader::ReadBytes(uint8_t* val, size_t len) {
|
||||||
if (len > Length()) {
|
if (len > Length()) {
|
||||||
|
|||||||
@ -100,6 +100,12 @@ class ByteBufferWriterT {
|
|||||||
void WriteBytes(const uint8_t* val, size_t len) {
|
void WriteBytes(const uint8_t* val, size_t len) {
|
||||||
WriteBytesInternal(reinterpret_cast<const value_type*>(val), len);
|
WriteBytesInternal(reinterpret_cast<const value_type*>(val), len);
|
||||||
}
|
}
|
||||||
|
// For backwards compatibility: Write an array of char
|
||||||
|
// TODO(bugs.webrtc.org/15665): Remove when users converted
|
||||||
|
[[deprecated("Use WriteString")]] void WriteBytes(const char* val,
|
||||||
|
size_t len) {
|
||||||
|
WriteBytesInternal(reinterpret_cast<const value_type*>(val), len);
|
||||||
|
}
|
||||||
|
|
||||||
// Reserves the given number of bytes and returns a value_type* that can be
|
// Reserves the given number of bytes and returns a value_type* that can be
|
||||||
// written into. Useful for functions that require a value_type* buffer and
|
// written into. Useful for functions that require a value_type* buffer and
|
||||||
@ -157,10 +163,14 @@ class ByteBufferReader {
|
|||||||
ByteBufferReader(const ByteBufferReader&) = delete;
|
ByteBufferReader(const ByteBufferReader&) = delete;
|
||||||
ByteBufferReader& operator=(const ByteBufferReader&) = delete;
|
ByteBufferReader& operator=(const ByteBufferReader&) = delete;
|
||||||
|
|
||||||
const uint8_t* Data() const { return bytes_ + start_; }
|
// Returns start of unprocessed data.
|
||||||
|
// TODO(bugs.webrtc.org/15661): Deprecate and remove.
|
||||||
|
const char* Data() const {
|
||||||
|
return reinterpret_cast<const char*>(bytes_ + start_);
|
||||||
|
}
|
||||||
// Returns number of unprocessed bytes.
|
// Returns number of unprocessed bytes.
|
||||||
size_t Length() const { return end_ - start_; }
|
size_t Length() const { return end_ - start_; }
|
||||||
// Returns a view of the unprocessed data. Does not move current position.
|
// Returns a view of the unprocessed data.
|
||||||
rtc::ArrayView<const uint8_t> DataView() const {
|
rtc::ArrayView<const uint8_t> DataView() const {
|
||||||
return rtc::ArrayView<const uint8_t>(bytes_ + start_, end_ - start_);
|
return rtc::ArrayView<const uint8_t>(bytes_ + start_, end_ - start_);
|
||||||
}
|
}
|
||||||
@ -173,8 +183,11 @@ class ByteBufferReader {
|
|||||||
bool ReadUInt32(uint32_t* val);
|
bool ReadUInt32(uint32_t* val);
|
||||||
bool ReadUInt64(uint64_t* val);
|
bool ReadUInt64(uint64_t* val);
|
||||||
bool ReadUVarint(uint64_t* val);
|
bool ReadUVarint(uint64_t* val);
|
||||||
// Copies the val.size() next bytes into val.data().
|
|
||||||
bool ReadBytes(rtc::ArrayView<uint8_t> val);
|
bool ReadBytes(rtc::ArrayView<uint8_t> val);
|
||||||
|
// For backwards compatibility.
|
||||||
|
// TODO(bugs.webrtc.org/15661): Deprecate and remove.
|
||||||
|
[[deprecated("Read using ArrayView")]] bool ReadBytes(char* val, size_t len);
|
||||||
|
|
||||||
// Appends next `len` bytes from the buffer to `val`. Returns false
|
// Appends next `len` bytes from the buffer to `val`. Returns false
|
||||||
// if there is less than `len` bytes left.
|
// if there is less than `len` bytes left.
|
||||||
bool ReadString(std::string* val, size_t len);
|
bool ReadString(std::string* val, size_t len);
|
||||||
|
|||||||
@ -75,9 +75,7 @@ void AsyncSocksProxyServerSocket::ProcessInput(char* data, size_t* len) {
|
|||||||
|
|
||||||
// Consume parsed data
|
// Consume parsed data
|
||||||
*len = response.Length();
|
*len = response.Length();
|
||||||
if (response.Length() > 0) {
|
memmove(data, response.Data(), *len);
|
||||||
memmove(data, response.DataView().data(), *len);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncSocksProxyServerSocket::DirectSend(const ByteBufferWriter& buf) {
|
void AsyncSocksProxyServerSocket::DirectSend(const ByteBufferWriter& buf) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user