1 // Copyright 2012 The Chromium Authors 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 "build/build_config.h" 9 #include "mojo/public/cpp/system/message_pipe.h" 10 11 #if BUILDFLAG(IS_NACL) 12 #include "base/file_descriptor_posix.h" 13 #endif // defined (OS_NACL) 14 15 namespace IPC { 16 17 // Note that serialization for this object is defined in the ParamTraits 18 // template specialization in ipc_message_utils.h. 19 #if BUILDFLAG(IS_NACL) 20 struct ChannelHandle { ChannelHandleChannelHandle21 ChannelHandle() {} ChannelHandleChannelHandle22 explicit ChannelHandle(const base::FileDescriptor& s) : socket(s) {} 23 24 base::FileDescriptor socket; 25 }; 26 #else 27 struct ChannelHandle { 28 ChannelHandle() {} 29 ChannelHandle(mojo::MessagePipeHandle h) : mojo_handle(h) {} 30 31 bool is_mojo_channel_handle() const { return mojo_handle.is_valid(); } 32 33 mojo::MessagePipeHandle mojo_handle; 34 }; 35 #endif // BUILDFLAG(IS_NACL) 36 37 } // namespace IPC 38 39 #endif // IPC_IPC_CHANNEL_HANDLE_H_ 40