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_CHILD_BROKER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_CHILD_BROKER_H_ |
6 #define MOJO_EDK_SYSTEM_CHILD_BROKER_H_ | 6 #define MOJO_EDK_SYSTEM_CHILD_BROKER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 // Broker implementation: | 39 // Broker implementation: |
40 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
41 void CreatePlatformChannelPair(ScopedPlatformHandle* server, | 41 void CreatePlatformChannelPair(ScopedPlatformHandle* server, |
42 ScopedPlatformHandle* client) override; | 42 ScopedPlatformHandle* client) override; |
43 void HandleToToken(const PlatformHandle* platform_handles, | 43 void HandleToToken(const PlatformHandle* platform_handles, |
44 size_t count, | 44 size_t count, |
45 uint64_t* tokens) override; | 45 uint64_t* tokens) override; |
46 void TokenToHandle(const uint64_t* tokens, | 46 void TokenToHandle(const uint64_t* tokens, |
47 size_t count, | 47 size_t count, |
48 PlatformHandle* handles) override; | 48 PlatformHandle* handles) override; |
| 49 #else |
| 50 scoped_refptr<PlatformSharedBuffer> CreateSharedBuffer( |
| 51 size_t num_bytes) override; |
49 #endif | 52 #endif |
| 53 |
50 void ConnectMessagePipe(uint64_t pipe_id, | 54 void ConnectMessagePipe(uint64_t pipe_id, |
51 MessagePipeDispatcher* message_pipe) override; | 55 MessagePipeDispatcher* message_pipe) override; |
52 void CloseMessagePipe(uint64_t pipe_id, | 56 void CloseMessagePipe(uint64_t pipe_id, |
53 MessagePipeDispatcher* message_pipe) override; | 57 MessagePipeDispatcher* message_pipe) override; |
54 | 58 |
55 private: | 59 private: |
56 friend struct base::DefaultSingletonTraits<ChildBroker>; | 60 friend struct base::DefaultSingletonTraits<ChildBroker>; |
57 | 61 |
58 ChildBroker(); | 62 ChildBroker(); |
59 ~ChildBroker() override; | 63 ~ChildBroker() override; |
(...skipping 20 matching lines...) Expand all Loading... |
80 | 84 |
81 #if defined(OS_WIN) | 85 #if defined(OS_WIN) |
82 // Helper method to write the given message and read back the result. | 86 // Helper method to write the given message and read back the result. |
83 bool WriteAndReadResponse(BrokerMessage* message, | 87 bool WriteAndReadResponse(BrokerMessage* message, |
84 void* response, | 88 void* response, |
85 uint32_t response_size); | 89 uint32_t response_size); |
86 | 90 |
87 void CreatePlatformChannelPairNoLock(ScopedPlatformHandle* server, | 91 void CreatePlatformChannelPairNoLock(ScopedPlatformHandle* server, |
88 ScopedPlatformHandle* client); | 92 ScopedPlatformHandle* client); |
89 | 93 |
| 94 #else |
| 95 // Will fully write |message|, then read back some number of handles. Returns |
| 96 // false if the write or read failed, or if there were no handles received. |
| 97 bool WriteAndReadHandles(BrokerMessage* message, |
| 98 std::deque<PlatformHandle>* handles); |
| 99 #endif |
| 100 |
90 // Guards access to |parent_sync_channel_|. | 101 // Guards access to |parent_sync_channel_|. |
91 // We use LockImpl instead of Lock because the latter adds thread checking | 102 // We use LockImpl instead of Lock because the latter adds thread checking |
92 // that we don't want (since we lock in the constructor and unlock on another | 103 // that we don't want (since we lock in the constructor and unlock on another |
93 // thread. | 104 // thread. |
94 base::internal::LockImpl sync_channel_lock_; | 105 base::internal::LockImpl sync_channel_lock_; |
95 | 106 |
96 // Pipe used for communication to the parent process. We use a pipe directly | 107 // Pipe used for communication to the parent process. We use a pipe directly |
97 // instead of bindings or RawChannel because we need to send synchronous | 108 // instead of bindings or RawChannel because we need to send synchronous |
98 // messages with replies from any thread. | 109 // messages with replies from any thread. |
99 ScopedPlatformHandle parent_sync_channel_; | 110 ScopedPlatformHandle parent_sync_channel_; |
100 #endif | |
101 | 111 |
102 // RawChannel used for asynchronous communication to and from the parent | 112 // RawChannel used for asynchronous communication to and from the parent |
103 // process. Since these messages are bidirectional, we can't use | 113 // process. Since these messages are bidirectional, we can't use |
104 // |parent_sync_channel_| which is only used for sync messages to the parent. | 114 // |parent_sync_channel_| which is only used for sync messages to the parent. |
105 // However since the messages are asynchronous, we can use RawChannel for | 115 // However since the messages are asynchronous, we can use RawChannel for |
106 // convenience instead of writing and reading from pipes manually. Although it | 116 // convenience instead of writing and reading from pipes manually. Although it |
107 // would be convenient, we don't use Mojo IPC because it would be a layering | 117 // would be convenient, we don't use Mojo IPC because it would be a layering |
108 // violation (and cirular dependency) if the system layer depended on | 118 // violation (and cirular dependency) if the system layer depended on |
109 // bindings. | 119 // bindings. |
110 RoutedRawChannel* parent_async_channel_; | 120 RoutedRawChannel* parent_async_channel_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 RoutedRawChannel* in_process_pipes_channel1_; | 152 RoutedRawChannel* in_process_pipes_channel1_; |
143 RoutedRawChannel* in_process_pipes_channel2_; | 153 RoutedRawChannel* in_process_pipes_channel2_; |
144 | 154 |
145 DISALLOW_COPY_AND_ASSIGN(ChildBroker); | 155 DISALLOW_COPY_AND_ASSIGN(ChildBroker); |
146 }; | 156 }; |
147 | 157 |
148 } // namespace edk | 158 } // namespace edk |
149 } // namespace mojo | 159 } // namespace mojo |
150 | 160 |
151 #endif // MOJO_EDK_SYSTEM_CHILD_BROKER_H_ | 161 #endif // MOJO_EDK_SYSTEM_CHILD_BROKER_H_ |
OLD | NEW |