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

Unified Diff: chrome/browser/extensions/extension_function.cc

Issue 10694106: Added support for multiple parameters to Extension API callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Synced. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_function.cc
diff --git a/chrome/browser/extensions/extension_function.cc b/chrome/browser/extensions/extension_function.cc
index d8ab5b994accbd8505b2f17b721afa744015a458..9caad98e40fb8faa1e04c2a351710aed0563fa0a 100644
--- a/chrome/browser/extensions/extension_function.cc
+++ b/chrome/browser/extensions/extension_function.cc
@@ -93,8 +93,13 @@ void ExtensionFunction::SetArgs(const base::ListValue* args) {
args_.reset(args->DeepCopy());
}
-const Value* ExtensionFunction::GetResultValue() {
- return result_.get();
+void ExtensionFunction::SetResult(base::Value* result) {
+ results_.reset(new base::ListValue());
+ results_->Append(result);
+}
+
+const ListValue* ExtensionFunction::GetResultList() {
+ return results_.get();
}
const std::string ExtensionFunction::GetError() {
@@ -129,14 +134,12 @@ void ExtensionFunction::SendResponseImpl(base::ProcessHandle process,
return;
}
- // Value objects can't be directly serialized in our IPC code, so we wrap the
- // result_ Value with a ListValue (also transferring ownership of result_).
- base::ListValue result_wrapper;
- if (result_.get())
- result_wrapper.Append(result_.release());
+ // If results were never set, we send an empty argument list.
+ if (!results_.get())
+ results_.reset(new ListValue());
ipc_sender->Send(new ExtensionMsg_Response(
- routing_id, request_id_, success, result_wrapper, GetError()));
+ routing_id, request_id_, success, *results_.release(), GetError()));
koz (OOO until 15th September) 2012/07/13 04:48:16 Is this a memory leak? I think a better way to do
Matt Tytel 2012/07/13 05:14:39 :( Yes that is. As for the scoped_ptr business, t
not at google - send to devlin 2012/07/13 05:20:05 In the JSC case it's also reasonable to do void S
}
void ExtensionFunction::HandleBadMessage(base::ProcessHandle process) {
« no previous file with comments | « chrome/browser/extensions/extension_function.h ('k') | chrome/browser/extensions/extension_function_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698