| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 void HandleWriter(int* handle_index, | 47 void HandleWriter(int* handle_index, |
| 48 IPC::Message* m, | 48 IPC::Message* m, |
| 49 const ppapi::proxy::SerializedHandle& handle) { | 49 const ppapi::proxy::SerializedHandle& handle) { |
| 50 WriteHandle((*handle_index)++, handle, m); | 50 WriteHandle((*handle_index)++, handle, m); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void ConvertHandlesInParam(const ppapi::proxy::SerializedVar& var, | 53 void ConvertHandlesInParam(const ppapi::proxy::SerializedVar& var, |
| 54 Handles* handles, | 54 Handles* handles, |
| 55 IPC::Message* msg, | 55 IPC::Message* msg, |
| 56 int* handle_index) { | 56 int* handle_index) { |
| 57 if (!var.raw_var_data()) | 57 std::vector<ppapi::proxy::SerializedHandle*> var_handles = var.GetHandles(); |
| 58 return; | |
| 59 | |
| 60 std::vector<ppapi::proxy::SerializedHandle*> var_handles = | |
| 61 var.raw_var_data()->GetHandles(); | |
| 62 if (var_handles.empty()) | 58 if (var_handles.empty()) |
| 63 return; | 59 return; |
| 64 | 60 |
| 65 for (size_t i = 0; i < var_handles.size(); ++i) | 61 for (size_t i = 0; i < var_handles.size(); ++i) |
| 66 handles->push_back(*var_handles[i]); | 62 handles->push_back(*var_handles[i]); |
| 67 if (msg) | 63 if (msg) |
| 68 var.raw_var_data()->Write(msg, base::Bind(&HandleWriter, handle_index)); | 64 var.WriteDataToMessage(msg, base::Bind(&HandleWriter, handle_index)); |
| 69 } | 65 } |
| 70 | 66 |
| 71 // For PpapiMsg_ResourceReply and the reply to PpapiHostMsg_ResourceSyncCall, | 67 // For PpapiMsg_ResourceReply and the reply to PpapiHostMsg_ResourceSyncCall, |
| 72 // the handles are carried inside the ResourceMessageReplyParams. | 68 // the handles are carried inside the ResourceMessageReplyParams. |
| 73 // NOTE: We only translate handles from host->NaCl. The only kind of | 69 // NOTE: We only translate handles from host->NaCl. The only kind of |
| 74 // ResourceMessageParams that travels this direction is | 70 // ResourceMessageParams that travels this direction is |
| 75 // ResourceMessageReplyParams, so that's the only one we need to handle. | 71 // ResourceMessageReplyParams, so that's the only one we need to handle. |
| 76 void ConvertHandlesInParam( | 72 void ConvertHandlesInParam( |
| 77 const ppapi::proxy::ResourceMessageReplyParams& params, | 73 const ppapi::proxy::ResourceMessageReplyParams& params, |
| 78 Handles* handles, | 74 Handles* handles, |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 DCHECK(msg.is_sync()); | 275 DCHECK(msg.is_sync()); |
| 280 | 276 |
| 281 int msg_id = IPC::SyncMessage::GetMessageId(msg); | 277 int msg_id = IPC::SyncMessage::GetMessageId(msg); |
| 282 DCHECK(pending_sync_msgs_.find(msg_id) == pending_sync_msgs_.end()); | 278 DCHECK(pending_sync_msgs_.find(msg_id) == pending_sync_msgs_.end()); |
| 283 | 279 |
| 284 pending_sync_msgs_[msg_id] = msg.type(); | 280 pending_sync_msgs_[msg_id] = msg.type(); |
| 285 } | 281 } |
| 286 | 282 |
| 287 } // namespace proxy | 283 } // namespace proxy |
| 288 } // namespace ppapi | 284 } // namespace ppapi |
| OLD | NEW |