Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: ppapi/proxy/flash_resource.cc

Issue 11039012: Implement plugin side of sync EnumerateVideoCaptureDevices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/flash_resource.h ('k') | ppapi/proxy/flash_resource_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ppapi/proxy/flash_resource.h"
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"
11 #include "ppapi/shared_impl/array_writer.h"
12 #include "ppapi/thunk/enter.h"
13
14 namespace ppapi {
15 namespace proxy {
16
17 FlashResource::FlashResource(Connection connection, PP_Instance instance)
18 : PluginResource(connection, instance) {
19 SendCreateToRenderer(PpapiHostMsg_Flash_Create());
20 }
21
22 FlashResource::~FlashResource() {
23 }
24
25 thunk::PPB_Flash_Functions_API* FlashResource::AsPPB_Flash_Functions_API() {
26 return this;
27 }
28
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::EnterResource<thunk::PPB_VideoCapture_API> enter(video_capture, true);
39 if (enter.failed())
40 return PP_ERROR_NOINTERFACE;
41
42 IPC::Message reply;
43 std::vector<ppapi::DeviceRefData> device_ref_data;
44 int32_t result = CallRendererSync(
45 PpapiHostMsg_Flash_EnumerateVideoCaptureDevices(
46 enter.resource()->host_resource()), &reply);
47 if (result != PP_OK)
48 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
54 std::vector<scoped_refptr<Resource> > device_resources;
55 for (size_t i = 0; i < device_ref_data.size(); ++i) {
56 scoped_refptr<Resource> resource(new PPB_DeviceRef_Shared(
57 OBJECT_IS_PROXY, instance, device_ref_data[i]));
58 device_resources.push_back(resource);
59 }
60
61 if (!output.StoreResourceVector(device_resources))
62 return PP_ERROR_FAILED;
63
64 return PP_OK;
65 }
66
67 } // namespace proxy
68 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/flash_resource.h ('k') | ppapi/proxy/flash_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698