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 #include "base/process/process_handle.h" |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 namespace edk { | 14 namespace edk { |
15 | 15 |
16 // Pack all structs here. | 16 // Pack all structs here. |
17 #pragma pack(push, 1) | 17 #pragma pack(push, 1) |
18 | 18 |
19 // This header defines the message format between ChildBroker and | 19 // This header defines the message format between ChildBroker and |
20 // ChildBrokerHost. | 20 // ChildBrokerHost. |
21 | 21 |
22 // Sandbox processes need the parent's help to create shared buffers. | 22 #if defined(OS_WIN) |
23 // They are sent synchronously from child to parent and each have | 23 // Windows only messages needed because sandboxed child processes need the |
| 24 // parent's help. They are sent synchronously from child to parent and each have |
24 // a response. They are sent over a raw pipe. | 25 // a response. They are sent over a raw pipe. |
25 enum SandboxMessages : uint32_t { | 26 enum WindowsSandboxMessages : uint32_t { |
26 #if defined(OS_WIN) | |
27 // The reply is two HANDLEs. | 27 // The reply is two HANDLEs. |
28 CREATE_PLATFORM_CHANNEL_PAIR = 0, | 28 CREATE_PLATFORM_CHANNEL_PAIR = 0, |
29 // The reply is tokens of the same count of passed in handles. | 29 // The reply is tokens of the same count of passed in handles. |
30 HANDLE_TO_TOKEN, | 30 HANDLE_TO_TOKEN, |
31 // The reply is handles of the same count of passed in tokens. | 31 // The reply is handles of the same count of passed in tokens. |
32 TOKEN_TO_HANDLE, | 32 TOKEN_TO_HANDLE, |
33 #else | |
34 // The reply is a PlatformHandle. | |
35 CREATE_SHARED_BUFFER = 0, | |
36 #endif | |
37 }; | 33 }; |
38 | 34 |
39 // Definitions of the raw bytes sent in messages. | 35 // Definitions of the raw bytes sent in messages. |
40 | 36 |
41 struct BrokerMessage { | 37 struct BrokerMessage { |
42 uint32_t size; | 38 uint32_t size; |
43 SandboxMessages id; | 39 WindowsSandboxMessages id; |
44 | |
45 #if defined(OS_WIN) | |
46 // Data, if any, follows. | 40 // Data, if any, follows. |
47 union { | 41 union { |
48 HANDLE handles[1]; // If HANDLE_TO_TOKEN. | 42 HANDLE handles[1]; // If HANDLE_TO_TOKEN. |
49 uint64_t tokens[1]; // If TOKEN_TO_HANDLE. | 43 uint64_t tokens[1]; // If TOKEN_TO_HANDLE. |
50 }; | 44 }; |
51 #else | |
52 uint32_t shared_buffer_size; // Size of the shared buffer to create. | |
53 #endif | |
54 }; | 45 }; |
55 | 46 |
56 const int kBrokerMessageHeaderSize = sizeof(uint32_t) + sizeof(SandboxMessages); | 47 const int kBrokerMessageHeaderSize = |
| 48 sizeof(uint32_t) + sizeof(WindowsSandboxMessages); |
| 49 |
| 50 #endif |
57 | 51 |
58 // Route id used for messages between ChildBroker and ChildBrokerHost. | 52 // Route id used for messages between ChildBroker and ChildBrokerHost. |
59 const uint64_t kBrokerRouteId = 1; | 53 const uint64_t kBrokerRouteId = 1; |
60 | 54 |
61 // Multiplexing related messages. They are all asynchronous messages. | 55 // Multiplexing related messages. They are all asynchronous messages. |
62 // They are sent over RawChannel. | 56 // They are sent over RawChannel. |
63 enum MultiplexMessages : uint32_t { | 57 enum MultiplexMessages : uint32_t { |
64 // Messages from child to parent. | 58 // Messages from child to parent. |
65 | 59 |
66 // Tells the parent that the given pipe id has been bound to a | 60 // Tells the parent that the given pipe id has been bound to a |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 MultiplexMessages type; // PEER_DIED | 105 MultiplexMessages type; // PEER_DIED |
112 uint64_t pipe_id; | 106 uint64_t pipe_id; |
113 }; | 107 }; |
114 | 108 |
115 #pragma pack(pop) | 109 #pragma pack(pop) |
116 | 110 |
117 } // namespace edk | 111 } // namespace edk |
118 } // namespace mojo | 112 } // namespace mojo |
119 | 113 |
120 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ | 114 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ |
OLD | NEW |