blob: ef31b8434c4ef6de1c43bd4ff1afe5fa6b593920 [file] [log] [blame]
amit@chromium.org37290742012-01-24 11:36:05 +09001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
agl@chromium.org1c6dcf22009-07-23 08:57:21 +09002// 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
apatrick@chromium.orgbcd2b352010-03-06 06:53:50 +09008#include <string>
9
agl@chromium.org1c6dcf22009-07-23 08:57:21 +090010#include "build/build_config.h"
amistry70d63572016-06-27 15:34:42 +090011#include "mojo/public/cpp/system/message_pipe.h"
agl@chromium.org1c6dcf22009-07-23 08:57:21 +090012
sammc5aeaa8a2016-11-14 12:29:08 +090013#if defined(OS_NACL_SFI)
agl@chromium.org1c6dcf22009-07-23 08:57:21 +090014#include "base/file_descriptor_posix.h"
sammc5aeaa8a2016-11-14 12:29:08 +090015#endif // defined (OS_NACL_SFI)
agl@chromium.org1c6dcf22009-07-23 08:57:21 +090016
17namespace IPC {
18
sammc5aeaa8a2016-11-14 12:29:08 +090019// 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)
agl@chromium.org1c6dcf22009-07-23 08:57:21 +090022struct ChannelHandle {
agl@chromium.org1c6dcf22009-07-23 08:57:21 +090023 ChannelHandle() {}
sammc5aeaa8a2016-11-14 12:29:08 +090024 explicit ChannelHandle(const base::FileDescriptor& s) : socket(s) {}
25
26 base::FileDescriptor socket;
27};
28#else
29struct ChannelHandle {
30 ChannelHandle() {}
amistry70d63572016-06-27 15:34:42 +090031 ChannelHandle(mojo::MessagePipeHandle h) : mojo_handle(h) {}
dmaclach@chromium.org058c4a72010-12-09 04:28:09 +090032
sammc5aeaa8a2016-11-14 12:29:08 +090033 bool is_mojo_channel_handle() const { return mojo_handle.is_valid(); }
sammc14126a82016-10-18 14:48:33 +090034
amistry70d63572016-06-27 15:34:42 +090035 mojo::MessagePipeHandle mojo_handle;
agl@chromium.org1c6dcf22009-07-23 08:57:21 +090036};
sammc5aeaa8a2016-11-14 12:29:08 +090037#endif // defined(OS_NACL_SFI)
agl@chromium.org1c6dcf22009-07-23 08:57:21 +090038
39} // namespace IPC
40
41#endif // IPC_IPC_CHANNEL_HANDLE_H_