blob: ef31b8434c4ef6de1c43bd4ff1afe5fa6b593920 [file] [log] [blame]
Luis Hector Chavez645501c2016-12-28 10:56:26 -08001// 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 Civellicfc1eaa2017-08-21 17:18:10 -070013#if defined(OS_NACL_SFI)
Luis Hector Chavez645501c2016-12-28 10:56:26 -080014#include "base/file_descriptor_posix.h"
Jay Civellicfc1eaa2017-08-21 17:18:10 -070015#endif // defined (OS_NACL_SFI)
Luis Hector Chavez645501c2016-12-28 10:56:26 -080016
17namespace IPC {
18
Jay Civellicfc1eaa2017-08-21 17:18:10 -070019// 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 Chavez645501c2016-12-28 10:56:26 -080022struct ChannelHandle {
Luis Hector Chavez645501c2016-12-28 10:56:26 -080023 ChannelHandle() {}
Jay Civellicfc1eaa2017-08-21 17:18:10 -070024 explicit ChannelHandle(const base::FileDescriptor& s) : socket(s) {}
25
26 base::FileDescriptor socket;
27};
28#else
29struct ChannelHandle {
30 ChannelHandle() {}
Luis Hector Chavez645501c2016-12-28 10:56:26 -080031 ChannelHandle(mojo::MessagePipeHandle h) : mojo_handle(h) {}
32
Jay Civellicfc1eaa2017-08-21 17:18:10 -070033 bool is_mojo_channel_handle() const { return mojo_handle.is_valid(); }
34
Luis Hector Chavez645501c2016-12-28 10:56:26 -080035 mojo::MessagePipeHandle mojo_handle;
36};
Jay Civellicfc1eaa2017-08-21 17:18:10 -070037#endif // defined(OS_NACL_SFI)
Luis Hector Chavez645501c2016-12-28 10:56:26 -080038
39} // namespace IPC
40
41#endif // IPC_IPC_CHANNEL_HANDLE_H_