| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_EDK_EMBEDDER_EMBEDDER_H_ | 5 #ifndef MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
| 6 #define MOJO_EDK_EMBEDDER_EMBEDDER_H_ | 6 #define MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/task_runner.h" | 13 #include "base/task_runner.h" |
| 14 #include "mojo/edk/embedder/channel_info_forward.h" | 14 #include "mojo/edk/embedder/channel_info_forward.h" |
| 15 #include "mojo/edk/embedder/process_type.h" | 15 #include "mojo/edk/embedder/process_type.h" |
| 16 #include "mojo/edk/embedder/scoped_platform_handle.h" | 16 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 17 #include "mojo/edk/system/system_impl_export.h" | 17 #include "mojo/edk/system/system_impl_export.h" |
| 18 #include "mojo/public/cpp/system/message_pipe.h" | 18 #include "mojo/public/cpp/system/message_pipe.h" |
| 19 | 19 |
| 20 namespace mojo { | 20 namespace mojo { |
| 21 namespace embedder { | 21 namespace embedder { |
| 22 | 22 |
| 23 struct Configuration; | 23 struct Configuration; |
| 24 class PlatformSupport; | 24 class PlatformSupport; |
| 25 class ProcessDelegate; | 25 class ProcessDelegate; |
| 26 typedef void* SlaveInfo; | 26 using SlaveInfo = void*; |
| 27 | 27 |
| 28 // Basic configuration/initialization ------------------------------------------ | 28 // Basic configuration/initialization ------------------------------------------ |
| 29 | 29 |
| 30 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| | 30 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| |
| 31 // functions available and functional. This is never shut down (except in tests | 31 // functions available and functional. This is never shut down (except in tests |
| 32 // -- see test_embedder.h). | 32 // -- see test_embedder.h). |
| 33 | 33 |
| 34 // Returns the global configuration. In general, you should not need to change | 34 // Returns the global configuration. In general, you should not need to change |
| 35 // the configuration, but if you do you must do it before calling |Init()|. | 35 // the configuration, but if you do you must do it before calling |Init()|. |
| 36 MOJO_SYSTEM_IMPL_EXPORT Configuration* GetConfiguration(); | 36 MOJO_SYSTEM_IMPL_EXPORT Configuration* GetConfiguration(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // respectively, and take the |ChannelInfo*| produced by the creation functions. | 184 // respectively, and take the |ChannelInfo*| produced by the creation functions. |
| 185 | 185 |
| 186 // Creates a channel; must only be called from the I/O thread. |platform_handle| | 186 // Creates a channel; must only be called from the I/O thread. |platform_handle| |
| 187 // should be a handle to a connected OS "pipe". Eventually (even on failure), | 187 // should be a handle to a connected OS "pipe". Eventually (even on failure), |
| 188 // the "out" value |*channel_info| should be passed to |DestoryChannel()| to | 188 // the "out" value |*channel_info| should be passed to |DestoryChannel()| to |
| 189 // tear down the channel. Returns a handle to the bootstrap message pipe. | 189 // tear down the channel. Returns a handle to the bootstrap message pipe. |
| 190 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle | 190 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle |
| 191 CreateChannelOnIOThread(ScopedPlatformHandle platform_handle, | 191 CreateChannelOnIOThread(ScopedPlatformHandle platform_handle, |
| 192 ChannelInfo** channel_info); | 192 ChannelInfo** channel_info); |
| 193 | 193 |
| 194 typedef base::Callback<void(ChannelInfo*)> DidCreateChannelCallback; | 194 using DidCreateChannelCallback = base::Callback<void(ChannelInfo*)>; |
| 195 // Creates a channel asynchronously; may be called from any thread. | 195 // Creates a channel asynchronously; may be called from any thread. |
| 196 // |platform_handle| should be a handle to a connected OS "pipe". | 196 // |platform_handle| should be a handle to a connected OS "pipe". |
| 197 // |io_thread_task_runner| should be the |TaskRunner| for the I/O thread. | 197 // |io_thread_task_runner| should be the |TaskRunner| for the I/O thread. |
| 198 // |callback| should be the callback to call with the |ChannelInfo*|, which | 198 // |callback| should be the callback to call with the |ChannelInfo*|, which |
| 199 // should eventually be passed to |DestroyChannel()| to tear down the channel; | 199 // should eventually be passed to |DestroyChannel()| to tear down the channel; |
| 200 // the callback will be called using |callback_thread_task_runner| if that is | 200 // the callback will be called using |callback_thread_task_runner| if that is |
| 201 // non-null, or otherwise it will be called using |io_thread_task_runner|. | 201 // non-null, or otherwise it will be called using |io_thread_task_runner|. |
| 202 // Returns a handle to the bootstrap message pipe. | 202 // Returns a handle to the bootstrap message pipe. |
| 203 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle | 203 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle |
| 204 CreateChannel(ScopedPlatformHandle platform_handle, | 204 CreateChannel(ScopedPlatformHandle platform_handle, |
| 205 scoped_refptr<base::TaskRunner> io_thread_task_runner, | 205 scoped_refptr<base::TaskRunner> io_thread_task_runner, |
| 206 const DidCreateChannelCallback& callback, | 206 const DidCreateChannelCallback& callback, |
| 207 scoped_refptr<base::TaskRunner> callback_thread_task_runner); | 207 scoped_refptr<base::TaskRunner> callback_thread_task_runner); |
| 208 | 208 |
| 209 // Destroys a channel that was created using |CreateChannel()| (or | 209 // Destroys a channel that was created using |CreateChannel()| (or |
| 210 // |CreateChannelOnIOThread()|); must be called from the channel's I'O thread. | 210 // |CreateChannelOnIOThread()|); must be called from the channel's I'O thread. |
| 211 // |channel_info| should be the value provided to the callback to | 211 // |channel_info| should be the value provided to the callback to |
| 212 // |CreateChannel()| (or returned by |CreateChannelOnIOThread()|). Completes | 212 // |CreateChannel()| (or returned by |CreateChannelOnIOThread()|). Completes |
| 213 // synchronously (and posts no tasks). | 213 // synchronously (and posts no tasks). |
| 214 MOJO_SYSTEM_IMPL_EXPORT void DestroyChannelOnIOThread( | 214 MOJO_SYSTEM_IMPL_EXPORT void DestroyChannelOnIOThread( |
| 215 ChannelInfo* channel_info); | 215 ChannelInfo* channel_info); |
| 216 | 216 |
| 217 typedef base::Closure DidDestroyChannelCallback; | 217 using DidDestroyChannelCallback = base::Closure; |
| 218 // Like |DestroyChannelOnIOThread()|, but asynchronous and may be called from | 218 // Like |DestroyChannelOnIOThread()|, but asynchronous and may be called from |
| 219 // any thread. The callback will be called using |callback_thread_task_runner| | 219 // any thread. The callback will be called using |callback_thread_task_runner| |
| 220 // if that is non-null, or otherwise it will be called on the "channel thread". | 220 // if that is non-null, or otherwise it will be called on the "channel thread". |
| 221 // The "channel thread" must remain alive and continue to process tasks until | 221 // The "channel thread" must remain alive and continue to process tasks until |
| 222 // the callback has been executed. | 222 // the callback has been executed. |
| 223 MOJO_SYSTEM_IMPL_EXPORT void DestroyChannel( | 223 MOJO_SYSTEM_IMPL_EXPORT void DestroyChannel( |
| 224 ChannelInfo* channel_info, | 224 ChannelInfo* channel_info, |
| 225 const DidDestroyChannelCallback& callback, | 225 const DidDestroyChannelCallback& callback, |
| 226 scoped_refptr<base::TaskRunner> callback_thread_task_runner); | 226 scoped_refptr<base::TaskRunner> callback_thread_task_runner); |
| 227 | 227 |
| 228 // Inform the channel that it will soon be destroyed (doing so is optional). | 228 // Inform the channel that it will soon be destroyed (doing so is optional). |
| 229 // This may be called from any thread, but the caller must ensure that this is | 229 // This may be called from any thread, but the caller must ensure that this is |
| 230 // called before |DestroyChannel()|. | 230 // called before |DestroyChannel()|. |
| 231 MOJO_SYSTEM_IMPL_EXPORT void WillDestroyChannelSoon(ChannelInfo* channel_info); | 231 MOJO_SYSTEM_IMPL_EXPORT void WillDestroyChannelSoon(ChannelInfo* channel_info); |
| 232 | 232 |
| 233 } // namespace embedder | 233 } // namespace embedder |
| 234 } // namespace mojo | 234 } // namespace mojo |
| 235 | 235 |
| 236 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ | 236 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
| OLD | NEW |