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

Side by Side Diff: content/renderer/pepper/pepper_flash_host.cc

Issue 11016007: Implement host 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
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 "content/renderer/pepper/pepper_flash_host.h"
6
7 #include <vector>
8
9 #include "content/public/renderer/renderer_ppapi_host.h"
10 #include "ipc/ipc_message_macros.h"
11 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/host/dispatch_host_message.h"
13 #include "ppapi/host/ppapi_host.h"
14 #include "ppapi/proxy/enter_proxy.h"
15 #include "ppapi/proxy/ppapi_messages.h"
16 #include "ppapi/proxy/resource_message_params.h"
17 #include "ppapi/thunk/ppb_video_capture_api.h"
18
19 using ppapi::proxy::EnterHostFromHostResource;
20 using ppapi::proxy::EnterHostFromHostResourceForceCallback;
21 using ppapi::thunk::PPB_VideoCapture_API;
22
23 namespace content {
24
25 PepperFlashHost::PepperFlashHost(
26 RendererPpapiHost* host,
27 PP_Instance instance,
28 PP_Resource resource)
29 : ResourceHost(host->GetPpapiHost(), instance, resource),
30 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
31 }
32
33 PepperFlashHost::~PepperFlashHost() {
34 }
35
36 int32_t PepperFlashHost::OnResourceMessageReceived(
37 const IPC::Message& msg,
38 ppapi::host::HostMessageContext* context) {
39 IPC_BEGIN_MESSAGE_MAP(PepperFlashHost, msg)
40 PPAPI_DISPATCH_HOST_RESOURCE_CALL(
41 PpapiHostMsg_Flash_EnumerateVideoDevicesSync,
42 OnMsgEnumerateVideoDevicesSync)
43 IPC_END_MESSAGE_MAP()
44 return PP_ERROR_FAILED;
45 }
46
47 int32_t PepperFlashHost::OnMsgEnumerateVideoDevicesSync(
48 ppapi::host::HostMessageContext* host_context,
49 const ppapi::HostResource& host_resource) {
50 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter(
51 host_resource, callback_factory_,
52 &PepperFlashHost::OnEnumerateVideoDevicesComplete,
53 host_context->MakeReplyMessageContext(),
54 host_resource);
55 if (enter.succeeded()) {
56 // We don't want the output to go into a PP_ResourceArray (which is
57 // deprecated), so just pass in NULL. We'll grab the DeviceRefData vector
58 // in the callback and convert it to a PP_ArrayOutput in the plugin.
59 enter.SetResult(enter.object()->EnumerateDevices(NULL, enter.callback()));
60 }
61 return PP_OK_COMPLETIONPENDING;
62 }
63
64 void PepperFlashHost::OnEnumerateVideoDevicesComplete(
65 int32_t result,
66 ppapi::host::ReplyMessageContext reply_message_context,
yzshen1 2012/10/10 18:17:39 wrong indent.
raymes 2012/10/11 18:39:26 Done.
67 const ppapi::HostResource& host_resource) {
68 std::vector<ppapi::DeviceRefData> devices;
69 if (result == PP_OK) {
70 EnterHostFromHostResource<PPB_VideoCapture_API> enter(host_resource);
71 if (enter.succeeded())
72 devices = enter.object()->GetDeviceRefData();
yzshen1 2012/10/10 18:17:39 nit, optional: it seems nice to avoid this copy.
raymes 2012/10/11 18:39:26 Done.
73 else
74 result = PP_ERROR_FAILED;
75 }
76 reply_message_context.params.set_result(result);
77 host()->SendReply(reply_message_context,
78 PpapiPluginMsg_Flash_EnumerateVideoDevicesSyncReply(devices));
79 }
80
81 } // namespace content
82
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698