erikchen | fdd43fe | 2015-07-08 07:13:11 +0900 | [diff] [blame] | 1 | // 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 | |
erikchen | 3155dee | 2015-07-28 05:28:20 +0900 | [diff] [blame] | 8 | #include "base/process/process_handle.h" |
avi | 42ebda4 | 2015-12-22 11:39:04 +0900 | [diff] [blame] | 9 | #include "build/build_config.h" |
erikchen | fdd43fe | 2015-07-08 07:13:11 +0900 | [diff] [blame] | 10 | #include "ipc/brokerable_attachment.h" |
erikchen | da5404b | 2015-07-15 10:35:39 +0900 | [diff] [blame] | 11 | #include "ipc/ipc_export.h" |
erikchen | fdd43fe | 2015-07-08 07:13:11 +0900 | [diff] [blame] | 12 | #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 | |
erikchen | 19419b7 | 2015-10-07 04:59:39 +0900 | [diff] [blame] | 18 | #if defined(OS_MACOSX) |
| 19 | #include "ipc/mach_port_attachment_mac.h" |
| 20 | #endif // defined(OS_MACOSX) |
| 21 | |
erikchen | fdd43fe | 2015-07-08 07:13:11 +0900 | [diff] [blame] | 22 | // ---------------------------------------------------------------------------- |
| 23 | // Serialization of structs. |
| 24 | // ---------------------------------------------------------------------------- |
| 25 | |
| 26 | #if defined(OS_WIN) |
erikchen | e6605e7 | 2015-08-12 06:17:47 +0900 | [diff] [blame] | 27 | // Define the serialization for Permissions. |
| 28 | IPC_ENUM_TRAITS_MAX_VALUE(HandleWin::Permissions, HandleWin::MAX_PERMISSIONS); |
| 29 | |
erikchen | fdd43fe | 2015-07-08 07:13:11 +0900 | [diff] [blame] | 30 | IPC_STRUCT_TRAITS_BEGIN(IPC::internal::HandleAttachmentWin::WireFormat) |
Daniel Cheng | 784e89c | 2015-07-17 06:44:58 +0900 | [diff] [blame] | 31 | IPC_STRUCT_TRAITS_MEMBER(handle) |
| 32 | IPC_STRUCT_TRAITS_MEMBER(destination_process) |
erikchen | e6605e7 | 2015-08-12 06:17:47 +0900 | [diff] [blame] | 33 | IPC_STRUCT_TRAITS_MEMBER(permissions) |
Daniel Cheng | 784e89c | 2015-07-17 06:44:58 +0900 | [diff] [blame] | 34 | IPC_STRUCT_TRAITS_MEMBER(attachment_id) |
erikchen | fdd43fe | 2015-07-08 07:13:11 +0900 | [diff] [blame] | 35 | IPC_STRUCT_TRAITS_END() |
| 36 | #endif // defined(OS_WIN) |
| 37 | |
erikchen | 19419b7 | 2015-10-07 04:59:39 +0900 | [diff] [blame] | 38 | #if defined(OS_MACOSX) |
| 39 | IPC_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) |
| 43 | IPC_STRUCT_TRAITS_END() |
| 44 | #endif // defined(OS_MACOSX) |
| 45 | |
erikchen | da5404b | 2015-07-15 10:35:39 +0900 | [diff] [blame] | 46 | #undef IPC_MESSAGE_EXPORT |
| 47 | #define IPC_MESSAGE_EXPORT IPC_EXPORT |
erikchen | fdd43fe | 2015-07-08 07:13:11 +0900 | [diff] [blame] | 48 | #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. |
| 58 | IPC_MESSAGE_CONTROL1( |
| 59 | AttachmentBrokerMsg_WinHandleHasBeenDuplicated, |
| 60 | IPC::internal::HandleAttachmentWin::WireFormat /* wire_format */) |
| 61 | #endif // defined(OS_WIN) |
| 62 | |
erikchen | 19419b7 | 2015-10-07 04:59:39 +0900 | [diff] [blame] | 63 | #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. |
| 68 | IPC_MESSAGE_CONTROL1( |
| 69 | AttachmentBrokerMsg_MachPortHasBeenDuplicated, |
| 70 | IPC::internal::MachPortAttachmentMac::WireFormat /* wire_format */) |
| 71 | #endif // defined(OS_MACOSX) |
| 72 | |
erikchen | fdd43fe | 2015-07-08 07:13:11 +0900 | [diff] [blame] | 73 | // ---------------------------------------------------------------------------- |
| 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). |
erikchen | cc6ccfc | 2015-07-29 08:16:48 +0900 | [diff] [blame] | 81 | IPC_MESSAGE_CONTROL1( |
erikchen | fdd43fe | 2015-07-08 07:13:11 +0900 | [diff] [blame] | 82 | AttachmentBrokerMsg_DuplicateWinHandle, |
erikchen | cc6ccfc | 2015-07-29 08:16:48 +0900 | [diff] [blame] | 83 | IPC::internal::HandleAttachmentWin::WireFormat /* wire_format */) |
erikchen | fdd43fe | 2015-07-08 07:13:11 +0900 | [diff] [blame] | 84 | #endif // defined(OS_WIN) |
erikchen | 19419b7 | 2015-10-07 04:59:39 +0900 | [diff] [blame] | 85 | |
| 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). |
| 90 | IPC_MESSAGE_CONTROL1( |
| 91 | AttachmentBrokerMsg_DuplicateMachPort, |
| 92 | IPC::internal::MachPortAttachmentMac::WireFormat /* wire_format */) |
| 93 | #endif // defined(OS_MACOSX) |