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 <functional> | 8 #include <functional> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "mojo/edk/embedder/channel_info_forward.h" | 12 #include "mojo/edk/embedder/channel_info_forward.h" |
13 #include "mojo/edk/embedder/process_type.h" | 13 #include "mojo/edk/embedder/process_type.h" |
14 #include "mojo/edk/embedder/slave_info.h" | 14 #include "mojo/edk/embedder/slave_info.h" |
15 #include "mojo/edk/platform/scoped_platform_handle.h" | 15 #include "mojo/edk/platform/scoped_platform_handle.h" |
16 #include "mojo/edk/platform/task_runner.h" | 16 #include "mojo/edk/platform/task_runner.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 |
| 21 namespace platform { |
| 22 class PlatformHandleWatcher; |
| 23 } |
| 24 |
20 namespace embedder { | 25 namespace embedder { |
21 | 26 |
22 struct Configuration; | 27 struct Configuration; |
23 class PlatformSupport; | 28 class PlatformSupport; |
24 class ProcessDelegate; | 29 class ProcessDelegate; |
25 | 30 |
26 // Basic configuration/initialization ------------------------------------------ | 31 // Basic configuration/initialization ------------------------------------------ |
27 | 32 |
28 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| | 33 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| |
29 // functions available and functional. This is never shut down (except in tests | 34 // functions available and functional. This is never shut down (except in tests |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // (This may only be done after |Init()|.) | 77 // (This may only be done after |Init()|.) |
73 // | 78 // |
74 // This subsystem may be shut down, using |ShutdownIPCSupportOnIOThread()| or | 79 // This subsystem may be shut down, using |ShutdownIPCSupportOnIOThread()| or |
75 // |ShutdownIPCSupport()|. None of the IPC functions may be called while or | 80 // |ShutdownIPCSupport()|. None of the IPC functions may be called while or |
76 // after either of these is called. | 81 // after either of these is called. |
77 | 82 |
78 // Initializes a process of the given type; to be called after |Init()|. | 83 // Initializes a process of the given type; to be called after |Init()|. |
79 // - |process_delegate| must be a process delegate of the appropriate type | 84 // - |process_delegate| must be a process delegate of the appropriate type |
80 // corresponding to |process_type|; its methods will be called on | 85 // corresponding to |process_type|; its methods will be called on |
81 // |delegate_thread_task_runner|. | 86 // |delegate_thread_task_runner|. |
82 // - |delegate_thread_task_runner|, |process_delegate|, and | 87 // - |delegate_thread_task_runner|, |process_delegate|, |io_task_runner|, |
83 // |io_thread_task_runner| should live at least until | 88 // and |io_watcher| should live at least until |ShutdownIPCSupport()|'s |
84 // |ShutdownIPCSupport()|'s callback has been run or | 89 // callback has been run or |ShutdownIPCSupportOnIOThread()| has completed. |
85 // |ShutdownIPCSupportOnIOThread()| has completed. | |
86 // - For slave processes (i.e., |process_type| is |ProcessType::SLAVE|), | 90 // - For slave processes (i.e., |process_type| is |ProcessType::SLAVE|), |
87 // |platform_handle| should be connected to the handle passed to | 91 // |platform_handle| should be connected to the handle passed to |
88 // |ConnectToSlave()| (in the master process). For other processes, | 92 // |ConnectToSlave()| (in the master process). For other processes, |
89 // |platform_handle| is ignored (and should not be valid). | 93 // |platform_handle| is ignored (and should not be valid). |
90 void InitIPCSupport( | 94 void InitIPCSupport( |
91 ProcessType process_type, | 95 ProcessType process_type, |
92 util::RefPtr<platform::TaskRunner>&& delegate_thread_task_runner, | 96 util::RefPtr<platform::TaskRunner>&& delegate_thread_task_runner, |
93 ProcessDelegate* process_delegate, | 97 ProcessDelegate* process_delegate, |
94 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner, | 98 util::RefPtr<platform::TaskRunner>&& io_task_runner, |
| 99 platform::PlatformHandleWatcher* io_watcher, |
95 platform::ScopedPlatformHandle platform_handle); | 100 platform::ScopedPlatformHandle platform_handle); |
96 | 101 |
97 // Shuts down the subsystem initialized by |InitIPCSupport()|. This must be | 102 // Shuts down the subsystem initialized by |InitIPCSupport()|. This must be |
98 // called on the I/O thread (given to |InitIPCSupport()|). This completes | 103 // called on the I/O thread (given to |InitIPCSupport()|). This completes |
99 // synchronously and does not result in a call to the process delegate's | 104 // synchronously and does not result in a call to the process delegate's |
100 // |OnShutdownComplete()|. | 105 // |OnShutdownComplete()|. |
101 void ShutdownIPCSupportOnIOThread(); | 106 void ShutdownIPCSupportOnIOThread(); |
102 | 107 |
103 // Like |ShutdownIPCSupportOnIOThread()|, but may be called from any thread, | 108 // Like |ShutdownIPCSupportOnIOThread()|, but may be called from any thread, |
104 // signaling shutdown completion via the process delegate's | 109 // signaling shutdown completion via the process delegate's |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 234 |
230 // Inform the channel that it will soon be destroyed (doing so is optional). | 235 // Inform the channel that it will soon be destroyed (doing so is optional). |
231 // This may be called from any thread, but the caller must ensure that this is | 236 // This may be called from any thread, but the caller must ensure that this is |
232 // called before |DestroyChannel()|. | 237 // called before |DestroyChannel()|. |
233 void WillDestroyChannelSoon(ChannelInfo* channel_info); | 238 void WillDestroyChannelSoon(ChannelInfo* channel_info); |
234 | 239 |
235 } // namespace embedder | 240 } // namespace embedder |
236 } // namespace mojo | 241 } // namespace mojo |
237 | 242 |
238 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ | 243 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
OLD | NEW |