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 43f758f3b72991cdb85d20dde56395a21b1c905e..15a3a7bfcef48698ab4f85aa2d72e6f4f15d21a8 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; |
@@ -38,4 +42,28 @@ PP_Var PPB_DeviceRef_Shared::GetName() { |
return StringVar::StringToPPVar(data_.name); |
} |
+// static |
+PP_Resource PPB_DeviceRef_Shared::CreateResourceArray( |
+ ResourceObjectType type, |
+ 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 = |
+ new PPB_DeviceRef_Shared(type, instance, devices[index]); |
+ elements[index] = device_object->GetReference(); |
+ } |
+ } |
+ PPB_ResourceArray_Shared* array_object = |
+ new PPB_ResourceArray_Shared(type, instance, elements.get(), size); |
+ |
+ for (size_t index = 0; index < size; ++index) |
+ PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(elements[index]); |
+ |
+ return array_object->GetReference(); |
+} |
+ |
} // namespace ppapi |