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

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

Issue 11274036: Refactor video capture to new design (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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
OLDNEW
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 "content/renderer/pepper/pepper_flash_host.h" 5 #include "content/renderer/pepper/pepper_flash_host.h"
6 6
7 #include <vector>
8
9 #include "content/public/renderer/renderer_ppapi_host.h" 7 #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 8
23 namespace content { 9 namespace content {
24 10
25 PepperFlashHost::PepperFlashHost( 11 PepperFlashHost::PepperFlashHost(
26 RendererPpapiHost* host, 12 RendererPpapiHost* host,
27 PP_Instance instance, 13 PP_Instance instance,
28 PP_Resource resource) 14 PP_Resource resource)
29 : ResourceHost(host->GetPpapiHost(), instance, resource), 15 : ResourceHost(host->GetPpapiHost(), instance, resource) {
30 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
31 } 16 }
32 17
33 PepperFlashHost::~PepperFlashHost() { 18 PepperFlashHost::~PepperFlashHost() {
34 } 19 }
35 20
36 int32_t PepperFlashHost::OnResourceMessageReceived(
raymes 2012/11/13 15:54:16 Please leave this here and just return PP_ERROR_FA
victorhsieh 2012/11/14 01:07:50 Done.
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_EnumerateVideoCaptureDevices,
42 OnMsgEnumerateVideoCaptureDevices)
43 IPC_END_MESSAGE_MAP()
44 return PP_ERROR_FAILED;
45 }
46
47 int32_t PepperFlashHost::OnMsgEnumerateVideoCaptureDevices(
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::OnEnumerateVideoCaptureDevicesComplete,
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::OnEnumerateVideoCaptureDevicesComplete(
65 int32_t result,
66 ppapi::host::ReplyMessageContext reply_message_context,
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();
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_EnumerateVideoCaptureDevicesReply(devices));
79 }
80
81 } // namespace content 21 } // namespace content
82
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698