| 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" | |
| 8 #include "ppapi/c/pp_errors.h" | |
| 9 #include "ppapi/proxy/dispatch_reply_message.h" | |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 7 #include "ppapi/proxy/ppapi_messages.h" |
| 11 #include "ppapi/shared_impl/array_writer.h" | |
| 12 #include "ppapi/thunk/enter.h" | |
| 13 | 8 |
| 14 namespace ppapi { | 9 namespace ppapi { |
| 15 namespace proxy { | 10 namespace proxy { |
| 16 | 11 |
| 17 FlashResource::FlashResource(Connection connection, PP_Instance instance) | 12 FlashResource::FlashResource(Connection connection, PP_Instance instance) |
| 18 : PluginResource(connection, instance) { | 13 : PluginResource(connection, instance) { |
| 19 SendCreate(RENDERER, PpapiHostMsg_Flash_Create()); | 14 SendCreate(RENDERER, PpapiHostMsg_Flash_Create()); |
| 20 } | 15 } |
| 21 | 16 |
| 22 FlashResource::~FlashResource() { | 17 FlashResource::~FlashResource() { |
| 23 } | 18 } |
| 24 | 19 |
| 25 thunk::PPB_Flash_Functions_API* FlashResource::AsPPB_Flash_Functions_API() { | 20 thunk::PPB_Flash_Functions_API* FlashResource::AsPPB_Flash_Functions_API() { |
| 26 return this; | 21 return this; |
| 27 } | 22 } |
| 28 | 23 |
| 29 int32_t FlashResource::EnumerateVideoCaptureDevices( | |
| 30 PP_Instance instance, | |
| 31 PP_Resource video_capture, | |
| 32 const PP_ArrayOutput& devices) { | |
| 33 ArrayWriter output; | |
| 34 output.set_pp_array_output(devices); | |
| 35 if (!output.is_valid()) | |
| 36 return PP_ERROR_BADARGUMENT; | |
| 37 | |
| 38 thunk::EnterResourceNoLock<thunk::PPB_VideoCapture_API> enter(video_capture, | |
| 39 true); | |
| 40 if (enter.failed()) | |
| 41 return PP_ERROR_NOINTERFACE; | |
| 42 | |
| 43 std::vector<ppapi::DeviceRefData> device_ref_data; | |
| 44 int32_t result = | |
| 45 SyncCall<PpapiPluginMsg_Flash_EnumerateVideoCaptureDevicesReply>( | |
| 46 RENDERER, | |
| 47 PpapiHostMsg_Flash_EnumerateVideoCaptureDevices( | |
| 48 enter.resource()->host_resource()), | |
| 49 &device_ref_data); | |
| 50 if (result != PP_OK) | |
| 51 return result; | |
| 52 | |
| 53 std::vector<scoped_refptr<Resource> > device_resources; | |
| 54 for (size_t i = 0; i < device_ref_data.size(); ++i) { | |
| 55 scoped_refptr<Resource> resource(new PPB_DeviceRef_Shared( | |
| 56 OBJECT_IS_PROXY, instance, device_ref_data[i])); | |
| 57 device_resources.push_back(resource); | |
| 58 } | |
| 59 | |
| 60 if (!output.StoreResourceVector(device_resources)) | |
| 61 return PP_ERROR_FAILED; | |
| 62 | |
| 63 return PP_OK; | |
| 64 } | |
| 65 | |
| 66 } // namespace proxy | 24 } // namespace proxy |
| 67 } // namespace ppapi | 25 } // namespace ppapi |
| OLD | NEW |