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