| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/shared_memory_handle.h" | 16 #include "base/memory/shared_memory_handle.h" |
| 17 #include "base/process/process_handle.h" | 17 #include "base/process/process_handle.h" |
| 18 #include "base/task_runner.h" | 18 #include "base/task_runner.h" |
| 19 #include "mojo/edk/embedder/scoped_platform_handle.h" | 19 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 20 #include "mojo/edk/system/system_impl_export.h" | 20 #include "mojo/edk/system/system_impl_export.h" |
| 21 #include "mojo/public/cpp/system/message_pipe.h" | 21 #include "mojo/public/cpp/system/message_pipe.h" |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 class PortProvider; | 24 class PortProvider; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace mojo { | 27 namespace mojo { |
| 28 namespace edk { | 28 namespace edk { |
| 29 | 29 |
| 30 class ProcessDelegate; | |
| 31 | |
| 32 using ProcessErrorCallback = base::Callback<void(const std::string& error)>; | 30 using ProcessErrorCallback = base::Callback<void(const std::string& error)>; |
| 33 | 31 |
| 34 // Basic configuration/initialization ------------------------------------------ | 32 // Basic configuration/initialization ------------------------------------------ |
| 35 | 33 |
| 36 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| | 34 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| |
| 37 // functions available and functional. This is never shut down (except in tests | 35 // functions available and functional. This is never shut down (except in tests |
| 38 // -- see test_embedder.h). | 36 // -- see test_embedder.h). |
| 39 | 37 |
| 40 // Allows changing the default max message size. Must be called before Init. | 38 // Allows changing the default max message size. Must be called before Init. |
| 41 MOJO_SYSTEM_IMPL_EXPORT void SetMaxMessageSize(size_t bytes); | 39 MOJO_SYSTEM_IMPL_EXPORT void SetMaxMessageSize(size_t bytes); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 bool* read_only); | 141 bool* read_only); |
| 144 | 142 |
| 145 // Initialialization/shutdown for interprocess communication (IPC) ------------- | 143 // Initialialization/shutdown for interprocess communication (IPC) ------------- |
| 146 | 144 |
| 147 // |InitIPCSupport()| sets up the subsystem for interprocess communication, | 145 // |InitIPCSupport()| sets up the subsystem for interprocess communication, |
| 148 // making the IPC functions (in the following section) available and functional. | 146 // making the IPC functions (in the following section) available and functional. |
| 149 // (This may only be done after |Init()|.) | 147 // (This may only be done after |Init()|.) |
| 150 // | 148 // |
| 151 // This subsystem may be shut down using |ShutdownIPCSupport()|. None of the IPC | 149 // This subsystem may be shut down using |ShutdownIPCSupport()|. None of the IPC |
| 152 // functions may be called after this is called. | 150 // functions may be called after this is called. |
| 151 // |
| 152 // |io_thread_task_runner| should live at least until |ShutdownIPCSupport()|'s |
| 153 // callback has been run. |
| 154 MOJO_SYSTEM_IMPL_EXPORT void InitIPCSupport( |
| 155 scoped_refptr<base::TaskRunner> io_thread_task_runner); |
| 153 | 156 |
| 154 // Initializes a process of the given type; to be called after |Init()|. | 157 // Retrieves the TaskRunner used for IPC I/O, as set by InitIPCSupport. |
| 155 // - |process_delegate| must be a process delegate of the appropriate type | 158 MOJO_SYSTEM_IMPL_EXPORT scoped_refptr<base::TaskRunner> GetIOTaskRunner(); |
| 156 // corresponding to |process_type|; its methods will be called on the same | |
| 157 // thread as Shutdown. | |
| 158 // - |process_delegate|, and |io_thread_task_runner| should live at least | |
| 159 // until |ShutdownIPCSupport()|'s callback has been run. | |
| 160 MOJO_SYSTEM_IMPL_EXPORT void InitIPCSupport( | |
| 161 ProcessDelegate* process_delegate, | |
| 162 scoped_refptr<base::TaskRunner> io_thread_task_runner); | |
| 163 | 159 |
| 164 // Shuts down the subsystem initialized by |InitIPCSupport()|. It be called from | 160 // Shuts down the subsystem initialized by |InitIPCSupport()|. It be called from |
| 165 // any thread and will attempt to complete shutdown on the I/O thread with which | 161 // any thread and will attempt to complete shutdown on the I/O thread with which |
| 166 // the system was initialized. Upon completion the ProcessDelegate's | 162 // the system was initialized. Upon completion, |callback| is invoked on an |
| 167 // |OnShutdownComplete()| method is invoked. | 163 // arbitrary thread. |
| 168 MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupport(); | 164 MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupport(const base::Closure& callback); |
| 169 | 165 |
| 170 #if defined(OS_MACOSX) && !defined(OS_IOS) | 166 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 171 // Set the |base::PortProvider| for this process. Can be called on any thread, | 167 // Set the |base::PortProvider| for this process. Can be called on any thread, |
| 172 // but must be set in the root process before any Mach ports can be transferred. | 168 // but must be set in the root process before any Mach ports can be transferred. |
| 173 MOJO_SYSTEM_IMPL_EXPORT void SetMachPortProvider( | 169 MOJO_SYSTEM_IMPL_EXPORT void SetMachPortProvider( |
| 174 base::PortProvider* port_provider); | 170 base::PortProvider* port_provider); |
| 175 #endif | 171 #endif |
| 176 | 172 |
| 177 // Creates a message pipe over an arbitrary platform channel. The other end of | 173 // Creates a message pipe over an arbitrary platform channel. The other end of |
| 178 // the channel must also be passed to this function. Either endpoint can be in | 174 // the channel must also be passed to this function. Either endpoint can be in |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // | 206 // |
| 211 // Default property values: | 207 // Default property values: |
| 212 // |MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED| - true | 208 // |MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED| - true |
| 213 MOJO_SYSTEM_IMPL_EXPORT MojoResult SetProperty(MojoPropertyType type, | 209 MOJO_SYSTEM_IMPL_EXPORT MojoResult SetProperty(MojoPropertyType type, |
| 214 const void* value); | 210 const void* value); |
| 215 | 211 |
| 216 } // namespace edk | 212 } // namespace edk |
| 217 } // namespace mojo | 213 } // namespace mojo |
| 218 | 214 |
| 219 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ | 215 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
| OLD | NEW |