OLD | NEW |
| (Empty) |
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 #ifndef MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ | |
6 #define MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "base/process/process_handle.h" | |
12 | |
13 namespace mojo { | |
14 namespace edk { | |
15 | |
16 // Pack all structs here. | |
17 #pragma pack(push, 1) | |
18 | |
19 // This header defines the message format between ChildBroker and | |
20 // ChildBrokerHost. | |
21 | |
22 #if defined(OS_WIN) | |
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 | |
25 // a response. They are sent over a raw pipe. | |
26 enum WindowsSandboxMessages : uint32_t { | |
27 // The reply is two HANDLEs. | |
28 CREATE_PLATFORM_CHANNEL_PAIR = 0, | |
29 // The reply is tokens of the same count of passed in handles. | |
30 HANDLE_TO_TOKEN, | |
31 // The reply is handles of the same count of passed in tokens. | |
32 TOKEN_TO_HANDLE, | |
33 }; | |
34 | |
35 // Definitions of the raw bytes sent in messages. | |
36 | |
37 struct BrokerMessage { | |
38 uint32_t size; | |
39 WindowsSandboxMessages id; | |
40 // Data, if any, follows. | |
41 union { | |
42 HANDLE handles[1]; // If HANDLE_TO_TOKEN. | |
43 uint64_t tokens[1]; // If TOKEN_TO_HANDLE. | |
44 }; | |
45 }; | |
46 | |
47 const int kBrokerMessageHeaderSize = | |
48 sizeof(uint32_t) + sizeof(WindowsSandboxMessages); | |
49 | |
50 #endif | |
51 | |
52 // Route id used for messages between ChildBroker and ChildBrokerHost. | |
53 const uint64_t kBrokerRouteId = 1; | |
54 | |
55 // Multiplexing related messages. They are all asynchronous messages. | |
56 // They are sent over RawChannel. | |
57 enum MultiplexMessages : uint32_t { | |
58 // Messages from child to parent. | |
59 | |
60 // Tells the parent that the given pipe id has been bound to a | |
61 // MessagePipeDispatcher in the child process. The parent will then respond | |
62 // with either PEER_PIPE_CONNECTED or PEER_DIED when the other side is also | |
63 // bound. | |
64 CONNECT_MESSAGE_PIPE = 0, | |
65 // Tells the parent to remove its bookkeeping for the given peer id since | |
66 // another MessagePipeDispatcher has connected to the pipe in the same | |
67 // process. | |
68 CANCEL_CONNECT_MESSAGE_PIPE, | |
69 | |
70 | |
71 // Messages from parent to child. | |
72 | |
73 // Tells the child to open a channel to a given process. This will be followed | |
74 // by a PEER_PIPE_CONNECTED connecting a message pipe from the child process | |
75 // to the given process over the new channel. | |
76 CONNECT_TO_PROCESS, | |
77 | |
78 // Connect a given message pipe to another process. | |
79 PEER_PIPE_CONNECTED, | |
80 | |
81 // Informs the child that the other end of the message pipe is in a process | |
82 // that died. | |
83 PEER_DIED, | |
84 }; | |
85 | |
86 struct ConnectMessagePipeMessage { | |
87 // CONNECT_MESSAGE_PIPE or CANCEL_CONNECT_MESSAGE_PIPE | |
88 MultiplexMessages type; | |
89 uint64_t pipe_id; | |
90 }; | |
91 | |
92 struct ConnectToProcessMessage { | |
93 MultiplexMessages type; // CONNECT_TO_PROCESS | |
94 base::ProcessId process_id; | |
95 // Also has an attached platform handle. | |
96 }; | |
97 | |
98 struct PeerPipeConnectedMessage { | |
99 MultiplexMessages type; // PEER_PIPE_CONNECTED | |
100 uint64_t pipe_id; | |
101 base::ProcessId process_id; | |
102 }; | |
103 | |
104 struct PeerDiedMessage { | |
105 MultiplexMessages type; // PEER_DIED | |
106 uint64_t pipe_id; | |
107 }; | |
108 | |
109 #pragma pack(pop) | |
110 | |
111 } // namespace edk | |
112 } // namespace mojo | |
113 | |
114 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ | |
OLD | NEW |