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

Side by Side Diff: chrome/browser/extensions/api/idltest/idltest_api.cc

Issue 2282063002: [Extensions] Convert some SyncExtensionFunctions (Closed)
Patch Set: revert Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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::BinaryValue;
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 BinaryValue* 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 bool IdltestSendArrayBufferFunction::RunSync() { 29 ExtensionFunction::ResponseAction IdltestSendArrayBufferFunction::Run() {
30 BinaryValue* input = NULL; 30 BinaryValue* input = NULL;
31 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); 31 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input));
32 SetResult(CopyBinaryValueToIntegerList(input)); 32 return RespondNow(OneArgument(CopyBinaryValueToIntegerList(input)));
33 return true;
34 } 33 }
35 34
36 bool IdltestSendArrayBufferViewFunction::RunSync() { 35 ExtensionFunction::ResponseAction IdltestSendArrayBufferViewFunction::Run() {
37 BinaryValue* input = NULL; 36 BinaryValue* input = NULL;
38 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); 37 EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input));
39 SetResult(CopyBinaryValueToIntegerList(input)); 38 return RespondNow(OneArgument(CopyBinaryValueToIntegerList(input)));
40 return true;
41 } 39 }
42 40
43 bool IdltestGetArrayBufferFunction::RunSync() { 41 ExtensionFunction::ResponseAction IdltestGetArrayBufferFunction::Run() {
44 std::string hello = "hello world"; 42 std::string hello = "hello world";
45 SetResult(BinaryValue::CreateWithCopiedBuffer(hello.c_str(), hello.size())); 43 return RespondNow(OneArgument(
46 return true; 44 BinaryValue::CreateWithCopiedBuffer(hello.c_str(), hello.size())));
47 } 45 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/idltest/idltest_api.h ('k') | extensions/browser/api/system_display/system_display_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698