| 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 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 namespace edk { | 13 namespace edk { |
| 14 | 14 |
| 15 // This header defines the message format between ChildBroker and | 15 // This header defines the message format between ChildBroker and |
| 16 // ChildBrokerHost. | 16 // ChildBrokerHost. |
| 17 | 17 |
| 18 enum MessageId { | 18 enum MessageId { |
| 19 // The reply is two HANDLEs. | 19 // The reply is two HANDLEs. |
| 20 CREATE_PLATFORM_CHANNEL_PAIR = 0, | 20 CREATE_PLATFORM_CHANNEL_PAIR = 0, |
| 21 // The reply is tokens of the same count of passed in handles. | 21 // The reply is tokens of the same count of passed in handles. |
| 22 HANDLE_TO_TOKEN, | 22 HANDLE_TO_TOKEN, |
| 23 // The reply is handles of the same count of passed in tokens. | 23 // The reply is handles of the same count of passed in tokens. |
| 24 TOKEN_TO_HANDLE, | 24 TOKEN_TO_HANDLE, |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 // Definitions of the raw bytes sent in messages. | 27 // Definitions of the raw bytes sent in messages. |
| 28 | 28 |
| 29 struct ALIGNAS(4) BrokerMessage { | 29 struct BrokerMessage { |
| 30 uint32_t size; | 30 uint32_t size; |
| 31 MessageId id; | 31 MessageId id; |
| 32 // Data, if any, follows. | 32 // Data, if any, follows. |
| 33 union { | 33 union { |
| 34 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 35 HANDLE handles[1]; // If HANDLE_TO_TOKEN. | 35 HANDLE handles[1]; // If HANDLE_TO_TOKEN. |
| 36 uint64_t tokens[1]; // If TOKEN_TO_HANDLE. | 36 uint64_t tokens[1]; // If TOKEN_TO_HANDLE. |
| 37 #endif | 37 #endif |
| 38 }; | 38 }; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 const int kBrokerMessageHeaderSize = sizeof(uint32_t) + sizeof(MessageId); | 41 const int kBrokerMessageHeaderSize = sizeof(uint32_t) + sizeof(MessageId); |
| 42 | 42 |
| 43 } // namespace edk | 43 } // namespace edk |
| 44 } // namespace mojo | 44 } // namespace mojo |
| 45 | 45 |
| 46 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ | 46 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ |
| OLD | NEW |