| Index: mojo/edk/system/core.cc
|
| diff --git a/mojo/edk/system/core.cc b/mojo/edk/system/core.cc
|
| index cfe01fabb156654f01d0bd5ee5b05be09f2e2db1..1e0bf4e1dfea36ee749036e3cf160316f9d6437e 100644
|
| --- a/mojo/edk/system/core.cc
|
| +++ b/mojo/edk/system/core.cc
|
| @@ -35,7 +35,6 @@
|
| #include "mojo/edk/system/shared_buffer_dispatcher.h"
|
| #include "mojo/edk/system/wait_set_dispatcher.h"
|
| #include "mojo/edk/system/waiter.h"
|
| -#include "mojo/edk/system/watcher_dispatcher.h"
|
|
|
| namespace mojo {
|
| namespace edk {
|
| @@ -48,6 +47,15 @@
|
| // TODO(rockot): Maybe we could negotiate a debugging pipe ID for cross-process
|
| // pipes too; for now we just use a constant. This only affects bootstrap pipes.
|
| const uint64_t kUnknownPipeIdForDebug = 0x7f7f7f7f7f7f7f7fUL;
|
| +
|
| +void CallWatchCallback(MojoWatchCallback callback,
|
| + uintptr_t context,
|
| + MojoResult result,
|
| + const HandleSignalsState& signals_state,
|
| + MojoWatchNotificationFlags flags) {
|
| + callback(context, result, static_cast<MojoHandleSignalsState>(signals_state),
|
| + flags);
|
| +}
|
|
|
| MojoResult MojoPlatformHandleToScopedPlatformHandle(
|
| const MojoPlatformHandle* platform_handle,
|
| @@ -420,50 +428,24 @@
|
| return rv;
|
| }
|
|
|
| -MojoResult Core::CreateWatcher(MojoWatcherCallback callback,
|
| - MojoHandle* watcher_handle) {
|
| - RequestContext request_context;
|
| - if (!watcher_handle)
|
| - return MOJO_RESULT_INVALID_ARGUMENT;
|
| - *watcher_handle = AddDispatcher(new WatcherDispatcher(callback));
|
| - if (*watcher_handle == MOJO_HANDLE_INVALID)
|
| - return MOJO_RESULT_RESOURCE_EXHAUSTED;
|
| - return MOJO_RESULT_OK;
|
| -}
|
| -
|
| -MojoResult Core::Watch(MojoHandle watcher_handle,
|
| - MojoHandle handle,
|
| +MojoResult Core::Watch(MojoHandle handle,
|
| MojoHandleSignals signals,
|
| + MojoWatchCallback callback,
|
| uintptr_t context) {
|
| RequestContext request_context;
|
| - scoped_refptr<Dispatcher> watcher = GetDispatcher(watcher_handle);
|
| - if (!watcher || watcher->GetType() != Dispatcher::Type::WATCHER)
|
| - return MOJO_RESULT_INVALID_ARGUMENT;
|
| scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle);
|
| if (!dispatcher)
|
| return MOJO_RESULT_INVALID_ARGUMENT;
|
| - return watcher->WatchDispatcher(dispatcher, signals, context);
|
| -}
|
| -
|
| -MojoResult Core::CancelWatch(MojoHandle watcher_handle, uintptr_t context) {
|
| - RequestContext request_context;
|
| - scoped_refptr<Dispatcher> watcher = GetDispatcher(watcher_handle);
|
| - if (!watcher || watcher->GetType() != Dispatcher::Type::WATCHER)
|
| - return MOJO_RESULT_INVALID_ARGUMENT;
|
| - return watcher->CancelWatch(context);
|
| -}
|
| -
|
| -MojoResult Core::ArmWatcher(MojoHandle watcher_handle,
|
| - uint32_t* num_ready_contexts,
|
| - uintptr_t* ready_contexts,
|
| - MojoResult* ready_results,
|
| - MojoHandleSignalsState* ready_signals_states) {
|
| - RequestContext request_context;
|
| - scoped_refptr<Dispatcher> watcher = GetDispatcher(watcher_handle);
|
| - if (!watcher || watcher->GetType() != Dispatcher::Type::WATCHER)
|
| - return MOJO_RESULT_INVALID_ARGUMENT;
|
| - return watcher->Arm(num_ready_contexts, ready_contexts, ready_results,
|
| - ready_signals_states);
|
| + return dispatcher->Watch(
|
| + signals, base::Bind(&CallWatchCallback, callback, context), context);
|
| +}
|
| +
|
| +MojoResult Core::CancelWatch(MojoHandle handle, uintptr_t context) {
|
| + RequestContext request_context;
|
| + scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle);
|
| + if (!dispatcher)
|
| + return MOJO_RESULT_INVALID_ARGUMENT;
|
| + return dispatcher->CancelWatch(context);
|
| }
|
|
|
| MojoResult Core::AllocMessage(uint32_t num_bytes,
|
|
|