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

Unified Diff: third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js

Issue 2701763002: DevTools: run user callback inside promise for promisified domains (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js
diff --git a/third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js b/third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js
index b1266f916a64ca073a29d0d11c8132e620885d19..c906e02ef7604ab967a46a1a388e783c5d2701ae 100644
--- a/third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js
+++ b/third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js
@@ -599,13 +599,14 @@ Protocol.InspectorBackend._AgentPrototype = class {
}
var userCallback = (args.length && typeof args.peekLast() === 'function') ? args.pop() : null;
var params = this._prepareParameters(method, signature, args, !userCallback, onError);
+ var responseArguments;
if (errorMessage)
return Promise.reject(new Error(errorMessage));
pfeldman 2017/02/16 22:43:02 You aren't calling it here, are you?
else
- return new Promise(promiseAction.bind(this));
+ return new Promise(promiseAction.bind(this)).then(runUserCallback);
/**
- * @param {function(?)} resolve
+ * @param {function()} resolve
* @param {function(!Error)} reject
* @this {Protocol.InspectorBackend._AgentPrototype}
*/
@@ -614,11 +615,15 @@ Protocol.InspectorBackend._AgentPrototype = class {
* @param {...*} vararg
*/
function callback(vararg) {
- var result = userCallback ? userCallback.apply(null, arguments) : undefined;
- resolve(result);
+ responseArguments = arguments;
+ resolve();
}
this._target._wrapCallbackAndSendMessageObject(this._domain, method, params, callback);
}
+
+ function runUserCallback() {
pfeldman 2017/02/16 22:43:02 You are changing the order of callback and promise
+ return userCallback ? userCallback.apply(null, responseArguments) : undefined;
+ }
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698