Commit 59dcdfa5 authored by CJ DiMeglio's avatar CJ DiMeglio Committed by Commit Bot

Updates SmallMessageSocket to use size_t.

Bug: 982014
Merge-With: eureka-internal/360834
Change-Id: I47b9995892f7141c6f76222a7fe1a437d541792a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040210Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarKenneth MacKay <kmackay@chromium.org>
Commit-Queue: CJ DiMeglio <lethalantidote@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739212}
parent b4f60257
...@@ -50,7 +50,7 @@ class CaptureServiceReceiver::Socket : public SmallMessageSocket::Delegate { ...@@ -50,7 +50,7 @@ class CaptureServiceReceiver::Socket : public SmallMessageSocket::Delegate {
void OnSendUnblocked() override; void OnSendUnblocked() override;
void OnError(int error) override; void OnError(int error) override;
void OnEndOfStream() override; void OnEndOfStream() override;
bool OnMessage(char* data, int size) override; bool OnMessage(char* data, size_t size) override;
bool SendRequest(); bool SendRequest();
void OnInactivityTimeout(); void OnInactivityTimeout();
...@@ -136,10 +136,7 @@ void CaptureServiceReceiver::Socket::OnEndOfStream() { ...@@ -136,10 +136,7 @@ void CaptureServiceReceiver::Socket::OnEndOfStream() {
ReportErrorAndStop(); ReportErrorAndStop();
} }
bool CaptureServiceReceiver::Socket::OnMessage(char* data, int size) { bool CaptureServiceReceiver::Socket::OnMessage(char* data, size_t size) {
// TODO(https://crbug.com/982014): Remove the DCHECK once using unsigned
// |size|.
DCHECK_GT(size, 0);
capture_service::PacketInfo info; capture_service::PacketInfo info;
if (!capture_service::ReadHeader(data, size, &info)) { if (!capture_service::ReadHeader(data, size, &info)) {
ReportErrorAndStop(); ReportErrorAndStop();
......
...@@ -71,7 +71,7 @@ bool LoopbackConnection::HandleMetadata(const Generic& message) { ...@@ -71,7 +71,7 @@ bool LoopbackConnection::HandleMetadata(const Generic& message) {
} }
bool LoopbackConnection::HandleAudioData(char* data, bool LoopbackConnection::HandleAudioData(char* data,
int size, size_t size,
int64_t timestamp) { int64_t timestamp) {
if (format_ != kUnknownSampleFormat && size > 0) { if (format_ != kUnknownSampleFormat && size > 0) {
delegate_->OnLoopbackAudio(timestamp, format_, sample_rate_, num_channels_, delegate_->OnLoopbackAudio(timestamp, format_, sample_rate_, num_channels_,
......
...@@ -66,7 +66,7 @@ class LoopbackConnection : public MixerConnection, ...@@ -66,7 +66,7 @@ class LoopbackConnection : public MixerConnection,
// MixerSocket::Delegate implementation: // MixerSocket::Delegate implementation:
bool HandleMetadata(const Generic& message) override; bool HandleMetadata(const Generic& message) override;
bool HandleAudioData(char* data, int size, int64_t timestamp) override; bool HandleAudioData(char* data, size_t size, int64_t timestamp) override;
Delegate* const delegate_; Delegate* const delegate_;
......
...@@ -25,9 +25,9 @@ namespace mixer_service { ...@@ -25,9 +25,9 @@ namespace mixer_service {
namespace { namespace {
bool ReceiveProto(const char* data, int size, Generic* message) { bool ReceiveProto(const char* data, size_t size, Generic* message) {
int32_t padding_bytes; int32_t padding_bytes;
if (size < static_cast<int>(sizeof(padding_bytes))) { if (size < sizeof(padding_bytes)) {
LOG(ERROR) << "Invalid metadata message size " << size; LOG(ERROR) << "Invalid metadata message size " << size;
return false; return false;
} }
...@@ -41,7 +41,7 @@ bool ReceiveProto(const char* data, int size, Generic* message) { ...@@ -41,7 +41,7 @@ bool ReceiveProto(const char* data, int size, Generic* message) {
return false; return false;
} }
if (size < padding_bytes) { if (size < static_cast<size_t>(padding_bytes)) {
LOG(ERROR) << "Size " << size << " is smaller than padding " LOG(ERROR) << "Size " << size << " is smaller than padding "
<< padding_bytes; << padding_bytes;
return false; return false;
...@@ -61,7 +61,7 @@ bool MixerSocket::Delegate::HandleMetadata(const Generic& message) { ...@@ -61,7 +61,7 @@ bool MixerSocket::Delegate::HandleMetadata(const Generic& message) {
} }
bool MixerSocket::Delegate::HandleAudioData(char* data, bool MixerSocket::Delegate::HandleAudioData(char* data,
int size, size_t size,
int64_t timestamp) { int64_t timestamp) {
return true; return true;
} }
...@@ -69,7 +69,7 @@ bool MixerSocket::Delegate::HandleAudioData(char* data, ...@@ -69,7 +69,7 @@ bool MixerSocket::Delegate::HandleAudioData(char* data,
bool MixerSocket::Delegate::HandleAudioBuffer( bool MixerSocket::Delegate::HandleAudioBuffer(
scoped_refptr<net::IOBuffer> buffer, scoped_refptr<net::IOBuffer> buffer,
char* data, char* data,
int size, size_t size,
int64_t timestamp) { int64_t timestamp) {
return HandleAudioData(data, size, timestamp); return HandleAudioData(data, size, timestamp);
} }
...@@ -200,7 +200,7 @@ void MixerSocket::SendProto(const google::protobuf::MessageLite& message) { ...@@ -200,7 +200,7 @@ void MixerSocket::SendProto(const google::protobuf::MessageLite& message) {
} }
void MixerSocket::SendBuffer(scoped_refptr<net::IOBuffer> buffer, void MixerSocket::SendBuffer(scoped_refptr<net::IOBuffer> buffer,
int buffer_size) { size_t buffer_size) {
if (counterpart_task_runner_) { if (counterpart_task_runner_) {
counterpart_task_runner_->PostTask( counterpart_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
...@@ -244,9 +244,9 @@ void MixerSocket::OnEndOfStream() { ...@@ -244,9 +244,9 @@ void MixerSocket::OnEndOfStream() {
delegate_->OnConnectionError(); delegate_->OnConnectionError();
} }
bool MixerSocket::OnMessage(char* data, int size) { bool MixerSocket::OnMessage(char* data, size_t size) {
int16_t type; int16_t type;
if (size < static_cast<int>(sizeof(type))) { if (size < sizeof(type)) {
LOG(ERROR) << "Invalid message size " << size << " from " << this; LOG(ERROR) << "Invalid message size " << size << " from " << this;
delegate_->OnConnectionError(); delegate_->OnConnectionError();
return false; return false;
...@@ -267,8 +267,8 @@ bool MixerSocket::OnMessage(char* data, int size) { ...@@ -267,8 +267,8 @@ bool MixerSocket::OnMessage(char* data, int size) {
} }
bool MixerSocket::OnMessageBuffer(scoped_refptr<net::IOBuffer> buffer, bool MixerSocket::OnMessageBuffer(scoped_refptr<net::IOBuffer> buffer,
int size) { size_t size) {
if (size < static_cast<int>(sizeof(uint16_t) + sizeof(int16_t))) { if (size < sizeof(uint16_t) + sizeof(int16_t)) {
LOG(ERROR) << "Invalid buffer size " << size << " from " << this; LOG(ERROR) << "Invalid buffer size " << size << " from " << this;
delegate_->OnConnectionError(); delegate_->OnConnectionError();
return false; return false;
...@@ -291,7 +291,7 @@ bool MixerSocket::OnMessageBuffer(scoped_refptr<net::IOBuffer> buffer, ...@@ -291,7 +291,7 @@ bool MixerSocket::OnMessageBuffer(scoped_refptr<net::IOBuffer> buffer,
} }
} }
bool MixerSocket::ParseMetadata(char* data, int size) { bool MixerSocket::ParseMetadata(char* data, size_t size) {
Generic message; Generic message;
if (!ReceiveProto(data, size, &message)) { if (!ReceiveProto(data, size, &message)) {
LOG(INFO) << "Invalid metadata message from " << this; LOG(INFO) << "Invalid metadata message from " << this;
...@@ -302,9 +302,9 @@ bool MixerSocket::ParseMetadata(char* data, int size) { ...@@ -302,9 +302,9 @@ bool MixerSocket::ParseMetadata(char* data, int size) {
return delegate_->HandleMetadata(message); return delegate_->HandleMetadata(message);
} }
bool MixerSocket::ParseAudio(char* data, int size) { bool MixerSocket::ParseAudio(char* data, size_t size) {
int64_t timestamp; int64_t timestamp;
if (size < static_cast<int>(sizeof(timestamp))) { if (size < sizeof(timestamp)) {
LOG(ERROR) << "Invalid audio packet size " << size << " from " << this; LOG(ERROR) << "Invalid audio packet size " << size << " from " << this;
delegate_->OnConnectionError(); delegate_->OnConnectionError();
return false; return false;
...@@ -323,9 +323,9 @@ bool MixerSocket::ParseAudio(char* data, int size) { ...@@ -323,9 +323,9 @@ bool MixerSocket::ParseAudio(char* data, int size) {
bool MixerSocket::ParseAudioBuffer(scoped_refptr<net::IOBuffer> buffer, bool MixerSocket::ParseAudioBuffer(scoped_refptr<net::IOBuffer> buffer,
char* data, char* data,
int size) { size_t size) {
int64_t timestamp; int64_t timestamp;
if (size < static_cast<int>(sizeof(timestamp))) { if (size < sizeof(timestamp)) {
LOG(ERROR) << "Invalid audio buffer size " << size << " from " << this; LOG(ERROR) << "Invalid audio buffer size " << size << " from " << this;
delegate_->OnConnectionError(); delegate_->OnConnectionError();
return false; return false;
......
...@@ -48,7 +48,7 @@ class MixerSocket : public SmallMessageSocket::Delegate { ...@@ -48,7 +48,7 @@ class MixerSocket : public SmallMessageSocket::Delegate {
// Called when audio data is received from the other side of the connection. // Called when audio data is received from the other side of the connection.
// Return |true| if the socket should continue to receive messages. // Return |true| if the socket should continue to receive messages.
virtual bool HandleAudioData(char* data, int size, int64_t timestamp); virtual bool HandleAudioData(char* data, size_t size, int64_t timestamp);
// Called when audio data is received from the other side of the connection // Called when audio data is received from the other side of the connection
// using an IOBufferPool. The |buffer| reference may be held as long as // using an IOBufferPool. The |buffer| reference may be held as long as
...@@ -59,7 +59,7 @@ class MixerSocket : public SmallMessageSocket::Delegate { ...@@ -59,7 +59,7 @@ class MixerSocket : public SmallMessageSocket::Delegate {
// Return |true| if the socket should continue to receive messages. // Return |true| if the socket should continue to receive messages.
virtual bool HandleAudioBuffer(scoped_refptr<net::IOBuffer> buffer, virtual bool HandleAudioBuffer(scoped_refptr<net::IOBuffer> buffer,
char* data, char* data,
int size, size_t size,
int64_t timestamp); int64_t timestamp);
// Called when the connection is lost; no further data will be sent or // Called when the connection is lost; no further data will be sent or
...@@ -122,20 +122,21 @@ class MixerSocket : public SmallMessageSocket::Delegate { ...@@ -122,20 +122,21 @@ class MixerSocket : public SmallMessageSocket::Delegate {
void ReceiveMoreMessages(); void ReceiveMoreMessages();
private: private:
void SendBuffer(scoped_refptr<net::IOBuffer> buffer, int buffer_size); void SendBuffer(scoped_refptr<net::IOBuffer> buffer, size_t buffer_size);
// SmallMessageSocket::Delegate implementation: // SmallMessageSocket::Delegate implementation:
void OnSendUnblocked() override; void OnSendUnblocked() override;
void OnError(int error) override; void OnError(int error) override;
void OnEndOfStream() override; void OnEndOfStream() override;
bool OnMessage(char* data, int size) override; bool OnMessage(char* data, size_t size) override;
bool OnMessageBuffer(scoped_refptr<net::IOBuffer> buffer, int size) override; bool OnMessageBuffer(scoped_refptr<net::IOBuffer> buffer,
size_t size) override;
bool ParseMetadata(char* data, int size); bool ParseMetadata(char* data, size_t size);
bool ParseAudio(char* data, int size); bool ParseAudio(char* data, size_t size);
bool ParseAudioBuffer(scoped_refptr<net::IOBuffer> buffer, bool ParseAudioBuffer(scoped_refptr<net::IOBuffer> buffer,
char* data, char* data,
int size); size_t size);
Delegate* delegate_ = nullptr; Delegate* delegate_ = nullptr;
const std::unique_ptr<SmallMessageSocket> socket_; const std::unique_ptr<SmallMessageSocket> socket_;
......
...@@ -89,7 +89,7 @@ class ReceiverCma::Stream : public MixerSocket::Delegate, ...@@ -89,7 +89,7 @@ class ReceiverCma::Stream : public MixerSocket::Delegate,
return true; return true;
} }
bool HandleAudioData(char* data, int size, int64_t timestamp) override { bool HandleAudioData(char* data, size_t size, int64_t timestamp) override {
last_receive_time_ = base::TimeTicks::Now(); last_receive_time_ = base::TimeTicks::Now();
inactivity_timer_.Reset(); inactivity_timer_.Reset();
......
...@@ -94,7 +94,7 @@ bool RedirectedAudioConnection::HandleMetadata(const Generic& message) { ...@@ -94,7 +94,7 @@ bool RedirectedAudioConnection::HandleMetadata(const Generic& message) {
} }
bool RedirectedAudioConnection::HandleAudioData(char* data, bool RedirectedAudioConnection::HandleAudioData(char* data,
int size, size_t size,
int64_t timestamp) { int64_t timestamp) {
if (sample_rate_ != 0) { if (sample_rate_ != 0) {
int frames = size / (sizeof(float) * config_.num_output_channels); int frames = size / (sizeof(float) * config_.num_output_channels);
......
...@@ -93,7 +93,7 @@ class RedirectedAudioConnection : public MixerConnection, ...@@ -93,7 +93,7 @@ class RedirectedAudioConnection : public MixerConnection,
// MixerSocket::Delegate implementation: // MixerSocket::Delegate implementation:
bool HandleMetadata(const Generic& message) override; bool HandleMetadata(const Generic& message) override;
bool HandleAudioData(char* data, int size, int64_t timestamp) override; bool HandleAudioData(char* data, size_t size, int64_t timestamp) override;
const Config config_; const Config config_;
Delegate* const delegate_; Delegate* const delegate_;
......
...@@ -115,7 +115,7 @@ class AudioOutputRedirector::RedirectionConnection ...@@ -115,7 +115,7 @@ class AudioOutputRedirector::RedirectionConnection
} }
private: private:
bool HandleAudioData(char* data, int size, int64_t timestamp) override { bool HandleAudioData(char* data, size_t size, int64_t timestamp) override {
return true; return true;
} }
......
...@@ -279,7 +279,7 @@ bool MixerInputConnection::HandleMetadata( ...@@ -279,7 +279,7 @@ bool MixerInputConnection::HandleMetadata(
} }
bool MixerInputConnection::HandleAudioData(char* data, bool MixerInputConnection::HandleAudioData(char* data,
int size, size_t size,
int64_t timestamp) { int64_t timestamp) {
DCHECK(io_task_runner_->RunsTasksInCurrentSequence()); DCHECK(io_task_runner_->RunsTasksInCurrentSequence());
if (inactivity_timer_.IsRunning()) { if (inactivity_timer_.IsRunning()) {
...@@ -343,7 +343,7 @@ bool MixerInputConnection::HandleAudioData(char* data, ...@@ -343,7 +343,7 @@ bool MixerInputConnection::HandleAudioData(char* data,
bool MixerInputConnection::HandleAudioBuffer( bool MixerInputConnection::HandleAudioBuffer(
scoped_refptr<net::IOBuffer> buffer, scoped_refptr<net::IOBuffer> buffer,
char* data, char* data,
int size, size_t size,
int64_t timestamp) { int64_t timestamp) {
DCHECK(io_task_runner_->RunsTasksInCurrentSequence()); DCHECK(io_task_runner_->RunsTasksInCurrentSequence());
if (inactivity_timer_.IsRunning()) { if (inactivity_timer_.IsRunning()) {
......
...@@ -82,10 +82,10 @@ class MixerInputConnection : public mixer_service::MixerSocket::Delegate, ...@@ -82,10 +82,10 @@ class MixerInputConnection : public mixer_service::MixerSocket::Delegate,
// mixer_service::MixerSocket::Delegate implementation: // mixer_service::MixerSocket::Delegate implementation:
bool HandleMetadata(const mixer_service::Generic& message) override; bool HandleMetadata(const mixer_service::Generic& message) override;
bool HandleAudioData(char* data, int size, int64_t timestamp) override; bool HandleAudioData(char* data, size_t size, int64_t timestamp) override;
bool HandleAudioBuffer(scoped_refptr<net::IOBuffer> buffer, bool HandleAudioBuffer(scoped_refptr<net::IOBuffer> buffer,
char* data, char* data,
int size, size_t size,
int64_t timestamp) override; int64_t timestamp) override;
void OnConnectionError() override; void OnConnectionError() override;
......
...@@ -67,7 +67,7 @@ bool MixerLoopbackConnection::HandleMetadata( ...@@ -67,7 +67,7 @@ bool MixerLoopbackConnection::HandleMetadata(
} }
bool MixerLoopbackConnection::HandleAudioData(char* data, bool MixerLoopbackConnection::HandleAudioData(char* data,
int size, size_t size,
int64_t timestamp) { int64_t timestamp) {
return true; return true;
} }
......
...@@ -48,7 +48,7 @@ class MixerLoopbackConnection : public mixer_service::MixerSocket::Delegate { ...@@ -48,7 +48,7 @@ class MixerLoopbackConnection : public mixer_service::MixerSocket::Delegate {
private: private:
// mixer_service::MixerSocket::Delegate implementation: // mixer_service::MixerSocket::Delegate implementation:
bool HandleMetadata(const mixer_service::Generic& message) override; bool HandleMetadata(const mixer_service::Generic& message) override;
bool HandleAudioData(char* data, int size, int64_t timestamp) override; bool HandleAudioData(char* data, size_t size, int64_t timestamp) override;
void OnConnectionError() override; void OnConnectionError() override;
const std::unique_ptr<mixer_service::MixerSocket> socket_; const std::unique_ptr<mixer_service::MixerSocket> socket_;
......
...@@ -88,13 +88,13 @@ class MixerServiceReceiver::ControlConnection ...@@ -88,13 +88,13 @@ class MixerServiceReceiver::ControlConnection
return true; return true;
} }
bool HandleAudioData(char* data, int size, int64_t timestamp) override { bool HandleAudioData(char* data, size_t size, int64_t timestamp) override {
return true; return true;
} }
bool HandleAudioBuffer(scoped_refptr<net::IOBuffer> buffer, bool HandleAudioBuffer(scoped_refptr<net::IOBuffer> buffer,
char* data, char* data,
int size, size_t size,
int64_t timestamp) override { int64_t timestamp) override {
return true; return true;
} }
......
...@@ -145,7 +145,7 @@ void SmallMessageSocket::RemoveBufferPool() { ...@@ -145,7 +145,7 @@ void SmallMessageSocket::RemoveBufferPool() {
buffer_pool_.reset(); buffer_pool_.reset();
} }
void* SmallMessageSocket::PrepareSend(int message_size) { void* SmallMessageSocket::PrepareSend(size_t message_size) {
DCHECK_LE(message_size, std::numeric_limits<uint16_t>::max()); DCHECK_LE(message_size, std::numeric_limits<uint16_t>::max());
if (write_buffer_->remaining()) { if (write_buffer_->remaining()) {
send_blocked_ = true; send_blocked_ = true;
...@@ -153,8 +153,9 @@ void* SmallMessageSocket::PrepareSend(int message_size) { ...@@ -153,8 +153,9 @@ void* SmallMessageSocket::PrepareSend(int message_size) {
} }
write_storage_->set_offset(0); write_storage_->set_offset(0);
const int total_size = sizeof(uint16_t) + message_size; const size_t total_size = sizeof(uint16_t) + message_size;
if (write_storage_->capacity() < total_size) { // TODO(lethalantidote): Remove cast once capacity converted to size_t.
if (static_cast<size_t>(write_storage_->capacity()) < total_size) {
write_storage_->SetCapacity(total_size); write_storage_->SetCapacity(total_size);
} }
...@@ -165,7 +166,7 @@ void* SmallMessageSocket::PrepareSend(int message_size) { ...@@ -165,7 +166,7 @@ void* SmallMessageSocket::PrepareSend(int message_size) {
} }
bool SmallMessageSocket::SendBuffer(scoped_refptr<net::IOBuffer> data, bool SmallMessageSocket::SendBuffer(scoped_refptr<net::IOBuffer> data,
int size) { size_t size) {
if (write_buffer_->remaining()) { if (write_buffer_->remaining()) {
send_blocked_ = true; send_blocked_ = true;
return false; return false;
...@@ -411,7 +412,7 @@ bool SmallMessageSocket::HandleCompletedMessageBuffers() { ...@@ -411,7 +412,7 @@ bool SmallMessageSocket::HandleCompletedMessageBuffers() {
bool SmallMessageSocket::Delegate::OnMessageBuffer( bool SmallMessageSocket::Delegate::OnMessageBuffer(
scoped_refptr<net::IOBuffer> buffer, scoped_refptr<net::IOBuffer> buffer,
int size) { size_t size) {
return OnMessage(buffer->data() + sizeof(uint16_t), size - sizeof(uint16_t)); return OnMessage(buffer->data() + sizeof(uint16_t), size - sizeof(uint16_t));
} }
......
...@@ -46,13 +46,14 @@ class SmallMessageSocket { ...@@ -46,13 +46,14 @@ class SmallMessageSocket {
// Called when a message has been received and there is no buffer pool. The // Called when a message has been received and there is no buffer pool. The
// |data| buffer contains |size| bytes of data. Return |true| to continue // |data| buffer contains |size| bytes of data. Return |true| to continue
// reading messages after OnMessage() returns. // reading messages after OnMessage() returns.
virtual bool OnMessage(char* data, int size) = 0; virtual bool OnMessage(char* data, size_t size) = 0;
// Called when a message has been received. The |buffer| contains |size| // Called when a message has been received. The |buffer| contains |size|
// bytes of data, which includes the first 2 bytes which are the size in // bytes of data, which includes the first 2 bytes which are the size in
// network byte order. Note that these 2 bytes are not included in // network byte order. Note that these 2 bytes are not included in
// OnMessage()! Return |true| to continue receiving messages. // OnMessage()! Return |true| to continue receiving messages.
virtual bool OnMessageBuffer(scoped_refptr<net::IOBuffer> buffer, int size); virtual bool OnMessageBuffer(scoped_refptr<net::IOBuffer> buffer,
size_t size);
protected: protected:
virtual ~Delegate() = default; virtual ~Delegate() = default;
...@@ -82,7 +83,7 @@ class SmallMessageSocket { ...@@ -82,7 +83,7 @@ class SmallMessageSocket {
// then call Send() to send the finished message. // then call Send() to send the finished message.
// If nullptr is returned, then OnSendUnblocked() will be called once sending // If nullptr is returned, then OnSendUnblocked() will be called once sending
// is possible again. // is possible again.
void* PrepareSend(int message_size); void* PrepareSend(size_t message_size);
void Send(); void Send();
// Sends an already-prepared buffer of data, if possible. The first 2 bytes of // Sends an already-prepared buffer of data, if possible. The first 2 bytes of
...@@ -91,7 +92,7 @@ class SmallMessageSocket { ...@@ -91,7 +92,7 @@ class SmallMessageSocket {
// sent; returns false if sending is not allowed right now (ie, another send // sent; returns false if sending is not allowed right now (ie, another send
// is currently in progress). If false is returned, then OnSendUnblocked() // is currently in progress). If false is returned, then OnSendUnblocked()
// will be called once sending is possible again. // will be called once sending is possible again.
bool SendBuffer(scoped_refptr<net::IOBuffer> data, int size); bool SendBuffer(scoped_refptr<net::IOBuffer> data, size_t size);
// Enables receiving messages from the stream. Messages will be received and // Enables receiving messages from the stream. Messages will be received and
// passed to OnMessage() until either an error occurs, the end of stream is // passed to OnMessage() until either an error occurs, the end of stream is
......
...@@ -81,7 +81,7 @@ class TestSocket : public SmallMessageSocket::Delegate { ...@@ -81,7 +81,7 @@ class TestSocket : public SmallMessageSocket::Delegate {
private: private:
void OnError(int error) override { NOTREACHED(); } void OnError(int error) override { NOTREACHED(); }
bool OnMessage(char* data, int size) override { bool OnMessage(char* data, size_t size) override {
message_history_.push_back(size); message_history_.push_back(size);
CheckData(data, size); CheckData(data, size);
if (swap_pool_use_) { if (swap_pool_use_) {
...@@ -90,7 +90,8 @@ class TestSocket : public SmallMessageSocket::Delegate { ...@@ -90,7 +90,8 @@ class TestSocket : public SmallMessageSocket::Delegate {
return true; return true;
} }
bool OnMessageBuffer(scoped_refptr<net::IOBuffer> buffer, int size) override { bool OnMessageBuffer(scoped_refptr<net::IOBuffer> buffer,
size_t size) override {
uint16_t message_size; uint16_t message_size;
base::ReadBigEndian(buffer->data(), &message_size); base::ReadBigEndian(buffer->data(), &message_size);
DCHECK_EQ(message_size, size - sizeof(uint16_t)); DCHECK_EQ(message_size, size - sizeof(uint16_t));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment