| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ipc/mojo/ipc_mojo_handle_attachment.h" | 5 #include "ipc/mojo/ipc_mojo_handle_attachment.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ipc/ipc_message_attachment_set.h" | 10 #include "ipc/ipc_message_attachment_set.h" |
| 11 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 11 #include "mojo/edk/embedder/embedder.h" |
| 12 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 12 | 13 |
| 13 namespace IPC { | 14 namespace IPC { |
| 14 namespace internal { | 15 namespace internal { |
| 15 | 16 |
| 16 MojoHandleAttachment::MojoHandleAttachment(mojo::ScopedHandle handle) | 17 MojoHandleAttachment::MojoHandleAttachment(mojo::ScopedHandle handle) |
| 17 : handle_(std::move(handle)) {} | 18 : handle_(std::move(handle)) {} |
| 18 | 19 |
| 19 MojoHandleAttachment::~MojoHandleAttachment() { | 20 MojoHandleAttachment::~MojoHandleAttachment() { |
| 20 } | 21 } |
| 21 | 22 |
| 22 MessageAttachment::Type MojoHandleAttachment::GetType() const { | 23 MessageAttachment::Type MojoHandleAttachment::GetType() const { |
| 23 return TYPE_MOJO_HANDLE; | 24 return TYPE_MOJO_HANDLE; |
| 24 } | 25 } |
| 25 | 26 |
| 26 #if defined(OS_POSIX) | 27 #if defined(OS_POSIX) |
| 27 base::PlatformFile MojoHandleAttachment::TakePlatformFile() { | 28 base::PlatformFile MojoHandleAttachment::TakePlatformFile() { |
| 28 mojo::embedder::ScopedPlatformHandle platform_handle; | 29 mojo::edk::ScopedPlatformHandle platform_handle; |
| 29 MojoResult unwrap_result = mojo::embedder::PassWrappedPlatformHandle( | 30 MojoResult unwrap_result = mojo::edk::PassWrappedPlatformHandle( |
| 30 handle_.get().value(), &platform_handle); | 31 handle_.get().value(), &platform_handle); |
| 31 handle_.reset(); | 32 handle_.reset(); |
| 32 if (unwrap_result != MOJO_RESULT_OK) { | 33 if (unwrap_result != MOJO_RESULT_OK) { |
| 33 LOG(ERROR) << "Pipe failed to covert handles. Closing: " << unwrap_result; | 34 LOG(ERROR) << "Pipe failed to covert handles. Closing: " << unwrap_result; |
| 34 return -1; | 35 return -1; |
| 35 } | 36 } |
| 36 | 37 |
| 37 return platform_handle.release().fd; | 38 return platform_handle.release().handle; |
| 38 } | 39 } |
| 39 #endif // OS_POSIX | 40 #endif // OS_POSIX |
| 40 | 41 |
| 41 mojo::ScopedHandle MojoHandleAttachment::TakeHandle() { | 42 mojo::ScopedHandle MojoHandleAttachment::TakeHandle() { |
| 42 return std::move(handle_); | 43 return std::move(handle_); |
| 43 } | 44 } |
| 44 | 45 |
| 45 } // namespace internal | 46 } // namespace internal |
| 46 } // namespace IPC | 47 } // namespace IPC |
| OLD | NEW |