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

Side by Side 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: . Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/shared_impl/ppb_device_ref_shared.h ('k') | ppapi/shared_impl/ppb_video_capture_shared.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ppapi/shared_impl/ppb_device_ref_shared.h" 5 #include "ppapi/shared_impl/ppb_device_ref_shared.h"
6 6
7 #include "base/memory/scoped_ptr.h"
7 #include "ppapi/shared_impl/host_resource.h" 8 #include "ppapi/shared_impl/host_resource.h"
9 #include "ppapi/shared_impl/ppapi_globals.h"
10 #include "ppapi/shared_impl/ppb_resource_array_shared.h"
11 #include "ppapi/shared_impl/resource_tracker.h"
8 #include "ppapi/shared_impl/var.h" 12 #include "ppapi/shared_impl/var.h"
9 13
10 using ppapi::thunk::PPB_DeviceRef_API; 14 using ppapi::thunk::PPB_DeviceRef_API;
11 15
12 namespace ppapi { 16 namespace ppapi {
13 17
14 DeviceRefData::DeviceRefData() 18 DeviceRefData::DeviceRefData()
15 : type(PP_DEVICETYPE_DEV_INVALID) { 19 : type(PP_DEVICETYPE_DEV_INVALID) {
16 } 20 }
17 21
(...skipping 13 matching lines...) Expand all
31 } 35 }
32 36
33 PP_DeviceType_Dev PPB_DeviceRef_Shared::GetType() { 37 PP_DeviceType_Dev PPB_DeviceRef_Shared::GetType() {
34 return data_.type; 38 return data_.type;
35 } 39 }
36 40
37 PP_Var PPB_DeviceRef_Shared::GetName() { 41 PP_Var PPB_DeviceRef_Shared::GetName() {
38 return StringVar::StringToPPVar(data_.name); 42 return StringVar::StringToPPVar(data_.name);
39 } 43 }
40 44
45 // static
46 PP_Resource PPB_DeviceRef_Shared::CreateResourceArray(
47 ResourceObjectType type,
48 PP_Instance instance,
49 const std::vector<DeviceRefData>& devices) {
50 scoped_array<PP_Resource> elements;
51 size_t size = devices.size();
52 if (size > 0) {
53 elements.reset(new PP_Resource[size]);
54 for (size_t index = 0; index < size; ++index) {
55 PPB_DeviceRef_Shared* device_object =
56 new PPB_DeviceRef_Shared(type, instance, devices[index]);
57 elements[index] = device_object->GetReference();
58 }
59 }
60 PPB_ResourceArray_Shared* array_object =
61 new PPB_ResourceArray_Shared(type, instance, elements.get(), size);
62
63 for (size_t index = 0; index < size; ++index)
64 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(elements[index]);
65
66 return array_object->GetReference();
67 }
68
41 } // namespace ppapi 69 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/ppb_device_ref_shared.h ('k') | ppapi/shared_impl/ppb_video_capture_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698