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

Unified Diff: ppapi/shared_impl/ppb_device_ref_shared.cc

Issue 9234064: Implement device enumeration for PPB_VideoCapture_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes in response to Antoine's comments. Created 8 years, 11 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
Index: ppapi/shared_impl/ppb_device_ref_shared.cc
diff --git a/ppapi/shared_impl/ppb_device_ref_shared.cc b/ppapi/shared_impl/ppb_device_ref_shared.cc
index edd01f2ce9051739f8f9be8cc5b4b6b997f59661..c7149245a5d44f65f51d22286f9818da0887c91f 100644
--- a/ppapi/shared_impl/ppb_device_ref_shared.cc
+++ b/ppapi/shared_impl/ppb_device_ref_shared.cc
@@ -4,7 +4,11 @@
#include "ppapi/shared_impl/ppb_device_ref_shared.h"
+#include "base/memory/scoped_ptr.h"
#include "ppapi/shared_impl/host_resource.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/ppb_resource_array_shared.h"
+#include "ppapi/shared_impl/resource_tracker.h"
#include "ppapi/shared_impl/var.h"
using ppapi::thunk::PPB_DeviceRef_API;
@@ -45,4 +49,32 @@ PP_Var PPB_DeviceRef_Shared::GetName() {
return StringVar::StringToPPVar(data_.name);
}
+// static
+PP_Resource PPB_DeviceRef_Shared::CreateResourceArray(
+ bool init_as_impl,
+ PP_Instance instance,
+ const std::vector<DeviceRefData>& devices) {
+ scoped_array<PP_Resource> elements;
+ size_t size = devices.size();
+ if (size > 0) {
+ elements.reset(new PP_Resource[size]);
+ for (size_t index = 0; index < size; ++index) {
+ PPB_DeviceRef_Shared* device_object = init_as_impl ?
+ new PPB_DeviceRef_Shared(InitAsImpl(), instance, devices[index]):
+ new PPB_DeviceRef_Shared(InitAsProxy(), instance, devices[index]);
+ elements[index] = device_object->GetReference();
+ }
+ }
+ PPB_ResourceArray_Shared* array_object = init_as_impl ?
+ new PPB_ResourceArray_Shared(PPB_ResourceArray_Shared::InitAsImpl(),
+ instance, elements.get(), size) :
+ new PPB_ResourceArray_Shared(PPB_ResourceArray_Shared::InitAsProxy(),
+ instance, elements.get(), size);
+
+ for (size_t index = 0; index < size; ++index)
+ PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(elements[index]);
+
+ return array_object->GetReference();
+}
+
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698