blob: a6301c2da134f18be82d5563b5e8f2a54be774ba [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"
erikchenfdd43fe2015-07-08 07:13:11 +09009#include "ipc/brokerable_attachment.h"
erikchenda5404b2015-07-15 10:35:39 +090010#include "ipc/ipc_export.h"
erikchenfdd43fe2015-07-08 07:13:11 +090011#include "ipc/ipc_message_macros.h"
12
13#if defined(OS_WIN)
14#include "ipc/handle_attachment_win.h"
15#endif // defined(OS_WIN)
16
erikchen19419b72015-10-07 04:59:39 +090017#if defined(OS_MACOSX)
18#include "ipc/mach_port_attachment_mac.h"
19#endif // defined(OS_MACOSX)
20
erikchenfdd43fe2015-07-08 07:13:11 +090021// ----------------------------------------------------------------------------
22// Serialization of structs.
23// ----------------------------------------------------------------------------
24
25#if defined(OS_WIN)
erikchene6605e72015-08-12 06:17:47 +090026// Define the serialization for Permissions.
27IPC_ENUM_TRAITS_MAX_VALUE(HandleWin::Permissions, HandleWin::MAX_PERMISSIONS);
28
erikchenfdd43fe2015-07-08 07:13:11 +090029IPC_STRUCT_TRAITS_BEGIN(IPC::internal::HandleAttachmentWin::WireFormat)
Daniel Cheng784e89c2015-07-17 06:44:58 +090030 IPC_STRUCT_TRAITS_MEMBER(handle)
31 IPC_STRUCT_TRAITS_MEMBER(destination_process)
erikchene6605e72015-08-12 06:17:47 +090032 IPC_STRUCT_TRAITS_MEMBER(permissions)
Daniel Cheng784e89c2015-07-17 06:44:58 +090033 IPC_STRUCT_TRAITS_MEMBER(attachment_id)
erikchenfdd43fe2015-07-08 07:13:11 +090034IPC_STRUCT_TRAITS_END()
35#endif // defined(OS_WIN)
36
erikchen19419b72015-10-07 04:59:39 +090037#if defined(OS_MACOSX)
38IPC_STRUCT_TRAITS_BEGIN(IPC::internal::MachPortAttachmentMac::WireFormat)
39 IPC_STRUCT_TRAITS_MEMBER(mach_port)
40 IPC_STRUCT_TRAITS_MEMBER(destination_process)
41 IPC_STRUCT_TRAITS_MEMBER(attachment_id)
42IPC_STRUCT_TRAITS_END()
43#endif // defined(OS_MACOSX)
44
erikchenda5404b2015-07-15 10:35:39 +090045#undef IPC_MESSAGE_EXPORT
46#define IPC_MESSAGE_EXPORT IPC_EXPORT
erikchenfdd43fe2015-07-08 07:13:11 +090047#define IPC_MESSAGE_START AttachmentBrokerMsgStart
48
49// ----------------------------------------------------------------------------
50// Messages sent from the broker to a non-broker process.
51// ----------------------------------------------------------------------------
52
53#if defined(OS_WIN)
54// Sent from a broker to a non-broker to indicate that a windows HANDLE has been
55// brokered. Contains all information necessary for the non-broker to translate
56// a BrokerAttachment::AttachmentId to a BrokerAttachment.
57IPC_MESSAGE_CONTROL1(
58 AttachmentBrokerMsg_WinHandleHasBeenDuplicated,
59 IPC::internal::HandleAttachmentWin::WireFormat /* wire_format */)
60#endif // defined(OS_WIN)
61
erikchen19419b72015-10-07 04:59:39 +090062#if defined(OS_MACOSX)
63// Sent from a broker process to a non-broker process to indicate that an OSX
64// Mach port has been duplicated. Contains all information necessary for the
65// non-broker process to translate a BrokerAttachment::AttachmentId to a
66// BrokerAttachment.
67IPC_MESSAGE_CONTROL1(
68 AttachmentBrokerMsg_MachPortHasBeenDuplicated,
69 IPC::internal::MachPortAttachmentMac::WireFormat /* wire_format */)
70#endif // defined(OS_MACOSX)
71
erikchenfdd43fe2015-07-08 07:13:11 +090072// ----------------------------------------------------------------------------
73// Messages sent from a non-broker process to a broker process.
74// ----------------------------------------------------------------------------
75
76#if defined(OS_WIN)
77// Sent from a non-broker to a broker to request the duplication of a HANDLE
78// into a different process (possibly the broker process, or even the original
79// process).
erikchencc6ccfc2015-07-29 08:16:48 +090080IPC_MESSAGE_CONTROL1(
erikchenfdd43fe2015-07-08 07:13:11 +090081 AttachmentBrokerMsg_DuplicateWinHandle,
erikchencc6ccfc2015-07-29 08:16:48 +090082 IPC::internal::HandleAttachmentWin::WireFormat /* wire_format */)
erikchenfdd43fe2015-07-08 07:13:11 +090083#endif // defined(OS_WIN)
erikchen19419b72015-10-07 04:59:39 +090084
85#if defined(OS_MACOSX)
86// Sent from a non-broker process to a broker process to request the duplication
87// of a Mach port into a different process (possibly the broker process, or even
88// the original process).
89IPC_MESSAGE_CONTROL1(
90 AttachmentBrokerMsg_DuplicateMachPort,
91 IPC::internal::MachPortAttachmentMac::WireFormat /* wire_format */)
92#endif // defined(OS_MACOSX)