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

Unified Diff: ui/webui/resources/js/cr.js

Issue 1635673003: MD Settings: Add helper method for responding to cr.sendWithPromise. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment. Created 4 years, 11 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: ui/webui/resources/js/cr.js
diff --git a/ui/webui/resources/js/cr.js b/ui/webui/resources/js/cr.js
index 984a5c25df05cf9cd2e9dafe5c79fe86c2843b6a..ddf7c87950035ee6e80710ee474a3b46aadfce2f 100644
--- a/ui/webui/resources/js/cr.js
+++ b/ui/webui/resources/js/cr.js
@@ -331,15 +331,12 @@ var cr = function() {
* supply any number of other arguments that will be included in the response.
* @param {string} id The unique ID identifying the Promise this response is
* tied to.
- * @param {...*} var_args Variable number of arguments to be included in the
- * response.
+ * @param {*} response The response as sent from C++.
*/
- function webUIResponse(id, var_args) {
+ function webUIResponse(id, response) {
var resolverFn = chromeSendResolverMap[id];
delete chromeSendResolverMap[id];
- // Promise#resolve accepts only one value, therefore wrapping all arguments
- // passed from C++ to JS in an array.
- resolverFn(Array.prototype.slice.call(arguments, 1));
Dan Beam 2016/01/27 00:23:57 why did you change this?
dpapad 2016/01/27 00:45:24 Explained better in CL description. On top of that
Dan Beam 2016/01/27 02:30:44 I saw that
+ resolverFn(response);
}
/**
@@ -355,7 +352,7 @@ var cr = function() {
return new Promise(function(resolve, reject) {
var id = methodName + '_' + createUid();
chromeSendResolverMap[id] = resolve;
- chrome.send(methodName, ['cr.webUIResponse', id].concat(args));
+ chrome.send(methodName, [id].concat(args));
});
}

Powered by Google App Engine
This is Rietveld 408576698