summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk/ppb_device_ref_thunk.cc
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-21 07:54:17 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-21 07:54:17 +0000
commitdca65e16a1b85db7b2dfcd2f37bf656db553f306 (patch)
treee68f923eb74110b3194d0280ee4481958b55d91e /ppapi/thunk/ppb_device_ref_thunk.cc
parent2c9a3dca8ee47ad67ee6d8c12dc12f3c3356ca7c (diff)
downloadchromium_src-dca65e16a1b85db7b2dfcd2f37bf656db553f306.zip
chromium_src-dca65e16a1b85db7b2dfcd2f37bf656db553f306.tar.gz
chromium_src-dca65e16a1b85db7b2dfcd2f37bf656db553f306.tar.bz2
Implement PPB_DeviceRef_Dev.
This is part of the work to suppport enumeration of multiple audio/video capture devices. Relevant changes: The thread that discussed interface design - http://codereview.chromium.org/8981009/ PPB_ResourceArray_Dev (committed) - http://codereview.chromium.org/9111008/ BUG=None TEST=None Review URL: http://codereview.chromium.org/9192019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk/ppb_device_ref_thunk.cc')
-rw-r--r--ppapi/thunk/ppb_device_ref_thunk.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/ppapi/thunk/ppb_device_ref_thunk.cc b/ppapi/thunk/ppb_device_ref_thunk.cc
new file mode 100644
index 0000000..7424ca4
--- /dev/null
+++ b/ppapi/thunk/ppb_device_ref_thunk.cc
@@ -0,0 +1,46 @@
+// 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/thunk/enter.h"
+#include "ppapi/thunk/ppb_device_ref_api.h"
+#include "ppapi/thunk/thunk.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+PP_Bool IsDeviceRef(PP_Resource resource) {
+ EnterResource<PPB_DeviceRef_API> enter(resource, false);
+ return enter.succeeded() ? PP_TRUE : PP_FALSE;
+}
+
+PP_DeviceType_Dev GetType(PP_Resource device_ref) {
+ EnterResource<PPB_DeviceRef_API> enter(device_ref, true);
+ if (enter.failed())
+ return PP_DEVICETYPE_DEV_INVALID;
+ return enter.object()->GetType();
+}
+
+PP_Var GetName(PP_Resource device_ref) {
+ EnterResource<PPB_DeviceRef_API> enter(device_ref, true);
+ if (enter.failed())
+ return PP_MakeUndefined();
+ return enter.object()->GetName();
+}
+
+const PPB_DeviceRef_Dev g_ppb_device_ref_thunk = {
+ &IsDeviceRef,
+ &GetType,
+ &GetName
+};
+
+} // namespace
+
+const PPB_DeviceRef_Dev_0_1* GetPPB_DeviceRef_Dev_0_1_Thunk() {
+ return &g_ppb_device_ref_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi