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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/flash_resource.h ('k') | ppapi/proxy/flash_resource_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/flash_resource.cc
diff --git a/ppapi/proxy/flash_resource.cc b/ppapi/proxy/flash_resource.cc
new file mode 100644
index 0000000000000000000000000000000000000000..62e97e16798b7559e9cf893ef115b41f102b9caa
--- /dev/null
+++ b/ppapi/proxy/flash_resource.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/proxy/flash_resource.h"
+
+#include "ipc/ipc_message.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/proxy/dispatch_reply_message.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/array_writer.h"
+#include "ppapi/thunk/enter.h"
+
+namespace ppapi {
+namespace proxy {
+
+FlashResource::FlashResource(Connection connection, PP_Instance instance)
+ : PluginResource(connection, instance) {
+ SendCreateToRenderer(PpapiHostMsg_Flash_Create());
+}
+
+FlashResource::~FlashResource() {
+}
+
+thunk::PPB_Flash_Functions_API* FlashResource::AsPPB_Flash_Functions_API() {
+ return this;
+}
+
+int32_t FlashResource::EnumerateVideoCaptureDevices(
+ PP_Instance instance,
+ PP_Resource video_capture,
+ const PP_ArrayOutput& devices) {
+ ArrayWriter output;
+ output.set_pp_array_output(devices);
+ if (!output.is_valid())
+ return PP_ERROR_BADARGUMENT;
+
+ thunk::EnterResource<thunk::PPB_VideoCapture_API> enter(video_capture, true);
+ if (enter.failed())
+ return PP_ERROR_NOINTERFACE;
+
+ IPC::Message reply;
+ std::vector<ppapi::DeviceRefData> device_ref_data;
+ int32_t result = CallRendererSync(
+ PpapiHostMsg_Flash_EnumerateVideoCaptureDevices(
+ enter.resource()->host_resource()), &reply);
+ if (result != PP_OK)
+ return result;
+ PpapiPluginMsg_Flash_EnumerateVideoCaptureDevicesReply::Schema::Param p;
+ if (!PpapiPluginMsg_Flash_EnumerateVideoCaptureDevicesReply::Read(&reply, &p))
+ return PP_ERROR_FAILED;
+ device_ref_data = p.a;
+
+ std::vector<scoped_refptr<Resource> > device_resources;
+ for (size_t i = 0; i < device_ref_data.size(); ++i) {
+ scoped_refptr<Resource> resource(new PPB_DeviceRef_Shared(
+ OBJECT_IS_PROXY, instance, device_ref_data[i]));
+ device_resources.push_back(resource);
+ }
+
+ if (!output.StoreResourceVector(device_resources))
+ return PP_ERROR_FAILED;
+
+ return PP_OK;
+}
+
+} // namespace proxy
+} // namespace ppapi
« 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