Luis Hector Chavez | 645501c | 2016-12-28 10:56:26 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef IPC_IPC_CHANNEL_HANDLE_H_ |
| 6 | #define IPC_IPC_CHANNEL_HANDLE_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "build/build_config.h" |
| 11 | #include "mojo/public/cpp/system/message_pipe.h" |
| 12 | |
Jay Civelli | cfc1eaa | 2017-08-21 17:18:10 -0700 | [diff] [blame] | 13 | #if defined(OS_NACL_SFI) |
Luis Hector Chavez | 645501c | 2016-12-28 10:56:26 -0800 | [diff] [blame] | 14 | #include "base/file_descriptor_posix.h" |
Jay Civelli | cfc1eaa | 2017-08-21 17:18:10 -0700 | [diff] [blame] | 15 | #endif // defined (OS_NACL_SFI) |
Luis Hector Chavez | 645501c | 2016-12-28 10:56:26 -0800 | [diff] [blame] | 16 | |
| 17 | namespace IPC { |
| 18 | |
Jay Civelli | cfc1eaa | 2017-08-21 17:18:10 -0700 | [diff] [blame] | 19 | // Note that serialization for this object is defined in the ParamTraits |
| 20 | // template specialization in ipc_message_utils.h. |
| 21 | #if defined(OS_NACL_SFI) |
Luis Hector Chavez | 645501c | 2016-12-28 10:56:26 -0800 | [diff] [blame] | 22 | struct ChannelHandle { |
Luis Hector Chavez | 645501c | 2016-12-28 10:56:26 -0800 | [diff] [blame] | 23 | ChannelHandle() {} |
Jay Civelli | cfc1eaa | 2017-08-21 17:18:10 -0700 | [diff] [blame] | 24 | explicit ChannelHandle(const base::FileDescriptor& s) : socket(s) {} |
| 25 | |
| 26 | base::FileDescriptor socket; |
| 27 | }; |
| 28 | #else |
| 29 | struct ChannelHandle { |
| 30 | ChannelHandle() {} |
Luis Hector Chavez | 645501c | 2016-12-28 10:56:26 -0800 | [diff] [blame] | 31 | ChannelHandle(mojo::MessagePipeHandle h) : mojo_handle(h) {} |
| 32 | |
Jay Civelli | cfc1eaa | 2017-08-21 17:18:10 -0700 | [diff] [blame] | 33 | bool is_mojo_channel_handle() const { return mojo_handle.is_valid(); } |
| 34 | |
Luis Hector Chavez | 645501c | 2016-12-28 10:56:26 -0800 | [diff] [blame] | 35 | mojo::MessagePipeHandle mojo_handle; |
| 36 | }; |
Jay Civelli | cfc1eaa | 2017-08-21 17:18:10 -0700 | [diff] [blame] | 37 | #endif // defined(OS_NACL_SFI) |
Luis Hector Chavez | 645501c | 2016-12-28 10:56:26 -0800 | [diff] [blame] | 38 | |
| 39 | } // namespace IPC |
| 40 | |
| 41 | #endif // IPC_IPC_CHANNEL_HANDLE_H_ |