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

Unified Diff: ppapi/cpp/dev/resource_array_dev.cc

Issue 9965080: Change the cpp wrappers of audio input/video capture to use CompletionCallbackWithOutput. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More changes in response to Brett's comments. Created 8 years, 9 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
« no previous file with comments | « ppapi/cpp/dev/resource_array_dev.h ('k') | ppapi/cpp/dev/video_capture_dev.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/resource_array_dev.cc
diff --git a/ppapi/cpp/dev/resource_array_dev.cc b/ppapi/cpp/dev/resource_array_dev.cc
index 6a8493fc6d3cabc60848b644b14c437acee5b5a2..5bd2549326469ebbd5687841ffceeead17cbb604 100644
--- a/ppapi/cpp/dev/resource_array_dev.cc
+++ b/ppapi/cpp/dev/resource_array_dev.cc
@@ -5,7 +5,10 @@
#include "ppapi/cpp/dev/resource_array_dev.h"
#include "ppapi/c/dev/ppb_resource_array_dev.h"
+#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/logging.h"
+#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace pp {
@@ -59,4 +62,31 @@ PP_Resource ResourceArray_Dev::operator[](uint32_t index) const {
return get_interface<PPB_ResourceArray_Dev>()->GetAt(pp_resource(), index);
}
+// static
+void ResourceArray_Dev::ArrayOutputCallbackConverter(void* user_data,
+ int32_t result) {
+ ArrayOutputCallbackData* data =
+ static_cast<ArrayOutputCallbackData*>(user_data);
+
+ // data->resource_array_output should remain 0 if the call failed.
+ ResourceArray_Dev resources(PASS_REF, data->resource_array_output);
+ PP_DCHECK(resources.is_null() || result == PP_OK);
+
+ // Need to issue the "GetDataBuffer" even for error cases and when the number
+ // of items is 0.
+ PP_Resource* output_buf = static_cast<PP_Resource*>(
+ data->output.GetDataBuffer(
+ data->output.user_data, resources.is_null() ? 0 : resources.size(),
+ sizeof(PP_Resource)));
+ if (output_buf) {
+ for (uint32_t index = 0; index < resources.size(); ++index) {
+ output_buf[index] = resources[index];
+ Module::Get()->core()->AddRefResource(output_buf[index]);
+ }
+ }
+
+ PP_RunCompletionCallback(&data->original_callback, result);
+ delete data;
+}
+
} // namespace pp
« no previous file with comments | « ppapi/cpp/dev/resource_array_dev.h ('k') | ppapi/cpp/dev/video_capture_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698