Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Unified Diff: content/browser/loader/mojo_async_resource_handler.cc

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/loader/mojo_async_resource_handler.cc
diff --git a/content/browser/loader/mojo_async_resource_handler.cc b/content/browser/loader/mojo_async_resource_handler.cc
index 20a9bf17f260a334f119b565e070bcb4cef5eca7..1c4fc78a631a9dd02eba9ae36b86a1679e778aad 100644
--- a/content/browser/loader/mojo_async_resource_handler.cc
+++ b/content/browser/loader/mojo_async_resource_handler.cc
@@ -121,7 +121,7 @@ MojoAsyncResourceHandler::MojoAsyncResourceHandler(
: ResourceHandler(request),
rdh_(rdh),
binding_(this, std::move(mojo_request)),
- handle_watcher_(FROM_HERE),
+ handle_watcher_(FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::MANUAL),
url_loader_client_(std::move(url_loader_client)),
weak_factory_(this) {
DCHECK(url_loader_client_);
@@ -245,9 +245,10 @@ void MojoAsyncResourceHandler::OnWillRead(
response_body_consumer_handle_ = std::move(data_pipe.consumer_handle);
shared_writer_ = new SharedWriter(std::move(data_pipe.producer_handle));
- handle_watcher_.Start(shared_writer_->writer(), MOJO_HANDLE_SIGNAL_WRITABLE,
+ handle_watcher_.Watch(shared_writer_->writer(), MOJO_HANDLE_SIGNAL_WRITABLE,
base::Bind(&MojoAsyncResourceHandler::OnWritable,
base::Unretained(this)));
+ handle_watcher_.ArmOrNotify();
bool defer = false;
scoped_refptr<net::IOBufferWithSize> buffer;
@@ -388,11 +389,16 @@ MojoResult MojoAsyncResourceHandler::BeginWrite(void** data,
shared_writer_->writer(), data, available, MOJO_WRITE_DATA_FLAG_NONE);
if (result == MOJO_RESULT_OK)
*available = std::min(*available, static_cast<uint32_t>(kMaxChunkSize));
+ else if (result == MOJO_RESULT_SHOULD_WAIT)
+ handle_watcher_.ArmOrNotify();
return result;
}
MojoResult MojoAsyncResourceHandler::EndWrite(uint32_t written) {
- return mojo::EndWriteDataRaw(shared_writer_->writer(), written);
+ MojoResult result = mojo::EndWriteDataRaw(shared_writer_->writer(), written);
+ if (result == MOJO_RESULT_OK)
+ handle_watcher_.ArmOrNotify();
+ return result;
}
net::IOBufferWithSize* MojoAsyncResourceHandler::GetResponseMetadata(

Powered by Google App Engine
This is Rietveld 408576698