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 = |
Tom Sepez
2015/12/03 23:35:28
Actually, this hasn't been 100% correct since it d
jam
2015/12/04 00:43:47
This is only used on Windows and there's no paddin
| |
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. | |
Tom Sepez
2015/12/03 23:35:28
nit: indent.
jam
2015/12/04 00:43:47
i had meant to put it like this to separate out bo
| |
53 CONNECT_MESSAGE_PIPE = 0, | |
54 CANCEL_CONNECT_MESSAGE_PIPE, | |
55 // Messages from parent to child. | |
56 CONNECT_TO_PROCESS, | |
57 PEER_PIPE_CONNECTED, | |
58 }; | |
59 | |
60 struct ConnectMessagePipeMessage { | |
61 // CONNECT_MESSAGE_PIPE or CANCEL_CONNECT_MESSAGE_PIPE | |
62 MultiplexMessages type; | |
63 uint64_t pipe_id; | |
64 }; | |
65 | |
66 struct ConnectToProcessMessage { | |
67 MultiplexMessages type; // CONNECT_TO_PROCESS | |
68 base::ProcessId process_id; | |
69 // Also has an attached platform handle. | |
70 }; | |
71 | |
72 struct PeerPipeConnectedMessage { | |
73 MultiplexMessages type; // PEER_PIPE_CONNECTED | |
74 uint64_t pipe_id; | |
75 base::ProcessId process_id; | |
76 }; | |
42 | 77 |
43 } // namespace edk | 78 } // namespace edk |
44 } // namespace mojo | 79 } // namespace mojo |
45 | 80 |
46 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ | 81 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ |
OLD | NEW |