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

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

Issue 1462083003: Add //mojo/edk/platform and move platform_task_runners.h there. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: update readme Created 5 years, 1 month 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
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 #include "mojo/edk/system/ipc_support.h" 5 #include "mojo/edk/system/ipc_support.h"
6 6
7 #include <type_traits> 7 #include <type_traits>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "mojo/edk/embedder/master_process_delegate.h" 11 #include "mojo/edk/embedder/master_process_delegate.h"
12 #include "mojo/edk/embedder/slave_process_delegate.h" 12 #include "mojo/edk/embedder/slave_process_delegate.h"
13 #include "mojo/edk/system/channel_manager.h" 13 #include "mojo/edk/system/channel_manager.h"
14 #include "mojo/edk/system/master_connection_manager.h" 14 #include "mojo/edk/system/master_connection_manager.h"
15 #include "mojo/edk/system/message_pipe_dispatcher.h" 15 #include "mojo/edk/system/message_pipe_dispatcher.h"
16 #include "mojo/edk/system/slave_connection_manager.h" 16 #include "mojo/edk/system/slave_connection_manager.h"
17 17
18 using mojo::platform::TaskRunner;
18 using mojo::util::RefPtr; 19 using mojo::util::RefPtr;
19 20
20 namespace mojo { 21 namespace mojo {
21 namespace system { 22 namespace system {
22 23
23 IPCSupport::IPCSupport( 24 IPCSupport::IPCSupport(embedder::PlatformSupport* platform_support,
24 embedder::PlatformSupport* platform_support, 25 embedder::ProcessType process_type,
25 embedder::ProcessType process_type, 26 RefPtr<TaskRunner>&& delegate_thread_task_runner,
26 RefPtr<embedder::PlatformTaskRunner>&& delegate_thread_task_runner, 27 embedder::ProcessDelegate* process_delegate,
27 embedder::ProcessDelegate* process_delegate, 28 RefPtr<TaskRunner>&& io_thread_task_runner,
28 RefPtr<embedder::PlatformTaskRunner>&& io_thread_task_runner, 29 embedder::ScopedPlatformHandle platform_handle)
29 embedder::ScopedPlatformHandle platform_handle)
30 : process_type_(process_type), 30 : process_type_(process_type),
31 delegate_thread_task_runner_(std::move(delegate_thread_task_runner)), 31 delegate_thread_task_runner_(std::move(delegate_thread_task_runner)),
32 process_delegate_(process_delegate), 32 process_delegate_(process_delegate),
33 io_thread_task_runner_(std::move(io_thread_task_runner)) { 33 io_thread_task_runner_(std::move(io_thread_task_runner)) {
34 DCHECK(delegate_thread_task_runner_); 34 DCHECK(delegate_thread_task_runner_);
35 DCHECK(io_thread_task_runner_); 35 DCHECK(io_thread_task_runner_);
36 36
37 switch (process_type_) { 37 switch (process_type_) {
38 case embedder::ProcessType::UNINITIALIZED: 38 case embedder::ProcessType::UNINITIALIZED:
39 CHECK(false); 39 CHECK(false);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 ConnectionIdentifier IPCSupport::GenerateConnectionIdentifier() { 91 ConnectionIdentifier IPCSupport::GenerateConnectionIdentifier() {
92 return connection_manager()->GenerateConnectionIdentifier(); 92 return connection_manager()->GenerateConnectionIdentifier();
93 } 93 }
94 94
95 RefPtr<MessagePipeDispatcher> IPCSupport::ConnectToSlave( 95 RefPtr<MessagePipeDispatcher> IPCSupport::ConnectToSlave(
96 const ConnectionIdentifier& connection_id, 96 const ConnectionIdentifier& connection_id,
97 embedder::SlaveInfo slave_info, 97 embedder::SlaveInfo slave_info,
98 embedder::ScopedPlatformHandle platform_handle, 98 embedder::ScopedPlatformHandle platform_handle,
99 const base::Closure& callback, 99 const base::Closure& callback,
100 RefPtr<embedder::PlatformTaskRunner>&& callback_thread_task_runner, 100 RefPtr<TaskRunner>&& callback_thread_task_runner,
101 ChannelId* channel_id) { 101 ChannelId* channel_id) {
102 DCHECK(channel_id); 102 DCHECK(channel_id);
103 103
104 // We rely on |ChannelId| and |ProcessIdentifier| being identical types. 104 // We rely on |ChannelId| and |ProcessIdentifier| being identical types.
105 static_assert(std::is_same<ChannelId, ProcessIdentifier>::value, 105 static_assert(std::is_same<ChannelId, ProcessIdentifier>::value,
106 "ChannelId and ProcessIdentifier types don't match"); 106 "ChannelId and ProcessIdentifier types don't match");
107 107
108 embedder::ScopedPlatformHandle platform_connection_handle = 108 embedder::ScopedPlatformHandle platform_connection_handle =
109 ConnectToSlaveInternal(connection_id, slave_info, platform_handle.Pass(), 109 ConnectToSlaveInternal(connection_id, slave_info, platform_handle.Pass(),
110 channel_id); 110 channel_id);
111 return channel_manager()->CreateChannel( 111 return channel_manager()->CreateChannel(
112 *channel_id, platform_connection_handle.Pass(), callback, 112 *channel_id, platform_connection_handle.Pass(), callback,
113 std::move(callback_thread_task_runner)); 113 std::move(callback_thread_task_runner));
114 } 114 }
115 115
116 RefPtr<MessagePipeDispatcher> IPCSupport::ConnectToMaster( 116 RefPtr<MessagePipeDispatcher> IPCSupport::ConnectToMaster(
117 const ConnectionIdentifier& connection_id, 117 const ConnectionIdentifier& connection_id,
118 const base::Closure& callback, 118 const base::Closure& callback,
119 RefPtr<embedder::PlatformTaskRunner>&& callback_thread_task_runner, 119 RefPtr<TaskRunner>&& callback_thread_task_runner,
120 ChannelId* channel_id) { 120 ChannelId* channel_id) {
121 DCHECK(channel_id); 121 DCHECK(channel_id);
122 122
123 static_assert(std::is_same<ChannelId, ProcessIdentifier>::value, 123 static_assert(std::is_same<ChannelId, ProcessIdentifier>::value,
124 "ChannelId and ProcessIdentifier types don't match"); 124 "ChannelId and ProcessIdentifier types don't match");
125 embedder::ScopedPlatformHandle platform_connection_handle = 125 embedder::ScopedPlatformHandle platform_connection_handle =
126 ConnectToMasterInternal(connection_id); 126 ConnectToMasterInternal(connection_id);
127 *channel_id = kMasterProcessIdentifier; 127 *channel_id = kMasterProcessIdentifier;
128 return channel_manager()->CreateChannel( 128 return channel_manager()->CreateChannel(
129 *channel_id, platform_connection_handle.Pass(), callback, 129 *channel_id, platform_connection_handle.Pass(), callback,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 CHECK_EQ(connection_manager()->Connect(connection_id, &peer_id, &is_first, 164 CHECK_EQ(connection_manager()->Connect(connection_id, &peer_id, &is_first,
165 &platform_connection_handle), 165 &platform_connection_handle),
166 ConnectionManager::Result::SUCCESS_CONNECT_NEW_CONNECTION); 166 ConnectionManager::Result::SUCCESS_CONNECT_NEW_CONNECTION);
167 DCHECK_EQ(peer_id, system::kMasterProcessIdentifier); 167 DCHECK_EQ(peer_id, system::kMasterProcessIdentifier);
168 DCHECK(platform_connection_handle.is_valid()); 168 DCHECK(platform_connection_handle.is_valid());
169 return platform_connection_handle; 169 return platform_connection_handle;
170 } 170 }
171 171
172 } // namespace system 172 } // namespace system
173 } // namespace mojo 173 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698