mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Revert^2 "Remove deprecated ByteBufferReader and ByteBufferWriter functions"
This reverts commitca58f0eb9d
. Reason for revert: Webkit Linux Leak bot seems flaky Original change's description: > Revert "Remove deprecated ByteBufferReader and ByteBufferWriter functions" > > This reverts commite0e03ba73a
. > > 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} Bug: webrtc:15661, chromium:1513059 Change-Id: I702c695ba0f83bba5721b18ebd994435a8932c0a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/331980 Commit-Queue: Harald Alvestrand <hta@webrtc.org> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41419}
This commit is contained in:
parent
06a8ecadf2
commit
5692649b9b
5 changed files with 8 additions and 23 deletions
|
@ -587,7 +587,7 @@ bool StunMessage::AddFingerprint() {
|
|||
|
||||
bool StunMessage::Read(ByteBufferReader* buf) {
|
||||
// Keep a copy of the buffer data around for later verification.
|
||||
buffer_.assign(buf->Data(), buf->Length());
|
||||
buffer_.assign(reinterpret_cast<const char*>(buf->Data()), buf->Length());
|
||||
|
||||
if (!buf->ReadUInt16(&type_)) {
|
||||
return false;
|
||||
|
|
|
@ -1213,7 +1213,7 @@ void PseudoTcp::parseOptions(const char* data, uint32_t len) {
|
|||
|
||||
// Content of this option.
|
||||
if (opt_len <= buf.Length()) {
|
||||
applyOption(kind, buf.Data(), opt_len);
|
||||
applyOption(kind, reinterpret_cast<const char*>(buf.Data()), opt_len);
|
||||
buf.Consume(opt_len);
|
||||
} else {
|
||||
RTC_LOG(LS_ERROR) << "Invalid option length received.";
|
||||
|
|
|
@ -139,10 +139,6 @@ bool ByteBufferReader::ReadBytes(rtc::ArrayView<uint8_t> val) {
|
|||
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.
|
||||
bool ByteBufferReader::ReadBytes(uint8_t* val, size_t len) {
|
||||
if (len > Length()) {
|
||||
|
|
|
@ -100,12 +100,6 @@ class ByteBufferWriterT {
|
|||
void WriteBytes(const uint8_t* val, size_t 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
|
||||
// written into. Useful for functions that require a value_type* buffer and
|
||||
|
@ -163,14 +157,10 @@ class ByteBufferReader {
|
|||
ByteBufferReader(const ByteBufferReader&) = delete;
|
||||
ByteBufferReader& operator=(const ByteBufferReader&) = delete;
|
||||
|
||||
// Returns start of unprocessed data.
|
||||
// TODO(bugs.webrtc.org/15661): Deprecate and remove.
|
||||
const char* Data() const {
|
||||
return reinterpret_cast<const char*>(bytes_ + start_);
|
||||
}
|
||||
const uint8_t* Data() const { return bytes_ + start_; }
|
||||
// Returns number of unprocessed bytes.
|
||||
size_t Length() const { return end_ - start_; }
|
||||
// Returns a view of the unprocessed data.
|
||||
// Returns a view of the unprocessed data. Does not move current position.
|
||||
rtc::ArrayView<const uint8_t> DataView() const {
|
||||
return rtc::ArrayView<const uint8_t>(bytes_ + start_, end_ - start_);
|
||||
}
|
||||
|
@ -183,11 +173,8 @@ class ByteBufferReader {
|
|||
bool ReadUInt32(uint32_t* val);
|
||||
bool ReadUInt64(uint64_t* val);
|
||||
bool ReadUVarint(uint64_t* val);
|
||||
// Copies the val.size() next bytes into val.data().
|
||||
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
|
||||
// if there is less than `len` bytes left.
|
||||
bool ReadString(std::string* val, size_t len);
|
||||
|
|
|
@ -75,7 +75,9 @@ void AsyncSocksProxyServerSocket::ProcessInput(char* data, size_t* len) {
|
|||
|
||||
// Consume parsed data
|
||||
*len = response.Length();
|
||||
memmove(data, response.Data(), *len);
|
||||
if (response.Length() > 0) {
|
||||
memmove(data, response.DataView().data(), *len);
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncSocksProxyServerSocket::DirectSend(const ByteBufferWriter& buf) {
|
||||
|
|
Loading…
Reference in a new issue