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