blob: d27062ed6a2954c4d621287607d6231fcf4fe375 [file] [log] [blame]
erikchenfdd43fe2015-07-08 07:13:11 +09001// Copyright 2015 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// IPC messages used by the attachment broker.
6// Multiply-included message file, hence no include guard.
7
erikchen3155dee2015-07-28 05:28:20 +09008#include "base/process/process_handle.h"
avi42ebda42015-12-22 11:39:04 +09009#include "build/build_config.h"
erikchenfdd43fe2015-07-08 07:13:11 +090010#include "ipc/brokerable_attachment.h"
erikchenda5404b2015-07-15 10:35:39 +090011#include "ipc/ipc_export.h"
erikchenfdd43fe2015-07-08 07:13:11 +090012#include "ipc/ipc_message_macros.h"
13
14#if defined(OS_WIN)
15#include "ipc/handle_attachment_win.h"
16#endif // defined(OS_WIN)
17
erikchen19419b72015-10-07 04:59:39 +090018#if defined(OS_MACOSX)
19#include "ipc/mach_port_attachment_mac.h"
20#endif // defined(OS_MACOSX)
21
erikchenfdd43fe2015-07-08 07:13:11 +090022// ----------------------------------------------------------------------------
23// Serialization of structs.
24// ----------------------------------------------------------------------------
25
26#if defined(OS_WIN)
erikchene6605e72015-08-12 06:17:47 +090027// Define the serialization for Permissions.
28IPC_ENUM_TRAITS_MAX_VALUE(HandleWin::Permissions, HandleWin::MAX_PERMISSIONS);
29
erikchenfdd43fe2015-07-08 07:13:11 +090030IPC_STRUCT_TRAITS_BEGIN(IPC::internal::HandleAttachmentWin::WireFormat)
Daniel Cheng784e89c2015-07-17 06:44:58 +090031 IPC_STRUCT_TRAITS_MEMBER(handle)
32 IPC_STRUCT_TRAITS_MEMBER(destination_process)
erikchene6605e72015-08-12 06:17:47 +090033 IPC_STRUCT_TRAITS_MEMBER(permissions)
Daniel Cheng784e89c2015-07-17 06:44:58 +090034 IPC_STRUCT_TRAITS_MEMBER(attachment_id)
erikchenfdd43fe2015-07-08 07:13:11 +090035IPC_STRUCT_TRAITS_END()
36#endif // defined(OS_WIN)
37
erikchen19419b72015-10-07 04:59:39 +090038#if defined(OS_MACOSX)
39IPC_STRUCT_TRAITS_BEGIN(IPC::internal::MachPortAttachmentMac::WireFormat)
40 IPC_STRUCT_TRAITS_MEMBER(mach_port)
41 IPC_STRUCT_TRAITS_MEMBER(destination_process)
42 IPC_STRUCT_TRAITS_MEMBER(attachment_id)
43IPC_STRUCT_TRAITS_END()
44#endif // defined(OS_MACOSX)
45
erikchenda5404b2015-07-15 10:35:39 +090046#undef IPC_MESSAGE_EXPORT
47#define IPC_MESSAGE_EXPORT IPC_EXPORT
erikchenfdd43fe2015-07-08 07:13:11 +090048#define IPC_MESSAGE_START AttachmentBrokerMsgStart
49
50// ----------------------------------------------------------------------------
51// Messages sent from the broker to a non-broker process.
52// ----------------------------------------------------------------------------
53
54#if defined(OS_WIN)
55// Sent from a broker to a non-broker to indicate that a windows HANDLE has been
56// brokered. Contains all information necessary for the non-broker to translate
57// a BrokerAttachment::AttachmentId to a BrokerAttachment.
58IPC_MESSAGE_CONTROL1(
59 AttachmentBrokerMsg_WinHandleHasBeenDuplicated,
60 IPC::internal::HandleAttachmentWin::WireFormat /* wire_format */)
61#endif // defined(OS_WIN)
62
erikchen19419b72015-10-07 04:59:39 +090063#if defined(OS_MACOSX)
64// Sent from a broker process to a non-broker process to indicate that an OSX
65// Mach port has been duplicated. Contains all information necessary for the
66// non-broker process to translate a BrokerAttachment::AttachmentId to a
67// BrokerAttachment.
68IPC_MESSAGE_CONTROL1(
69 AttachmentBrokerMsg_MachPortHasBeenDuplicated,
70 IPC::internal::MachPortAttachmentMac::WireFormat /* wire_format */)
71#endif // defined(OS_MACOSX)
72
erikchenfdd43fe2015-07-08 07:13:11 +090073// ----------------------------------------------------------------------------
74// Messages sent from a non-broker process to a broker process.
75// ----------------------------------------------------------------------------
76
77#if defined(OS_WIN)
78// Sent from a non-broker to a broker to request the duplication of a HANDLE
79// into a different process (possibly the broker process, or even the original
80// process).
erikchencc6ccfc2015-07-29 08:16:48 +090081IPC_MESSAGE_CONTROL1(
erikchenfdd43fe2015-07-08 07:13:11 +090082 AttachmentBrokerMsg_DuplicateWinHandle,
erikchencc6ccfc2015-07-29 08:16:48 +090083 IPC::internal::HandleAttachmentWin::WireFormat /* wire_format */)
erikchenfdd43fe2015-07-08 07:13:11 +090084#endif // defined(OS_WIN)
erikchen19419b72015-10-07 04:59:39 +090085
86#if defined(OS_MACOSX)
87// Sent from a non-broker process to a broker process to request the duplication
88// of a Mach port into a different process (possibly the broker process, or even
89// the original process).
90IPC_MESSAGE_CONTROL1(
91 AttachmentBrokerMsg_DuplicateMachPort,
92 IPC::internal::MachPortAttachmentMac::WireFormat /* wire_format */)
93#endif // defined(OS_MACOSX)