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

Unified Diff: mojo/system/embedder.h

Issue 140403002: Mojo: Add the ability to hook up a channel to the embedder API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win Created 6 years, 11 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/system/core_test_base.cc ('k') | mojo/system/embedder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/embedder.h
diff --git a/mojo/system/embedder.h b/mojo/system/embedder.h
index 2b67e81db1cccc13fecc3777032b8c37966c66da..2431ba2b0279735d6c126d914be777dc5fe9b0b7 100644
--- a/mojo/system/embedder.h
+++ b/mojo/system/embedder.h
@@ -5,13 +5,51 @@
#ifndef MOJO_SYSTEM_EMBEDDER_H_
#define MOJO_SYSTEM_EMBEDDER_H_
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/task_runner.h"
+#include "mojo/public/system/core.h"
+#include "mojo/system/scoped_platform_handle.h"
#include "mojo/system/system_impl_export.h"
namespace mojo {
namespace embedder {
+// Must be called first to initialize the (global, singleton) system.
MOJO_SYSTEM_IMPL_EXPORT void Init();
+// Creates a new "channel", returning a handle to the bootstrap message pipe on
+// that channel. |platform_handle| should be an OS-dependent handle to one side
+// of a suitable bidirectional OS "pipe" (e.g., a file descriptor to a socket on
+// POSIX, a handle to a named pipe on Windows); this "pipe" should be connected
+// and ready for operation (e.g., to be written to or read from).
+// |io_thread_task_runner| should be a |TaskRunner| for the thread on which the
+// "channel" will run (read data and demultiplex).
+//
+// Returns |MOJO_HANDLE_INVALID| on error. Note that this will happen only if,
+// e.g., the handle table is full (operation of the channel begins
+// asynchronously and if, e.g., the other end of the "pipe" is closed, this will
+// report an error to the returned handle in the usual way).
+//
+// Notes: The handle returned is ready for use immediately, with messages
+// written to it queued. E.g., it would be perfectly valid for a message to be
+// immediately written to the returned handle and the handle closed, all before
+// the channel has begun operation on the IO thread. In this case, the channel
+// is expected to connect as usual, send the queued message, and report that the
+// handle was closed to the other side. (This message may well contain another
+// handle, so there may well still be message pipes "on" this channel.)
+//
+// TODO(vtl): Figure out channel teardown.
+struct ChannelInfo;
+typedef base::Callback<void(ChannelInfo*)> DidCreateChannelOnIOThreadCallback;
+MOJO_SYSTEM_IMPL_EXPORT MojoHandle CreateChannel(
+ system::ScopedPlatformHandle platform_handle,
+ scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ DidCreateChannelOnIOThreadCallback callback);
+
+MOJO_SYSTEM_IMPL_EXPORT void DestroyChannelOnIOThread(
+ ChannelInfo* channel_info);
+
} // namespace embedder
} // namespace mojo
« no previous file with comments | « mojo/system/core_test_base.cc ('k') | mojo/system/embedder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698