| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ | 5 #ifndef MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ |
| 6 #define MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ | 6 #define MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/process/process_handle.h" |
| 11 | 12 |
| 12 namespace mojo { | 13 namespace mojo { |
| 13 namespace edk { | 14 namespace edk { |
| 14 | 15 |
| 15 // This header defines the message format between ChildBroker and | 16 // This header defines the message format between ChildBroker and |
| 16 // ChildBrokerHost. | 17 // ChildBrokerHost. |
| 17 | 18 |
| 18 enum MessageId { | 19 #if defined(OS_WIN) |
| 20 // Windows only messages needed because sandboxed child processes need the |
| 21 // parent's help. They are sent synchronously from child to parent and each have |
| 22 // a response. They are sent over a raw pipe. |
| 23 enum WindowsSandboxMessages { |
| 19 // The reply is two HANDLEs. | 24 // The reply is two HANDLEs. |
| 20 CREATE_PLATFORM_CHANNEL_PAIR = 0, | 25 CREATE_PLATFORM_CHANNEL_PAIR = 0, |
| 21 // The reply is tokens of the same count of passed in handles. | 26 // The reply is tokens of the same count of passed in handles. |
| 22 HANDLE_TO_TOKEN, | 27 HANDLE_TO_TOKEN, |
| 23 // The reply is handles of the same count of passed in tokens. | 28 // The reply is handles of the same count of passed in tokens. |
| 24 TOKEN_TO_HANDLE, | 29 TOKEN_TO_HANDLE, |
| 25 }; | 30 }; |
| 26 | 31 |
| 27 // Definitions of the raw bytes sent in messages. | 32 // Definitions of the raw bytes sent in messages. |
| 28 | 33 |
| 29 struct BrokerMessage { | 34 struct BrokerMessage { |
| 30 uint32_t size; | 35 uint32_t size; |
| 31 MessageId id; | 36 WindowsSandboxMessages id; |
| 32 // Data, if any, follows. | 37 // Data, if any, follows. |
| 33 union { | 38 union { |
| 34 #if defined(OS_WIN) | |
| 35 HANDLE handles[1]; // If HANDLE_TO_TOKEN. | 39 HANDLE handles[1]; // If HANDLE_TO_TOKEN. |
| 36 uint64_t tokens[1]; // If TOKEN_TO_HANDLE. | 40 uint64_t tokens[1]; // If TOKEN_TO_HANDLE. |
| 37 #endif | |
| 38 }; | 41 }; |
| 39 }; | 42 }; |
| 40 | 43 |
| 41 const int kBrokerMessageHeaderSize = sizeof(uint32_t) + sizeof(MessageId); | 44 const int kBrokerMessageHeaderSize = |
| 45 sizeof(uint32_t) + sizeof(WindowsSandboxMessages); |
| 46 |
| 47 #endif |
| 48 |
| 49 // Multiplexing related messages. They are all asynchronous messages. |
| 50 // They are sent over RawChannel. |
| 51 enum MultiplexMessages { |
| 52 // Messages from child to parent. |
| 53 CONNECT_MESSAGE_PIPE = 0, |
| 54 CANCEL_CONNECT_MESSAGE_PIPE, |
| 55 |
| 56 // Messages from parent to child. |
| 57 CONNECT_TO_PROCESS, |
| 58 PEER_PIPE_CONNECTED, |
| 59 }; |
| 60 |
| 61 struct ConnectMessagePipeMessage { |
| 62 // CONNECT_MESSAGE_PIPE or CANCEL_CONNECT_MESSAGE_PIPE |
| 63 MultiplexMessages type; |
| 64 uint64_t pipe_id; |
| 65 }; |
| 66 |
| 67 struct ConnectToProcessMessage { |
| 68 MultiplexMessages type; // CONNECT_TO_PROCESS |
| 69 base::ProcessId process_id; |
| 70 // Also has an attached platform handle. |
| 71 }; |
| 72 |
| 73 struct PeerPipeConnectedMessage { |
| 74 MultiplexMessages type; // PEER_PIPE_CONNECTED |
| 75 uint64_t pipe_id; |
| 76 base::ProcessId process_id; |
| 77 }; |
| 42 | 78 |
| 43 } // namespace edk | 79 } // namespace edk |
| 44 } // namespace mojo | 80 } // namespace mojo |
| 45 | 81 |
| 46 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ | 82 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ |
| OLD | NEW |