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
3 // found in the LICENSE file.
5 #ifndef PPAPI_CPP_DEV_RESOURCE_ARRAY_DEV_H_
6 #define PPAPI_CPP_DEV_RESOURCE_ARRAY_DEV_H_
8 #include "ppapi/c/pp_array_output.h"
9 #include "ppapi/c/pp_completion_callback.h"
10 #include "ppapi/c/pp_stdint.h"
11 #include "ppapi/cpp/resource.h"
17 class ResourceArray_Dev
: public Resource
{
19 // Heap-allocated data passed to ArrayOutputCallbackConverter(). Please see
20 // the comment of ArrayOutputCallbackConverter() for more details.
21 struct ArrayOutputCallbackData
{
22 ArrayOutputCallbackData(const PP_ArrayOutput
& array_output
,
23 const PP_CompletionCallback
& callback
)
24 : resource_array_output(0),
26 original_callback(callback
) {
29 PP_Resource resource_array_output
;
30 PP_ArrayOutput output
;
31 PP_CompletionCallback original_callback
;
36 ResourceArray_Dev(PassRef
, PP_Resource resource
);
38 ResourceArray_Dev(const ResourceArray_Dev
& other
);
40 ResourceArray_Dev(const InstanceHandle
& instance
,
41 const PP_Resource elements
[],
44 virtual ~ResourceArray_Dev();
46 ResourceArray_Dev
& operator=(const ResourceArray_Dev
& other
);
48 uint32_t size() const;
50 PP_Resource
operator[](uint32_t index
) const;
52 // This is an adapter for backward compatibility. It works with those APIs
53 // which take a PPB_ResourceArray_Dev resource as output parameter, and
54 // returns results using PP_ArrayOutput. For example:
56 // ResourceArray_Dev::ArrayOutputCallbackData* data =
57 // new ResourceArray_Dev::ArrayOutputCallbackData(
58 // pp_array_output, callback);
60 // foo_resource, &data->resource_array_output,
61 // PP_MakeCompletionCallback(
62 // &ResourceArray_Dev::ArrayOutputCallbackConverter, data));
64 // It takes a heap-allocated ArrayOutputCallbackData struct passed as the user
65 // data, and deletes it when the call completes.
66 static void ArrayOutputCallbackConverter(void* user_data
, int32_t result
);
71 #endif // PPAPI_CPP_DEV_RESOURCE_ARRAY_DEV_H_