| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/extensions/api/idltest/idltest_api.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 |
| 9 using base::BinaryValue; |
| 10 |
| 11 namespace { |
| 12 |
| 13 ListValue* CopyBinaryValueToIntegerList(const BinaryValue* input) { |
| 14 ListValue* output = new ListValue(); |
| 15 const char* input_buffer = input->GetBuffer(); |
| 16 for (size_t i = 0; i < input->GetSize(); i++) { |
| 17 output->Append(Value::CreateIntegerValue(input_buffer[i])); |
| 18 } |
| 19 return output; |
| 20 } |
| 21 |
| 22 } |
| 23 |
| 24 bool IdltestSendArrayBufferFunction::RunImpl() { |
| 25 BinaryValue* input = NULL; |
| 26 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); |
| 27 result_.reset(CopyBinaryValueToIntegerList(input)); |
| 28 return true; |
| 29 } |
| 30 |
| 31 bool IdltestSendArrayBufferViewFunction::RunImpl() { |
| 32 BinaryValue* input = NULL; |
| 33 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); |
| 34 result_.reset(CopyBinaryValueToIntegerList(input)); |
| 35 return true; |
| 36 } |
| 37 |
| 38 bool IdltestGetArrayBufferFunction::RunImpl() { |
| 39 std::string hello = "hello world"; |
| 40 BinaryValue* output = |
| 41 BinaryValue::CreateWithCopiedBuffer(hello.c_str(), hello.size()); |
| 42 result_.reset(output); |
| 43 return true; |
| 44 } |
| OLD | NEW |