xref: /aosp_15_r20/external/libchrome/ipc/ipc_channel_handle.h (revision 635a864187cb8b6c713ff48b7e790a6b21769273)
1*635a8641SAndroid Build Coastguard Worker // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file.
4*635a8641SAndroid Build Coastguard Worker 
5*635a8641SAndroid Build Coastguard Worker #ifndef IPC_IPC_CHANNEL_HANDLE_H_
6*635a8641SAndroid Build Coastguard Worker #define IPC_IPC_CHANNEL_HANDLE_H_
7*635a8641SAndroid Build Coastguard Worker 
8*635a8641SAndroid Build Coastguard Worker #include <string>
9*635a8641SAndroid Build Coastguard Worker 
10*635a8641SAndroid Build Coastguard Worker #include "build/build_config.h"
11*635a8641SAndroid Build Coastguard Worker #include "mojo/public/cpp/system/message_pipe.h"
12*635a8641SAndroid Build Coastguard Worker 
13*635a8641SAndroid Build Coastguard Worker #if defined(OS_NACL_SFI)
14*635a8641SAndroid Build Coastguard Worker #include "base/file_descriptor_posix.h"
15*635a8641SAndroid Build Coastguard Worker #endif  // defined (OS_NACL_SFI)
16*635a8641SAndroid Build Coastguard Worker 
17*635a8641SAndroid Build Coastguard Worker namespace IPC {
18*635a8641SAndroid Build Coastguard Worker 
19*635a8641SAndroid Build Coastguard Worker // Note that serialization for this object is defined in the ParamTraits
20*635a8641SAndroid Build Coastguard Worker // template specialization in ipc_message_utils.h.
21*635a8641SAndroid Build Coastguard Worker #if defined(OS_NACL_SFI)
22*635a8641SAndroid Build Coastguard Worker struct ChannelHandle {
ChannelHandleChannelHandle23*635a8641SAndroid Build Coastguard Worker   ChannelHandle() {}
ChannelHandleChannelHandle24*635a8641SAndroid Build Coastguard Worker   explicit ChannelHandle(const base::FileDescriptor& s) : socket(s) {}
25*635a8641SAndroid Build Coastguard Worker 
26*635a8641SAndroid Build Coastguard Worker   base::FileDescriptor socket;
27*635a8641SAndroid Build Coastguard Worker };
28*635a8641SAndroid Build Coastguard Worker #else
29*635a8641SAndroid Build Coastguard Worker struct ChannelHandle {
30*635a8641SAndroid Build Coastguard Worker   ChannelHandle() {}
31*635a8641SAndroid Build Coastguard Worker   ChannelHandle(mojo::MessagePipeHandle h) : mojo_handle(h) {}
32*635a8641SAndroid Build Coastguard Worker 
33*635a8641SAndroid Build Coastguard Worker   bool is_mojo_channel_handle() const { return mojo_handle.is_valid(); }
34*635a8641SAndroid Build Coastguard Worker 
35*635a8641SAndroid Build Coastguard Worker   mojo::MessagePipeHandle mojo_handle;
36*635a8641SAndroid Build Coastguard Worker };
37*635a8641SAndroid Build Coastguard Worker #endif  // defined(OS_NACL_SFI)
38*635a8641SAndroid Build Coastguard Worker 
39*635a8641SAndroid Build Coastguard Worker }  // namespace IPC
40*635a8641SAndroid Build Coastguard Worker 
41*635a8641SAndroid Build Coastguard Worker #endif  // IPC_IPC_CHANNEL_HANDLE_H_
42