OLD | NEW |
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 "components/arc/arc_bridge_bootstrap.h" | 5 #include "components/arc/arc_bridge_bootstrap.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <grp.h> | 8 #include <grp.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 base::ScopedFD ArcBridgeBootstrapImpl::AcceptInstanceConnection( | 246 base::ScopedFD ArcBridgeBootstrapImpl::AcceptInstanceConnection( |
247 base::ScopedFD socket_fd) { | 247 base::ScopedFD socket_fd) { |
248 int raw_fd = -1; | 248 int raw_fd = -1; |
249 if (!IPC::ServerAcceptConnection(socket_fd.get(), &raw_fd)) { | 249 if (!IPC::ServerAcceptConnection(socket_fd.get(), &raw_fd)) { |
250 return base::ScopedFD(); | 250 return base::ScopedFD(); |
251 } | 251 } |
252 base::ScopedFD scoped_fd(raw_fd); | 252 base::ScopedFD scoped_fd(raw_fd); |
253 | 253 |
254 // Hardcode pid 0 since it is unused in mojo. | 254 // Hardcode pid 0 since it is unused in mojo. |
255 const base::ProcessHandle kUnusedChildProcessHandle = 0; | 255 const base::ProcessHandle kUnusedChildProcessHandle = 0; |
256 mojo::edk::ScopedPlatformHandle child_handle = | 256 mojo::edk::PlatformChannelPair channel_pair; |
257 mojo::edk::ChildProcessLaunched(kUnusedChildProcessHandle); | 257 mojo::edk::ChildProcessLaunched(kUnusedChildProcessHandle, |
| 258 channel_pair.PassServerHandle()); |
258 | 259 |
259 mojo::edk::ScopedPlatformHandleVectorPtr handles( | 260 mojo::edk::ScopedPlatformHandleVectorPtr handles( |
260 new mojo::edk::PlatformHandleVector{child_handle.release()}); | 261 new mojo::edk::PlatformHandleVector{ |
| 262 channel_pair.PassClientHandle().release()}); |
261 | 263 |
262 struct iovec iov = {const_cast<char*>(""), 1}; | 264 struct iovec iov = {const_cast<char*>(""), 1}; |
263 ssize_t result = mojo::edk::PlatformChannelSendmsgWithHandles( | 265 ssize_t result = mojo::edk::PlatformChannelSendmsgWithHandles( |
264 mojo::edk::PlatformHandle(scoped_fd.get()), &iov, 1, handles->data(), | 266 mojo::edk::PlatformHandle(scoped_fd.get()), &iov, 1, handles->data(), |
265 handles->size()); | 267 handles->size()); |
266 if (result == -1) { | 268 if (result == -1) { |
267 PLOG(ERROR) << "sendmsg"; | 269 PLOG(ERROR) << "sendmsg"; |
268 return base::ScopedFD(); | 270 return base::ScopedFD(); |
269 } | 271 } |
270 | 272 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 } | 335 } |
334 | 336 |
335 } // namespace | 337 } // namespace |
336 | 338 |
337 // static | 339 // static |
338 std::unique_ptr<ArcBridgeBootstrap> ArcBridgeBootstrap::Create() { | 340 std::unique_ptr<ArcBridgeBootstrap> ArcBridgeBootstrap::Create() { |
339 return base::WrapUnique(new ArcBridgeBootstrapImpl()); | 341 return base::WrapUnique(new ArcBridgeBootstrapImpl()); |
340 } | 342 } |
341 | 343 |
342 } // namespace arc | 344 } // namespace arc |
OLD | NEW |