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/memory/ptr_util.h" | |
12 #include "base/values.h" | 11 #include "base/values.h" |
13 | 12 |
14 using base::BinaryValue; | 13 using base::BinaryValue; |
15 | 14 |
16 namespace { | 15 namespace { |
17 | 16 |
18 std::unique_ptr<base::ListValue> CopyBinaryValueToIntegerList( | 17 std::unique_ptr<base::ListValue> CopyBinaryValueToIntegerList( |
19 const BinaryValue* input) { | 18 const BinaryValue* input) { |
20 std::unique_ptr<base::ListValue> output(new base::ListValue()); | 19 std::unique_ptr<base::ListValue> output(new base::ListValue()); |
21 const char* input_buffer = input->GetBuffer(); | 20 const char* input_buffer = input->GetBuffer(); |
(...skipping 14 matching lines...) Expand all Loading... |
36 | 35 |
37 bool IdltestSendArrayBufferViewFunction::RunSync() { | 36 bool IdltestSendArrayBufferViewFunction::RunSync() { |
38 BinaryValue* input = NULL; | 37 BinaryValue* input = NULL; |
39 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); | 38 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); |
40 SetResult(CopyBinaryValueToIntegerList(input)); | 39 SetResult(CopyBinaryValueToIntegerList(input)); |
41 return true; | 40 return true; |
42 } | 41 } |
43 | 42 |
44 bool IdltestGetArrayBufferFunction::RunSync() { | 43 bool IdltestGetArrayBufferFunction::RunSync() { |
45 std::string hello = "hello world"; | 44 std::string hello = "hello world"; |
46 BinaryValue* output = | 45 SetResult(BinaryValue::CreateWithCopiedBuffer(hello.c_str(), hello.size())); |
47 BinaryValue::CreateWithCopiedBuffer(hello.c_str(), hello.size()); | |
48 SetResult(base::WrapUnique(output)); | |
49 return true; | 46 return true; |
50 } | 47 } |
OLD | NEW |