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

Unified Diff: chrome/browser/media/cast_remoting_sender.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
« no previous file with comments | « chrome/browser/media/cast_remoting_sender.h ('k') | content/browser/loader/mojo_async_resource_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/cast_remoting_sender.cc
diff --git a/chrome/browser/media/cast_remoting_sender.cc b/chrome/browser/media/cast_remoting_sender.cc
index 00de02537bbeafe4c4f4ca00c7e7e0e197bb1207..7a55a911404a8c892689330be0856bd08d7a1cfa 100644
--- a/chrome/browser/media/cast_remoting_sender.cc
+++ b/chrome/browser/media/cast_remoting_sender.cc
@@ -92,7 +92,7 @@ CastRemotingSender::CastRemotingSender(
latest_acked_frame_id_(media::cast::FrameId::first() - 1),
duplicate_ack_counter_(0),
input_queue_discards_remaining_(0),
- pipe_watcher_(FROM_HERE),
+ pipe_watcher_(FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::MANUAL),
flow_restart_pending_(true),
weak_factory_(this) {
// Confirm this constructor is running on the IO BrowserThread.
@@ -164,10 +164,11 @@ void CastRemotingSender::FindAndBind(
sender->error_callback_ = error_callback;
sender->pipe_ = std::move(pipe);
- sender->pipe_watcher_.Start(
- sender->pipe_.get(), MOJO_HANDLE_SIGNAL_READABLE,
- base::Bind(&CastRemotingSender::ProcessInputQueue,
- base::Unretained(sender)));
+ sender->pipe_watcher_.Watch(sender->pipe_.get(),
+ MOJO_HANDLE_SIGNAL_NEW_DATA_READABLE,
+ base::Bind(&CastRemotingSender::ProcessInputQueue,
+ base::Unretained(sender)));
+ sender->pipe_watcher_.ArmOrNotify();
sender->binding_.Bind(std::move(request));
sender->binding_.set_connection_error_handler(sender->error_callback_);
}
@@ -378,8 +379,10 @@ bool CastRemotingSender::TryConsumeDataChunk(uint32_t offset, uint32_t size,
MOJO_READ_DATA_FLAG_DISCARD | MOJO_READ_DATA_FLAG_ALL_OR_NONE);
if (result == MOJO_RESULT_OK)
return true; // Successfully discarded data.
- if (result == MOJO_RESULT_OUT_OF_RANGE)
+ if (result == MOJO_RESULT_OUT_OF_RANGE) {
+ pipe_watcher_.ArmOrNotify();
return false; // Retry later.
+ }
LOG(ERROR) << SENDER_SSRC
<< "Unexpected result when discarding from data pipe ("
<< result << ')';
@@ -395,8 +398,10 @@ bool CastRemotingSender::TryConsumeDataChunk(uint32_t offset, uint32_t size,
MOJO_READ_DATA_FLAG_ALL_OR_NONE);
if (result == MOJO_RESULT_OK)
return true; // Successfully consumed data.
- if (result == MOJO_RESULT_OUT_OF_RANGE)
+ if (result == MOJO_RESULT_OUT_OF_RANGE) {
+ pipe_watcher_.ArmOrNotify();
return false; // Retry later.
+ }
LOG(ERROR)
<< SENDER_SSRC << "Read from data pipe failed (" << result << ')';
} while (false);
« no previous file with comments | « chrome/browser/media/cast_remoting_sender.h ('k') | content/browser/loader/mojo_async_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698