Chromium Code Reviews| 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 // This header defines the message format between ChildBroker and | 16 // This header defines the message format between ChildBroker and |
| 17 // ChildBrokerHost. | 17 // ChildBrokerHost. |
| 18 | 18 |
| 19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 20 // Windows only messages needed because sandboxed child processes need the | 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 | 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. | 22 // a response. They are sent over a raw pipe. |
| 23 enum WindowsSandboxMessages { | 23 enum WindowsSandboxMessages { |
|
jam
2016/01/06 02:58:16
nit: lets share the enum class type and just have
Eliot Courtney
2016/01/07 02:26:08
Done.
| |
| 24 // The reply is two HANDLEs. | 24 // The reply is two HANDLEs. |
| 25 CREATE_PLATFORM_CHANNEL_PAIR = 0, | 25 CREATE_PLATFORM_CHANNEL_PAIR = 0, |
| 26 // 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. |
| 27 HANDLE_TO_TOKEN, | 27 HANDLE_TO_TOKEN, |
| 28 // 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. |
| 29 TOKEN_TO_HANDLE, | 29 TOKEN_TO_HANDLE, |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 #else | |
| 33 // Sandbox processes need the parent's help to create shared buffers. | |
| 34 enum PosixSandboxMessages { | |
| 35 // The reply is a PlatformHandle. | |
| 36 CREATE_SHARED_BUFFER = 0 | |
| 37 }; | |
| 38 #endif | |
| 39 | |
| 32 // Definitions of the raw bytes sent in messages. | 40 // Definitions of the raw bytes sent in messages. |
| 33 | 41 |
| 34 struct BrokerMessage { | 42 struct BrokerMessage { |
| 35 uint32_t size; | 43 uint32_t size; |
| 44 #if defined(OS_WIN) | |
| 36 WindowsSandboxMessages id; | 45 WindowsSandboxMessages id; |
| 37 // Data, if any, follows. | 46 // Data, if any, follows. |
| 38 union { | 47 union { |
| 39 HANDLE handles[1]; // If HANDLE_TO_TOKEN. | 48 HANDLE handles[1]; // If HANDLE_TO_TOKEN. |
| 40 uint64_t tokens[1]; // If TOKEN_TO_HANDLE. | 49 uint64_t tokens[1]; // If TOKEN_TO_HANDLE. |
| 41 }; | 50 }; |
| 51 #else | |
| 52 PosixSandboxMessages id; | |
| 53 | |
| 54 uint32_t num_bytes; // Size of the shared buffer to create. | |
| 55 #endif | |
| 42 }; | 56 }; |
| 43 | 57 |
| 44 const int kBrokerMessageHeaderSize = | 58 const int kBrokerMessageHeaderSize = sizeof(uint32_t) + |
| 45 sizeof(uint32_t) + sizeof(WindowsSandboxMessages); | 59 #if defined(OS_WIN) |
| 46 | 60 sizeof(WindowsSandboxMessages); |
| 61 #else | |
| 62 sizeof(PosixSandboxMessages); | |
| 47 #endif | 63 #endif |
| 48 | 64 |
| 49 // Route id used for messages between ChildBroker and ChildBrokerHost. | 65 // Route id used for messages between ChildBroker and ChildBrokerHost. |
| 50 const uint64_t kBrokerRouteId = 1; | 66 const uint64_t kBrokerRouteId = 1; |
| 51 | 67 |
| 52 // Multiplexing related messages. They are all asynchronous messages. | 68 // Multiplexing related messages. They are all asynchronous messages. |
| 53 // They are sent over RawChannel. | 69 // They are sent over RawChannel. |
| 54 enum MultiplexMessages { | 70 enum MultiplexMessages { |
| 55 // Messages from child to parent. | 71 // Messages from child to parent. |
| 56 CONNECT_MESSAGE_PIPE = 0, | 72 CONNECT_MESSAGE_PIPE = 0, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 76 struct PeerPipeConnectedMessage { | 92 struct PeerPipeConnectedMessage { |
| 77 MultiplexMessages type; // PEER_PIPE_CONNECTED | 93 MultiplexMessages type; // PEER_PIPE_CONNECTED |
| 78 uint64_t pipe_id; | 94 uint64_t pipe_id; |
| 79 base::ProcessId process_id; | 95 base::ProcessId process_id; |
| 80 }; | 96 }; |
| 81 | 97 |
| 82 } // namespace edk | 98 } // namespace edk |
| 83 } // namespace mojo | 99 } // namespace mojo |
| 84 | 100 |
| 85 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ | 101 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ |
| OLD | NEW |