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

Unified Diff: mojo/edk/system/message_pipe_dispatcher.cc

Issue 1748503002: [mojo-edk] Add MojoWatch and MojoCancelWatch APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert RequestContext usage, nits Created 4 years, 10 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 | « mojo/edk/system/message_pipe_dispatcher.h ('k') | mojo/edk/system/request_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/message_pipe_dispatcher.cc
diff --git a/mojo/edk/system/message_pipe_dispatcher.cc b/mojo/edk/system/message_pipe_dispatcher.cc
index c7b4a32da6bad0e0cbea48ddc8b3e60683a01966..ce35f646d8d81e5dfbb84955c01259ba4486615f 100644
--- a/mojo/edk/system/message_pipe_dispatcher.cc
+++ b/mojo/edk/system/message_pipe_dispatcher.cc
@@ -13,6 +13,7 @@
#include "mojo/edk/system/core.h"
#include "mojo/edk/system/node_controller.h"
#include "mojo/edk/system/ports_message.h"
+#include "mojo/edk/system/request_context.h"
#include "mojo/public/c/system/macros.h"
namespace mojo {
@@ -97,6 +98,27 @@ MojoResult MessagePipeDispatcher::Close() {
return CloseNoLock();
}
+MojoResult MessagePipeDispatcher::Watch(MojoHandleSignals signals,
+ const Watcher::WatchCallback& callback,
+ uintptr_t context) {
+ base::AutoLock lock(signal_lock_);
+
+ if (port_closed_ || in_transit_)
+ return MOJO_RESULT_INVALID_ARGUMENT;
+
+ return awakables_.AddWatcher(
+ signals, callback, context, GetHandleSignalsStateNoLock());
+}
+
+MojoResult MessagePipeDispatcher::CancelWatch(uintptr_t context) {
+ base::AutoLock lock(signal_lock_);
+
+ if (port_closed_ || in_transit_)
+ return MOJO_RESULT_INVALID_ARGUMENT;
+
+ return awakables_.RemoveWatcher(context);
+}
+
MojoResult MessagePipeDispatcher::WriteMessage(
const void* bytes,
uint32_t num_bytes,
@@ -579,6 +601,8 @@ HandleSignalsState MessagePipeDispatcher::GetHandleSignalsStateNoLock() const {
}
void MessagePipeDispatcher::OnPortStatusChanged() {
+ RequestContext request_context;
+
base::AutoLock lock(signal_lock_);
// We stop observing our port as soon as it's transferred, but this can race
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.h ('k') | mojo/edk/system/request_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698