| 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/process/process.h" | 13 #include "base/process/process_handle.h" |
| 14 #include "base/task_runner.h" | 14 #include "base/task_runner.h" |
| 15 #include "mojo/edk/embedder/scoped_platform_handle.h" | 15 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 16 #include "mojo/edk/system/system_impl_export.h" | 16 #include "mojo/edk/system/system_impl_export.h" |
| 17 #include "mojo/public/cpp/system/message_pipe.h" | 17 #include "mojo/public/cpp/system/message_pipe.h" |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 namespace edk { | 20 namespace edk { |
| 21 | 21 |
| 22 class ProcessDelegate; | 22 class ProcessDelegate; |
| 23 | 23 |
| 24 // Basic configuration/initialization ------------------------------------------ | 24 // Basic configuration/initialization ------------------------------------------ |
| 25 | 25 |
| 26 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| | 26 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| |
| 27 // functions available and functional. This is never shut down (except in tests | 27 // functions available and functional. This is never shut down (except in tests |
| 28 // -- see test_embedder.h). | 28 // -- see test_embedder.h). |
| 29 | 29 |
| 30 // Allows changing the default max message size. Must be called before Init. | 30 // Allows changing the default max message size. Must be called before Init. |
| 31 MOJO_SYSTEM_IMPL_EXPORT void SetMaxMessageSize(size_t bytes); | 31 MOJO_SYSTEM_IMPL_EXPORT void SetMaxMessageSize(size_t bytes); |
| 32 | 32 |
| 33 #if defined(OS_WIN) | |
| 34 // Must be called before Init in the parent (unsandboxed) process. | 33 // Must be called before Init in the parent (unsandboxed) process. |
| 35 MOJO_SYSTEM_IMPL_EXPORT void PreInitializeParentProcess(); | 34 MOJO_SYSTEM_IMPL_EXPORT void PreInitializeParentProcess(); |
| 36 | 35 |
| 37 // Must be called before Init in the child (sandboxed) process. | 36 // Must be called before Init in the child (sandboxed) process. |
| 38 MOJO_SYSTEM_IMPL_EXPORT void PreInitializeChildProcess(); | 37 MOJO_SYSTEM_IMPL_EXPORT void PreInitializeChildProcess(); |
| 39 | 38 |
| 40 // Called in the parent process for each child process that is launched. The | 39 // Called in the parent process for each child process that is launched. The |
| 41 // returned handle must be sent to the child process which then calls | 40 // returned handle must be sent to the child process which then calls |
| 42 // SetParentPipeHandle. | 41 // SetParentPipeHandle. |
| 43 MOJO_SYSTEM_IMPL_EXPORT HANDLE ChildProcessLaunched(HANDLE child_process); | 42 MOJO_SYSTEM_IMPL_EXPORT ScopedPlatformHandle ChildProcessLaunched( |
| 43 base::ProcessHandle child_process); |
| 44 // Like above, except used when the embedder establishes the pipe between the | 44 // Like above, except used when the embedder establishes the pipe between the |
| 45 // parent and child processes itself. | 45 // parent and child processes itself. |
| 46 MOJO_SYSTEM_IMPL_EXPORT void ChildProcessLaunched(HANDLE child_process, | 46 MOJO_SYSTEM_IMPL_EXPORT void ChildProcessLaunched( |
| 47 HANDLE server_pipe); | 47 base::ProcessHandle child_process, ScopedPlatformHandle server_pipe); |
| 48 | 48 |
| 49 // Should be called as early as possible in the child process with the handle | 49 // Should be called as early as possible in the child process with the handle |
| 50 // that the parent received from ChildProcessLaunched. | 50 // that the parent received from ChildProcessLaunched. |
| 51 MOJO_SYSTEM_IMPL_EXPORT void SetParentPipeHandle(HANDLE pipe); | 51 MOJO_SYSTEM_IMPL_EXPORT void SetParentPipeHandle(ScopedPlatformHandle pipe); |
| 52 #endif | |
| 53 | 52 |
| 54 // Must be called first, or just after setting configuration parameters, to | 53 // Must be called first, or just after setting configuration parameters, to |
| 55 // initialize the (global, singleton) system. | 54 // initialize the (global, singleton) system. |
| 56 MOJO_SYSTEM_IMPL_EXPORT void Init(); | 55 MOJO_SYSTEM_IMPL_EXPORT void Init(); |
| 57 | 56 |
| 58 // Basic functions ------------------------------------------------------------- | 57 // Basic functions ------------------------------------------------------------- |
| 59 | 58 |
| 60 // The functions in this section are available once |Init()| has been called. | 59 // The functions in this section are available once |Init()| has been called. |
| 61 | 60 |
| 62 // Start waiting on the handle asynchronously. On success, |callback| will be | 61 // Start waiting on the handle asynchronously. On success, |callback| will be |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupportAndWaitForNoChannels(); | 121 MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupportAndWaitForNoChannels(); |
| 123 | 122 |
| 124 // Creates a message pipe from a platform handle. Safe to call from any thread. | 123 // Creates a message pipe from a platform handle. Safe to call from any thread. |
| 125 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle | 124 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle |
| 126 CreateMessagePipe(ScopedPlatformHandle platform_handle); | 125 CreateMessagePipe(ScopedPlatformHandle platform_handle); |
| 127 | 126 |
| 128 } // namespace edk | 127 } // namespace edk |
| 129 } // namespace mojo | 128 } // namespace mojo |
| 130 | 129 |
| 131 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ | 130 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
| OLD | NEW |