| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "ppapi/proxy/handle_converter.h" | 5 #include "ppapi/proxy/handle_converter.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 #include "ipc/ipc_message.h" | 8 #include "ipc/ipc_message.h" |
| 9 #include "ipc/ipc_message_macros.h" | 9 #include "ipc/ipc_message_macros.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // See ConvertHandlesImpl for how these get used. | 37 // See ConvertHandlesImpl for how these get used. |
| 38 void ConvertHandlesInParam(const ppapi::proxy::SerializedHandle& handle, | 38 void ConvertHandlesInParam(const ppapi::proxy::SerializedHandle& handle, |
| 39 Handles* handles, | 39 Handles* handles, |
| 40 IPC::Message* msg, | 40 IPC::Message* msg, |
| 41 int* handle_index) { | 41 int* handle_index) { |
| 42 handles->push_back(handle); | 42 handles->push_back(handle); |
| 43 if (msg) | 43 if (msg) |
| 44 WriteHandle((*handle_index)++, handle, msg); | 44 WriteHandle((*handle_index)++, handle, msg); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void HandleWriter(int* handle_index, |
| 48 IPC::Message* m, |
| 49 const ppapi::proxy::SerializedHandle& handle) { |
| 50 WriteHandle((*handle_index)++, handle, m); |
| 51 } |
| 52 |
| 47 void ConvertHandlesInParam(const ppapi::proxy::SerializedVar& var, | 53 void ConvertHandlesInParam(const ppapi::proxy::SerializedVar& var, |
| 48 Handles* handles, | 54 Handles* handles, |
| 49 IPC::Message* msg, | 55 IPC::Message* msg, |
| 50 int* handle_index) { | 56 int* handle_index) { |
| 51 ppapi::proxy::SerializedHandle *handle = var.GetPluginShmemHandle(); | 57 if (!var.raw_var_data()) |
| 52 if (handle) { | 58 return; |
| 53 handles->push_back(*handle); | 59 |
| 54 if (msg) { | 60 std::vector<ppapi::proxy::SerializedHandle*> var_handles = |
| 55 var.WriteRawVarHeader(msg); | 61 var.raw_var_data()->GetHandles(); |
| 56 WriteHandle((*handle_index)++, *handle, msg); | 62 if (var_handles.empty()) |
| 57 } | 63 return; |
| 58 } | 64 |
| 65 for (size_t i = 0; i < var_handles.size(); ++i) |
| 66 handles->push_back(*var_handles[i]); |
| 67 if (msg) |
| 68 var.raw_var_data()->Write(msg, base::Bind(&HandleWriter, handle_index)); |
| 59 } | 69 } |
| 60 | 70 |
| 61 // For PpapiMsg_ResourceReply and the reply to PpapiHostMsg_ResourceSyncCall, | 71 // For PpapiMsg_ResourceReply and the reply to PpapiHostMsg_ResourceSyncCall, |
| 62 // the handles are carried inside the ResourceMessageReplyParams. | 72 // the handles are carried inside the ResourceMessageReplyParams. |
| 63 // NOTE: We only translate handles from host->NaCl. The only kind of | 73 // NOTE: We only translate handles from host->NaCl. The only kind of |
| 64 // ResourceMessageParams that travels this direction is | 74 // ResourceMessageParams that travels this direction is |
| 65 // ResourceMessageReplyParams, so that's the only one we need to handle. | 75 // ResourceMessageReplyParams, so that's the only one we need to handle. |
| 66 void ConvertHandlesInParam( | 76 void ConvertHandlesInParam( |
| 67 const ppapi::proxy::ResourceMessageReplyParams& params, | 77 const ppapi::proxy::ResourceMessageReplyParams& params, |
| 68 Handles* handles, | 78 Handles* handles, |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 DCHECK(msg.is_sync()); | 279 DCHECK(msg.is_sync()); |
| 270 | 280 |
| 271 int msg_id = IPC::SyncMessage::GetMessageId(msg); | 281 int msg_id = IPC::SyncMessage::GetMessageId(msg); |
| 272 DCHECK(pending_sync_msgs_.find(msg_id) == pending_sync_msgs_.end()); | 282 DCHECK(pending_sync_msgs_.find(msg_id) == pending_sync_msgs_.end()); |
| 273 | 283 |
| 274 pending_sync_msgs_[msg_id] = msg.type(); | 284 pending_sync_msgs_[msg_id] = msg.type(); |
| 275 } | 285 } |
| 276 | 286 |
| 277 } // namespace proxy | 287 } // namespace proxy |
| 278 } // namespace ppapi | 288 } // namespace ppapi |
| OLD | NEW |