OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/idltest/idltest_api.h" | 5 #include "chrome/browser/extensions/api/idltest/idltest_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 | 12 |
13 using base::BinaryValue; | 13 using base::Value; |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 std::unique_ptr<base::ListValue> CopyBinaryValueToIntegerList( | 17 std::unique_ptr<base::ListValue> CopyBinaryValueToIntegerList( |
18 const BinaryValue* input) { | 18 const Value* input) { |
19 std::unique_ptr<base::ListValue> output(new base::ListValue()); | 19 std::unique_ptr<base::ListValue> output(new base::ListValue()); |
20 const char* input_buffer = input->GetBuffer(); | 20 const char* input_buffer = input->GetBuffer(); |
21 for (size_t i = 0; i < input->GetSize(); i++) { | 21 for (size_t i = 0; i < input->GetSize(); i++) { |
22 output->AppendInteger(input_buffer[i]); | 22 output->AppendInteger(input_buffer[i]); |
23 } | 23 } |
24 return output; | 24 return output; |
25 } | 25 } |
26 | 26 |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 ExtensionFunction::ResponseAction IdltestSendArrayBufferFunction::Run() { | 29 ExtensionFunction::ResponseAction IdltestSendArrayBufferFunction::Run() { |
30 BinaryValue* input = NULL; | 30 Value* input = NULL; |
31 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); | 31 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); |
32 return RespondNow(OneArgument(CopyBinaryValueToIntegerList(input))); | 32 return RespondNow(OneArgument(CopyBinaryValueToIntegerList(input))); |
33 } | 33 } |
34 | 34 |
35 ExtensionFunction::ResponseAction IdltestSendArrayBufferViewFunction::Run() { | 35 ExtensionFunction::ResponseAction IdltestSendArrayBufferViewFunction::Run() { |
36 BinaryValue* input = NULL; | 36 Value* input = NULL; |
37 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); | 37 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); |
38 return RespondNow(OneArgument(CopyBinaryValueToIntegerList(input))); | 38 return RespondNow(OneArgument(CopyBinaryValueToIntegerList(input))); |
39 } | 39 } |
40 | 40 |
41 ExtensionFunction::ResponseAction IdltestGetArrayBufferFunction::Run() { | 41 ExtensionFunction::ResponseAction IdltestGetArrayBufferFunction::Run() { |
42 std::string hello = "hello world"; | 42 std::string hello = "hello world"; |
43 return RespondNow(OneArgument( | 43 return RespondNow( |
44 BinaryValue::CreateWithCopiedBuffer(hello.c_str(), hello.size()))); | 44 OneArgument(Value::CreateWithCopiedBuffer(hello.c_str(), hello.size()))); |
45 } | 45 } |
OLD | NEW |