Index: content/child/url_response_body_consumer.cc |
diff --git a/content/child/url_response_body_consumer.cc b/content/child/url_response_body_consumer.cc |
index 1095ea15c3eee1a6e9bfc273a85289ac30b74618..a51b4f70a36bb43616203c12e30743193268423c 100644 |
--- a/content/child/url_response_body_consumer.cc |
+++ b/content/child/url_response_body_consumer.cc |
@@ -48,15 +48,15 @@ |
: request_id_(request_id), |
resource_dispatcher_(resource_dispatcher), |
handle_(std::move(handle)), |
- handle_watcher_(FROM_HERE, |
- mojo::SimpleWatcher::ArmingPolicy::MANUAL, |
- task_runner), |
+ handle_watcher_(FROM_HERE, task_runner), |
task_runner_(task_runner), |
has_seen_end_of_data_(!handle_.is_valid()) { |
- handle_watcher_.Watch( |
+ handle_watcher_.Start( |
handle_.get(), MOJO_HANDLE_SIGNAL_READABLE, |
base::Bind(&URLResponseBodyConsumer::OnReadable, base::Unretained(this))); |
- handle_watcher_.ArmOrNotify(); |
+ task_runner_->PostTask( |
+ FROM_HERE, base::Bind(&URLResponseBodyConsumer::OnReadable, AsWeakPtr(), |
+ MOJO_RESULT_OK)); |
} |
URLResponseBodyConsumer::~URLResponseBodyConsumer() {} |
@@ -91,7 +91,9 @@ |
if (is_in_on_readable_) |
return; |
- handle_watcher_.ArmOrNotify(); |
+ task_runner_->PostTask( |
+ FROM_HERE, base::Bind(&URLResponseBodyConsumer::OnReadable, AsWeakPtr(), |
+ MOJO_RESULT_OK)); |
} |
void URLResponseBodyConsumer::OnReadable(MojoResult unused) { |
@@ -110,11 +112,7 @@ |
uint32_t available = 0; |
MojoResult result = mojo::BeginReadDataRaw( |
handle_.get(), &buffer, &available, MOJO_READ_DATA_FLAG_NONE); |
- if (result == MOJO_RESULT_SHOULD_WAIT) { |
- handle_watcher_.ArmOrNotify(); |
- return; |
- } |
- if (result == MOJO_RESULT_BUSY) |
+ if (result == MOJO_RESULT_SHOULD_WAIT || result == MOJO_RESULT_BUSY) |
return; |
if (result == MOJO_RESULT_FAILED_PRECONDITION) { |
has_seen_end_of_data_ = true; |
@@ -136,7 +134,9 @@ |
// to the next task. |
result = mojo::EndReadDataRaw(handle_.get(), 0); |
DCHECK_EQ(result, MOJO_RESULT_OK); |
- handle_watcher_.ArmOrNotify(); |
+ task_runner_->PostTask(FROM_HERE, |
+ base::Bind(&URLResponseBodyConsumer::OnReadable, |
+ AsWeakPtr(), MOJO_RESULT_OK)); |
return; |
} |
num_bytes_consumed += available; |