Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: mojo/edk/system/ipc_support.h

Issue 1483823004: EDK: Move {platform_handle,scoped_platform_handle}.* to //mojo/edk/platform. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/dispatcher.cc ('k') | mojo/edk/system/ipc_support.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_SYSTEM_IPC_SUPPORT_H_ 5 #ifndef MOJO_EDK_SYSTEM_IPC_SUPPORT_H_
6 #define MOJO_EDK_SYSTEM_IPC_SUPPORT_H_ 6 #define MOJO_EDK_SYSTEM_IPC_SUPPORT_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "mojo/edk/embedder/process_type.h" 12 #include "mojo/edk/embedder/process_type.h"
13 #include "mojo/edk/embedder/scoped_platform_handle.h"
14 #include "mojo/edk/embedder/slave_info.h" 13 #include "mojo/edk/embedder/slave_info.h"
14 #include "mojo/edk/platform/scoped_platform_handle.h"
15 #include "mojo/edk/platform/task_runner.h" 15 #include "mojo/edk/platform/task_runner.h"
16 #include "mojo/edk/system/channel_id.h" 16 #include "mojo/edk/system/channel_id.h"
17 #include "mojo/edk/system/connection_identifier.h" 17 #include "mojo/edk/system/connection_identifier.h"
18 #include "mojo/edk/system/process_identifier.h" 18 #include "mojo/edk/system/process_identifier.h"
19 #include "mojo/edk/util/ref_ptr.h" 19 #include "mojo/edk/util/ref_ptr.h"
20 #include "mojo/public/cpp/system/macros.h" 20 #include "mojo/public/cpp/system/macros.h"
21 21
22 namespace mojo { 22 namespace mojo {
23 23
24 namespace embedder { 24 namespace embedder {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // processes. 60 // processes.
61 // 61 //
62 // All the (pointer) arguments must remain alive (and, in the case of task 62 // All the (pointer) arguments must remain alive (and, in the case of task
63 // runners, continue to process tasks) until |ShutdownOnIOThread()| has been 63 // runners, continue to process tasks) until |ShutdownOnIOThread()| has been
64 // called. 64 // called.
65 IPCSupport(embedder::PlatformSupport* platform_support, 65 IPCSupport(embedder::PlatformSupport* platform_support,
66 embedder::ProcessType process_type, 66 embedder::ProcessType process_type,
67 util::RefPtr<platform::TaskRunner>&& delegate_thread_task_runner, 67 util::RefPtr<platform::TaskRunner>&& delegate_thread_task_runner,
68 embedder::ProcessDelegate* process_delegate, 68 embedder::ProcessDelegate* process_delegate,
69 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner, 69 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner,
70 embedder::ScopedPlatformHandle platform_handle); 70 platform::ScopedPlatformHandle platform_handle);
71 // Note: This object must be shut down before destruction (see 71 // Note: This object must be shut down before destruction (see
72 // |ShutdownOnIOThread()|). 72 // |ShutdownOnIOThread()|).
73 ~IPCSupport(); 73 ~IPCSupport();
74 74
75 // This must be called (exactly once) on the I/O thread before this object is 75 // This must be called (exactly once) on the I/O thread before this object is
76 // destroyed (which may happen on any thread). Note: This does *not* call the 76 // destroyed (which may happen on any thread). Note: This does *not* call the
77 // process delegate's |OnShutdownComplete()|. 77 // process delegate's |OnShutdownComplete()|.
78 void ShutdownOnIOThread(); 78 void ShutdownOnIOThread();
79 79
80 // Generates a new (unique) connection identifier, for use with 80 // Generates a new (unique) connection identifier, for use with
(...skipping 14 matching lines...) Expand all
95 // |callback_thread_task_runner| (if it is non-null) or on the I/O thread. 95 // |callback_thread_task_runner| (if it is non-null) or on the I/O thread.
96 // |*channel_id| will be set to the ID for the channel (immediately); the 96 // |*channel_id| will be set to the ID for the channel (immediately); the
97 // channel may be destroyed using this ID, but only after the callback has 97 // channel may be destroyed using this ID, but only after the callback has
98 // been run. 98 // been run.
99 // 99 //
100 // TODO(vtl): Add some more channel management functionality to this class. 100 // TODO(vtl): Add some more channel management functionality to this class.
101 // Maybe make this callback interface more sane. 101 // Maybe make this callback interface more sane.
102 util::RefPtr<MessagePipeDispatcher> ConnectToSlave( 102 util::RefPtr<MessagePipeDispatcher> ConnectToSlave(
103 const ConnectionIdentifier& connection_id, 103 const ConnectionIdentifier& connection_id,
104 embedder::SlaveInfo slave_info, 104 embedder::SlaveInfo slave_info,
105 embedder::ScopedPlatformHandle platform_handle, 105 platform::ScopedPlatformHandle platform_handle,
106 const base::Closure& callback, 106 const base::Closure& callback,
107 util::RefPtr<platform::TaskRunner>&& callback_thread_task_runner, 107 util::RefPtr<platform::TaskRunner>&& callback_thread_task_runner,
108 ChannelId* channel_id); 108 ChannelId* channel_id);
109 109
110 // Called in a slave process to connect it to the master process and thus the 110 // Called in a slave process to connect it to the master process and thus the
111 // IPC system, creating a |Channel| and an initial message pipe (return a 111 // IPC system, creating a |Channel| and an initial message pipe (return a
112 // dispatcher for the slave's side). See |ConnectToSlave()|, above. 112 // dispatcher for the slave's side). See |ConnectToSlave()|, above.
113 // 113 //
114 // |callback|, |callback_thread_task_runner|, and |channel_id| are as in 114 // |callback|, |callback_thread_task_runner|, and |channel_id| are as in
115 // |ConnectToSlave()|. 115 // |ConnectToSlave()|.
(...skipping 24 matching lines...) Expand all
140 // These test |ConnectToSlaveInternal()| and |ConnectToMasterInternal()|. 140 // These test |ConnectToSlaveInternal()| and |ConnectToMasterInternal()|.
141 FRIEND_TEST_ALL_PREFIXES(IPCSupportTest, MasterSlaveInternal); 141 FRIEND_TEST_ALL_PREFIXES(IPCSupportTest, MasterSlaveInternal);
142 FRIEND_TEST_ALL_PREFIXES(IPCSupportTest, MultiprocessMasterSlaveInternal); 142 FRIEND_TEST_ALL_PREFIXES(IPCSupportTest, MultiprocessMasterSlaveInternal);
143 friend void MultiprocessMasterSlaveInternalTestChildTest(); 143 friend void MultiprocessMasterSlaveInternalTestChildTest();
144 144
145 // Helper for |ConnectToSlave()|. Connects (using the connection manager) to 145 // Helper for |ConnectToSlave()|. Connects (using the connection manager) to
146 // the slave using |platform_handle| (a handle to an OS "pipe" between master 146 // the slave using |platform_handle| (a handle to an OS "pipe" between master
147 // and slave) and creates a second OS "pipe" between the master and slave 147 // and slave) and creates a second OS "pipe" between the master and slave
148 // (returning the master's handle). |*slave_process_identifier| will be set to 148 // (returning the master's handle). |*slave_process_identifier| will be set to
149 // the process identifier assigned to the slave. 149 // the process identifier assigned to the slave.
150 embedder::ScopedPlatformHandle ConnectToSlaveInternal( 150 platform::ScopedPlatformHandle ConnectToSlaveInternal(
151 const ConnectionIdentifier& connection_id, 151 const ConnectionIdentifier& connection_id,
152 embedder::SlaveInfo slave_info, 152 embedder::SlaveInfo slave_info,
153 embedder::ScopedPlatformHandle platform_handle, 153 platform::ScopedPlatformHandle platform_handle,
154 ProcessIdentifier* slave_process_identifier); 154 ProcessIdentifier* slave_process_identifier);
155 155
156 // Helper for |ConnectToMaster()|. Connects (using the connection manager) to 156 // Helper for |ConnectToMaster()|. Connects (using the connection manager) to
157 // the master (using the handle to the OS "pipe" that was given to 157 // the master (using the handle to the OS "pipe" that was given to
158 // |SlaveConnectionManager::Init()|) and creates a second OS "pipe" between 158 // |SlaveConnectionManager::Init()|) and creates a second OS "pipe" between
159 // the master and slave (returning the slave's handle). 159 // the master and slave (returning the slave's handle).
160 embedder::ScopedPlatformHandle ConnectToMasterInternal( 160 platform::ScopedPlatformHandle ConnectToMasterInternal(
161 const ConnectionIdentifier& connection_id); 161 const ConnectionIdentifier& connection_id);
162 162
163 ConnectionManager* connection_manager() const { 163 ConnectionManager* connection_manager() const {
164 return connection_manager_.get(); 164 return connection_manager_.get();
165 } 165 }
166 166
167 // These are all set on construction and reset by |ShutdownOnIOThread()|. 167 // These are all set on construction and reset by |ShutdownOnIOThread()|.
168 embedder::ProcessType process_type_; 168 embedder::ProcessType process_type_;
169 util::RefPtr<platform::TaskRunner> delegate_thread_task_runner_; 169 util::RefPtr<platform::TaskRunner> delegate_thread_task_runner_;
170 embedder::ProcessDelegate* process_delegate_; 170 embedder::ProcessDelegate* process_delegate_;
171 util::RefPtr<platform::TaskRunner> io_thread_task_runner_; 171 util::RefPtr<platform::TaskRunner> io_thread_task_runner_;
172 172
173 std::unique_ptr<ConnectionManager> connection_manager_; 173 std::unique_ptr<ConnectionManager> connection_manager_;
174 std::unique_ptr<ChannelManager> channel_manager_; 174 std::unique_ptr<ChannelManager> channel_manager_;
175 175
176 MOJO_DISALLOW_COPY_AND_ASSIGN(IPCSupport); 176 MOJO_DISALLOW_COPY_AND_ASSIGN(IPCSupport);
177 }; 177 };
178 178
179 } // namespace system 179 } // namespace system
180 } // namespace mojo 180 } // namespace mojo
181 181
182 #endif // MOJO_EDK_SYSTEM_IPC_SUPPORT_H_ 182 #endif // MOJO_EDK_SYSTEM_IPC_SUPPORT_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/dispatcher.cc ('k') | mojo/edk/system/ipc_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698