| Index: mojo/edk/embedder/embedder.h
|
| diff --git a/mojo/edk/embedder/embedder.h b/mojo/edk/embedder/embedder.h
|
| index 85bc5832185eb94996fb7a1488c1e1311f6b6c89..02b4ac3f0c904f9fcc9dad00b24d1a495bb85e64 100644
|
| --- a/mojo/edk/embedder/embedder.h
|
| +++ b/mojo/edk/embedder/embedder.h
|
| @@ -12,23 +12,32 @@
|
| #include "mojo/edk/embedder/channel_info_forward.h"
|
| #include "mojo/edk/embedder/scoped_platform_handle.h"
|
| #include "mojo/edk/system/system_impl_export.h"
|
| -#include "mojo/public/cpp/system/core.h"
|
| +#include "mojo/public/cpp/system/message_pipe.h"
|
|
|
| namespace mojo {
|
| namespace embedder {
|
|
|
| +struct Configuration;
|
| class PlatformSupport;
|
|
|
| -// Must be called first to initialize the (global, singleton) system.
|
| +// Must be called first, or just after setting configuration parameters,
|
| +// to initialize the (global, singleton) system.
|
| MOJO_SYSTEM_IMPL_EXPORT void Init(scoped_ptr<PlatformSupport> platform_support);
|
|
|
| +// Returns the global configuration. In general there should be no need to
|
| +// change the configuration, but if you do so this must be done before calling
|
| +// |Init()|.
|
| +MOJO_SYSTEM_IMPL_EXPORT Configuration* GetConfiguration();
|
| +
|
| // A "channel" is a connection on top of an OS "pipe", on top of which Mojo
|
| // message pipes (etc.) can be multiplexed. It must "live" on some I/O thread.
|
| //
|
| -// There are two "channel" creation/destruction APIs: the synchronous
|
| -// |CreateChannelOnIOThread()|/|DestroyChannelOnIOThread()|, which must be
|
| -// called from the I/O thread, and the asynchronous
|
| -// |CreateChannel()|/|DestroyChannel()|, which may be called from any thread.
|
| +// There are two channel creation APIs: |CreateChannelOnIOThread()| creates a
|
| +// channel synchronously and must be called from the I/O thread, while
|
| +// |CreateChannel()| is asynchronous and may be called from any thread.
|
| +// |DestroyChannel()| is used to destroy the channel in either case and may be
|
| +// called from any thread, but completes synchronously when called from the I/O
|
| +// thread.
|
| //
|
| // Both creation functions have a |platform_handle| argument, which should be an
|
| // OS-dependent handle to one side of a suitable bidirectional OS "pipe" (e.g.,
|
| @@ -60,44 +69,37 @@ MOJO_SYSTEM_IMPL_EXPORT void Init(scoped_ptr<PlatformSupport> platform_support);
|
|
|
| // Creates a channel; must only be called from the I/O thread. |platform_handle|
|
| // should be a handle to a connected OS "pipe". Eventually (even on failure),
|
| -// the "out" value |*channel_info| should be passed to
|
| -// |DestroyChannelOnIOThread()| (or |DestoryChannel()|) to tear down the
|
| -// channel. Returns a handle to the bootstrap message pipe.
|
| +// the "out" value |*channel_info| should be passed to |DestoryChannel()| to
|
| +// tear down the channel. Returns a handle to the bootstrap message pipe.
|
| MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle
|
| - CreateChannelOnIOThread(ScopedPlatformHandle platform_handle,
|
| - ChannelInfo** channel_info);
|
| +CreateChannelOnIOThread(ScopedPlatformHandle platform_handle,
|
| + ChannelInfo** channel_info);
|
|
|
| typedef base::Callback<void(ChannelInfo*)> DidCreateChannelCallback;
|
| // Creates a channel asynchronously; may be called from any thread.
|
| // |platform_handle| should be a handle to a connected OS "pipe".
|
| // |io_thread_task_runner| should be the |TaskRunner| for the I/O thread.
|
| // |callback| should be the callback to call with the |ChannelInfo*|, which
|
| -// should eventually be passed to |DestroyChannel()| (or
|
| -// |DestroyChannelOnIOThread()|) to tear down the channel; the callback will be
|
| -// called using |callback_thread_task_runner| if that is non-null, or otherwise
|
| -// it will be called using |io_thread_task_runner|. Returns a handle to the
|
| -// bootstrap message pipe.
|
| +// should eventually be passed to |DestroyChannel()| to tear down the channel;
|
| +// the callback will be called using |callback_thread_task_runner| if that is
|
| +// non-null, or otherwise it will be called using |io_thread_task_runner|.
|
| +// Returns a handle to the bootstrap message pipe.
|
| MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle
|
| - CreateChannel(ScopedPlatformHandle platform_handle,
|
| - scoped_refptr<base::TaskRunner> io_thread_task_runner,
|
| - DidCreateChannelCallback callback,
|
| - scoped_refptr<base::TaskRunner> callback_thread_task_runner);
|
| -
|
| -// Destroys a channel that was created using either |CreateChannelOnIOThread()|
|
| -// or |CreateChannel()|; must only be called from the I/O thread. |channel_info|
|
| -// should be the "out" value from |CreateChannelOnIOThread()| or the value
|
| -// provided to the callback to |CreateChannel()|.
|
| -MOJO_SYSTEM_IMPL_EXPORT void DestroyChannelOnIOThread(
|
| - ChannelInfo* channel_info);
|
| +CreateChannel(ScopedPlatformHandle platform_handle,
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner,
|
| + DidCreateChannelCallback callback,
|
| + scoped_refptr<base::TaskRunner> callback_thread_task_runner);
|
|
|
| -// Destroys a channel (asynchronously) that was created using |CreateChannel()|;
|
| -// may be called from any thread. |channel_info| should be the value provided to
|
| -// the callback to |CreateChannel()|.
|
| +// Destroys a channel that was created using |CreateChannel()| (or
|
| +// |CreateChannelOnIOThread()|); may be called from any thread. |channel_info|
|
| +// should be the value provided to the callback to |CreateChannel()| (or
|
| +// returned by |CreateChannelOnIOThread()|). If called from the I/O thread, this
|
| +// will complete synchronously (in particular, it will post no tasks).
|
| MOJO_SYSTEM_IMPL_EXPORT void DestroyChannel(ChannelInfo* channel_info);
|
|
|
| // Inform the channel that it will soon be destroyed (doing so is optional).
|
| // This may be called from any thread, but the caller must ensure that this is
|
| -// called before |DestroyChannel()| or |DestroyChannelOnIOThread()|.
|
| +// called before |DestroyChannel()|.
|
| MOJO_SYSTEM_IMPL_EXPORT void WillDestroyChannelSoon(ChannelInfo* channel_info);
|
|
|
| // Creates a |MojoHandle| that wraps the given |PlatformHandle| (taking
|
| @@ -106,14 +108,14 @@ MOJO_SYSTEM_IMPL_EXPORT void WillDestroyChannelSoon(ChannelInfo* channel_info);
|
| // failure, which is different from what you'd expect from a Mojo API, but it
|
| // makes for a more convenient embedder API.
|
| MOJO_SYSTEM_IMPL_EXPORT MojoResult
|
| - CreatePlatformHandleWrapper(ScopedPlatformHandle platform_handle,
|
| - MojoHandle* platform_handle_wrapper_handle);
|
| +CreatePlatformHandleWrapper(ScopedPlatformHandle platform_handle,
|
| + MojoHandle* platform_handle_wrapper_handle);
|
| // Retrieves the |PlatformHandle| that was wrapped into a |MojoHandle| (using
|
| // |CreatePlatformHandleWrapper()| above). Note that the |MojoHandle| must still
|
| // be closed separately.
|
| MOJO_SYSTEM_IMPL_EXPORT MojoResult
|
| - PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle,
|
| - ScopedPlatformHandle* platform_handle);
|
| +PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle,
|
| + ScopedPlatformHandle* platform_handle);
|
|
|
| } // namespace embedder
|
| } // namespace mojo
|
|
|