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

Unified Diff: chrome/browser/extensions/api/idltest/idltest_api.cc

Issue 10161038: Allow serialization of ArrayBuffer params in extension/apps API methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes for review feedback and browser test failures Created 8 years, 8 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: chrome/browser/extensions/api/idltest/idltest_api.cc
diff --git a/chrome/browser/extensions/api/idltest/idltest_api.cc b/chrome/browser/extensions/api/idltest/idltest_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1feff0a8cd6af633729b3b9787f795eac2b661ad
--- /dev/null
+++ b/chrome/browser/extensions/api/idltest/idltest_api.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/idltest/idltest_api.h"
+
+#include "base/values.h"
+
+using base::BinaryValue;
+
+namespace {
+
+ListValue* CopyBinaryValueToIntegerList(const BinaryValue* input) {
+ ListValue* output = new ListValue();
+ const char* input_buffer = input->GetBuffer();
+ for (size_t i = 0; i < input->GetSize(); i++) {
+ output->Append(Value::CreateIntegerValue(input_buffer[i]));
+ }
+ return output;
+}
+
+}
+
+bool IdltestSendArrayBufferFunction::RunImpl() {
+ BinaryValue* input = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input));
+ result_.reset(CopyBinaryValueToIntegerList(input));
+ return true;
+}
+
+bool IdltestSendArrayBufferViewFunction::RunImpl() {
+ BinaryValue* input = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input));
+ result_.reset(CopyBinaryValueToIntegerList(input));
+ return true;
+}
+
+bool IdltestGetArrayBufferFunction::RunImpl() {
+ std::string hello = "hello world";
+ BinaryValue* output =
+ BinaryValue::CreateWithCopiedBuffer(hello.c_str(), hello.size());
+ result_.reset(output);
+ return true;
+}

Powered by Google App Engine
This is Rietveld 408576698