This source file includes following definitions.
- CopyBinaryValueToIntegerList
- RunImpl
- RunImpl
- RunImpl
#include "chrome/browser/extensions/api/idltest/idltest_api.h"
#include "base/values.h"
using base::BinaryValue;
namespace {
base::ListValue* CopyBinaryValueToIntegerList(const BinaryValue* input) {
base::ListValue* output = new base::ListValue();
const char* input_buffer = input->GetBuffer();
for (size_t i = 0; i < input->GetSize(); i++) {
output->Append(new base::FundamentalValue(input_buffer[i]));
}
return output;
}
}
bool IdltestSendArrayBufferFunction::RunImpl() {
BinaryValue* input = NULL;
EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input));
SetResult(CopyBinaryValueToIntegerList(input));
return true;
}
bool IdltestSendArrayBufferViewFunction::RunImpl() {
BinaryValue* input = NULL;
EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input));
SetResult(CopyBinaryValueToIntegerList(input));
return true;
}
bool IdltestGetArrayBufferFunction::RunImpl() {
std::string hello = "hello world";
BinaryValue* output =
BinaryValue::CreateWithCopiedBuffer(hello.c_str(), hello.size());
SetResult(output);
return true;
}