Commit 7ff8fdf1 authored by Wez's avatar Wez Committed by Commit Bot

Add some out-parameter initialization and DCHECKs in Mojo call-sites.

Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: Ib3e4cfd6eac23f6950831751d5f079f48738c4c7
Reviewed-on: https://chromium-review.googlesource.com/1176553Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584792}
parent 22981ad9
......@@ -125,7 +125,7 @@ class ScopedHandleBase {
bool is_valid() const { return handle_.is_valid(); }
explicit operator bool() const { return handle_; }
explicit operator bool() const { return handle_.is_valid(); }
bool operator==(const ScopedHandleBase& other) const {
return handle_.value() == other.get().value();
......
......@@ -26,7 +26,7 @@ MojoResult NetToMojoPendingBuffer::BeginWrite(
mojo::ScopedDataPipeProducerHandle* handle,
scoped_refptr<NetToMojoPendingBuffer>* pending,
uint32_t* num_bytes) {
void* buf;
void* buf = nullptr;
*num_bytes = 0;
MojoResult result =
(*handle)->BeginWriteData(&buf, num_bytes, MOJO_WRITE_DATA_FLAG_NONE);
......@@ -41,7 +41,7 @@ MojoResult NetToMojoPendingBuffer::BeginWrite(
mojo::ScopedDataPipeProducerHandle NetToMojoPendingBuffer::Complete(
uint32_t num_bytes) {
handle_->EndWriteData(num_bytes);
buffer_ = NULL;
buffer_ = nullptr;
return std::move(handle_);
}
......@@ -64,7 +64,7 @@ MojoResult MojoToNetPendingBuffer::BeginRead(
mojo::ScopedDataPipeConsumerHandle* handle,
scoped_refptr<MojoToNetPendingBuffer>* pending,
uint32_t* num_bytes) {
const void* buffer = NULL;
const void* buffer = nullptr;
*num_bytes = 0;
MojoResult result =
(*handle)->BeginReadData(&buffer, num_bytes, MOJO_READ_DATA_FLAG_NONE);
......@@ -75,7 +75,7 @@ MojoResult MojoToNetPendingBuffer::BeginRead(
void MojoToNetPendingBuffer::CompleteRead(uint32_t num_bytes) {
handle_->EndReadData(num_bytes);
buffer_ = NULL;
buffer_ = nullptr;
}
mojo::ScopedDataPipeConsumerHandle MojoToNetPendingBuffer::ReleaseHandle() {
......
......@@ -145,6 +145,7 @@ void MojoBlobReader::DidReadSideData(BlobReader::Status status) {
void MojoBlobReader::StartReading() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!response_body_stream_);
response_body_stream_ = delegate_->PassDataPipe();
peer_closed_handle_watcher_.Watch(
......@@ -165,8 +166,9 @@ void MojoBlobReader::StartReading() {
void MojoBlobReader::ReadMore() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!pending_write_.get());
DCHECK(response_body_stream_);
uint32_t num_bytes;
uint32_t num_bytes = 0;
// TODO: we should use the abstractions in MojoAsyncResourceHandler.
MojoResult result = network::NetToMojoPendingBuffer::BeginWrite(
&response_body_stream_, &pending_write_, &num_bytes);
......@@ -184,9 +186,10 @@ void MojoBlobReader::ReadMore() {
TRACE_EVENT_ASYNC_BEGIN0("Blob", "BlobReader::ReadMore", this);
CHECK_GT(static_cast<uint32_t>(std::numeric_limits<int>::max()), num_bytes);
DCHECK(pending_write_);
auto buf =
base::MakeRefCounted<network::NetToMojoIOBuffer>(pending_write_.get());
int bytes_read;
int bytes_read = 0;
BlobReader::Status read_status = blob_reader_->Read(
buf.get(), static_cast<int>(num_bytes), &bytes_read,
base::BindOnce(&MojoBlobReader::DidRead, base::Unretained(this), false));
......
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