Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: mojo/edk/system/broker_messages.h

Issue 1555273002: [mojo] Add CreateSharedBuffer method to Broker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // Sandbox processes need the parent's help to create shared buffers.
20 // They are sent synchronously from child to parent and each have
21 // a response. They are sent over a raw pipe.
22 enum SandboxMessages {
Anand Mistry (off Chromium) 2016/01/07 04:36:33 Not your fault, but these should have a uint32_t s
Eliot Courtney 2016/01/07 05:01:30 Acknowledged.
19 #if defined(OS_WIN) 23 #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 {
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 #else
31 // The reply is a PlatformHandle.
32 CREATE_SHARED_BUFFER = 0,
33 #endif
30 }; 34 };
31 35
32 // Definitions of the raw bytes sent in messages. 36 // Definitions of the raw bytes sent in messages.
33 37
34 struct BrokerMessage { 38 struct BrokerMessage {
35 uint32_t size; 39 uint32_t size;
36 WindowsSandboxMessages id; 40 SandboxMessages id;
41
42 #if defined(OS_WIN)
37 // Data, if any, follows. 43 // Data, if any, follows.
38 union { 44 union {
39 HANDLE handles[1]; // If HANDLE_TO_TOKEN. 45 HANDLE handles[1]; // If HANDLE_TO_TOKEN.
40 uint64_t tokens[1]; // If TOKEN_TO_HANDLE. 46 uint64_t tokens[1]; // If TOKEN_TO_HANDLE.
41 }; 47 };
48 #else
49 uint32_t num_bytes; // Size of the shared buffer to create.
Anand Mistry (off Chromium) 2016/01/07 04:36:33 Maybe call it shared_buffer_size instead. num_byte
Eliot Courtney 2016/01/07 05:01:30 Done.
50 #endif
42 }; 51 };
43 52
44 const int kBrokerMessageHeaderSize = 53 const int kBrokerMessageHeaderSize = sizeof(uint32_t) + sizeof(SandboxMessages);
45 sizeof(uint32_t) + sizeof(WindowsSandboxMessages);
46
47 #endif
48 54
49 // Route id used for messages between ChildBroker and ChildBrokerHost. 55 // Route id used for messages between ChildBroker and ChildBrokerHost.
50 const uint64_t kBrokerRouteId = 1; 56 const uint64_t kBrokerRouteId = 1;
51 57
52 // Multiplexing related messages. They are all asynchronous messages. 58 // Multiplexing related messages. They are all asynchronous messages.
53 // They are sent over RawChannel. 59 // They are sent over RawChannel.
54 enum MultiplexMessages { 60 enum MultiplexMessages {
55 // Messages from child to parent. 61 // Messages from child to parent.
56 CONNECT_MESSAGE_PIPE = 0, 62 CONNECT_MESSAGE_PIPE = 0,
57 CANCEL_CONNECT_MESSAGE_PIPE, 63 CANCEL_CONNECT_MESSAGE_PIPE,
(...skipping 18 matching lines...) Expand all
76 struct PeerPipeConnectedMessage { 82 struct PeerPipeConnectedMessage {
77 MultiplexMessages type; // PEER_PIPE_CONNECTED 83 MultiplexMessages type; // PEER_PIPE_CONNECTED
78 uint64_t pipe_id; 84 uint64_t pipe_id;
79 base::ProcessId process_id; 85 base::ProcessId process_id;
80 }; 86 };
81 87
82 } // namespace edk 88 } // namespace edk
83 } // namespace mojo 89 } // namespace mojo
84 90
85 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_ 91 #endif // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698