OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_NACL_LOADER_NACL_IPC_ADAPTER_H_ | 5 #ifndef COMPONENTS_NACL_LOADER_NACL_IPC_ADAPTER_H_ |
6 #define COMPONENTS_NACL_LOADER_NACL_IPC_ADAPTER_H_ | 6 #define COMPONENTS_NACL_LOADER_NACL_IPC_ADAPTER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 class RewrittenMessage; | 146 class RewrittenMessage; |
147 | 147 |
148 // This is the data that must only be accessed inside the lock. This struct | 148 // This is the data that must only be accessed inside the lock. This struct |
149 // just separates it so it's easier to see. | 149 // just separates it so it's easier to see. |
150 struct LockedData { | 150 struct LockedData { |
151 LockedData(); | 151 LockedData(); |
152 ~LockedData(); | 152 ~LockedData(); |
153 | 153 |
154 // Messages that we have read off of the Chrome IPC channel that are waiting | 154 // Messages that we have read off of the Chrome IPC channel that are waiting |
155 // to be received by the plugin. | 155 // to be received by the plugin. |
156 std::queue< scoped_refptr<RewrittenMessage> > to_be_received_; | 156 std::queue<std::unique_ptr<RewrittenMessage>> to_be_received_; |
157 | 157 |
158 ppapi::proxy::NaClMessageScanner nacl_msg_scanner_; | 158 ppapi::proxy::NaClMessageScanner nacl_msg_scanner_; |
159 | 159 |
160 // Data that we've queued from the plugin to send, but doesn't consist of a | 160 // Data that we've queued from the plugin to send, but doesn't consist of a |
161 // full message yet. The calling code can break apart the message into | 161 // full message yet. The calling code can break apart the message into |
162 // smaller pieces, and we need to send the message to the other process in | 162 // smaller pieces, and we need to send the message to the other process in |
163 // one chunk. | 163 // one chunk. |
164 // | 164 // |
165 // The IPC channel always starts a new send() at the beginning of each | 165 // The IPC channel always starts a new send() at the beginning of each |
166 // message, so we don't need to worry about arbitrary message boundaries. | 166 // message, so we don't need to worry about arbitrary message boundaries. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // for future use which we don't want. | 203 // for future use which we don't want. |
204 void ClearToBeSent(); | 204 void ClearToBeSent(); |
205 | 205 |
206 void ConnectChannelOnIOThread(); | 206 void ConnectChannelOnIOThread(); |
207 void CloseChannelOnIOThread(); | 207 void CloseChannelOnIOThread(); |
208 void SendMessageOnIOThread(std::unique_ptr<IPC::Message> message); | 208 void SendMessageOnIOThread(std::unique_ptr<IPC::Message> message); |
209 | 209 |
210 // Saves the message to forward to NaCl. This method assumes that the caller | 210 // Saves the message to forward to NaCl. This method assumes that the caller |
211 // holds the lock for locked_data_. | 211 // holds the lock for locked_data_. |
212 void SaveMessage(const IPC::Message& message, | 212 void SaveMessage(const IPC::Message& message, |
213 RewrittenMessage* rewritten_message); | 213 std::unique_ptr<RewrittenMessage> rewritten_message); |
214 | 214 |
215 base::Lock lock_; | 215 base::Lock lock_; |
216 base::ConditionVariable cond_var_; | 216 base::ConditionVariable cond_var_; |
217 | 217 |
218 scoped_refptr<base::TaskRunner> task_runner_; | 218 scoped_refptr<base::TaskRunner> task_runner_; |
219 | 219 |
220 ResolveFileTokenCallback resolve_file_token_cb_; | 220 ResolveFileTokenCallback resolve_file_token_cb_; |
221 OpenResourceCallback open_resource_cb_; | 221 OpenResourceCallback open_resource_cb_; |
222 | 222 |
223 // To be accessed inside of lock_ only. | 223 // To be accessed inside of lock_ only. |
224 LockedData locked_data_; | 224 LockedData locked_data_; |
225 | 225 |
226 // To be accessed on the I/O thread (via task runner) only. | 226 // To be accessed on the I/O thread (via task runner) only. |
227 IOThreadData io_thread_data_; | 227 IOThreadData io_thread_data_; |
228 | 228 |
229 DISALLOW_COPY_AND_ASSIGN(NaClIPCAdapter); | 229 DISALLOW_COPY_AND_ASSIGN(NaClIPCAdapter); |
230 }; | 230 }; |
231 | 231 |
232 // Export TranslatePepperFileReadWriteOpenFlags for testing. | 232 // Export TranslatePepperFileReadWriteOpenFlags for testing. |
233 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags); | 233 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags); |
234 | 234 |
235 #endif // COMPONENTS_NACL_LOADER_NACL_IPC_ADAPTER_H_ | 235 #endif // COMPONENTS_NACL_LOADER_NACL_IPC_ADAPTER_H_ |
OLD | NEW |