| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/flash_resource.h" | 5 #include "ppapi/proxy/flash_resource.h" |
| 6 | 6 |
| 7 #include "ipc/ipc_message.h" | 7 #include "ipc/ipc_message.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/proxy/dispatch_reply_message.h" | 9 #include "ppapi/proxy/dispatch_reply_message.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const PP_ArrayOutput& devices) { | 32 const PP_ArrayOutput& devices) { |
| 33 ArrayWriter output; | 33 ArrayWriter output; |
| 34 output.set_pp_array_output(devices); | 34 output.set_pp_array_output(devices); |
| 35 if (!output.is_valid()) | 35 if (!output.is_valid()) |
| 36 return PP_ERROR_BADARGUMENT; | 36 return PP_ERROR_BADARGUMENT; |
| 37 | 37 |
| 38 thunk::EnterResource<thunk::PPB_VideoCapture_API> enter(video_capture, true); | 38 thunk::EnterResource<thunk::PPB_VideoCapture_API> enter(video_capture, true); |
| 39 if (enter.failed()) | 39 if (enter.failed()) |
| 40 return PP_ERROR_NOINTERFACE; | 40 return PP_ERROR_NOINTERFACE; |
| 41 | 41 |
| 42 IPC::Message reply; | |
| 43 std::vector<ppapi::DeviceRefData> device_ref_data; | 42 std::vector<ppapi::DeviceRefData> device_ref_data; |
| 44 int32_t result = CallRendererSync( | 43 int32_t result = |
| 45 PpapiHostMsg_Flash_EnumerateVideoCaptureDevices( | 44 SyncCall<PpapiPluginMsg_Flash_EnumerateVideoCaptureDevicesReply>( |
| 46 enter.resource()->host_resource()), &reply); | 45 RENDERER, |
| 46 PpapiHostMsg_Flash_EnumerateVideoCaptureDevices( |
| 47 enter.resource()->host_resource()), |
| 48 &device_ref_data); |
| 47 if (result != PP_OK) | 49 if (result != PP_OK) |
| 48 return result; | 50 return result; |
| 49 PpapiPluginMsg_Flash_EnumerateVideoCaptureDevicesReply::Schema::Param p; | |
| 50 if (!PpapiPluginMsg_Flash_EnumerateVideoCaptureDevicesReply::Read(&reply, &p)) | |
| 51 return PP_ERROR_FAILED; | |
| 52 device_ref_data = p.a; | |
| 53 | 51 |
| 54 std::vector<scoped_refptr<Resource> > device_resources; | 52 std::vector<scoped_refptr<Resource> > device_resources; |
| 55 for (size_t i = 0; i < device_ref_data.size(); ++i) { | 53 for (size_t i = 0; i < device_ref_data.size(); ++i) { |
| 56 scoped_refptr<Resource> resource(new PPB_DeviceRef_Shared( | 54 scoped_refptr<Resource> resource(new PPB_DeviceRef_Shared( |
| 57 OBJECT_IS_PROXY, instance, device_ref_data[i])); | 55 OBJECT_IS_PROXY, instance, device_ref_data[i])); |
| 58 device_resources.push_back(resource); | 56 device_resources.push_back(resource); |
| 59 } | 57 } |
| 60 | 58 |
| 61 if (!output.StoreResourceVector(device_resources)) | 59 if (!output.StoreResourceVector(device_resources)) |
| 62 return PP_ERROR_FAILED; | 60 return PP_ERROR_FAILED; |
| 63 | 61 |
| 64 return PP_OK; | 62 return PP_OK; |
| 65 } | 63 } |
| 66 | 64 |
| 67 } // namespace proxy | 65 } // namespace proxy |
| 68 } // namespace ppapi | 66 } // namespace ppapi |
| OLD | NEW |