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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/NetworkRequest.js

Issue 1609973002: DevTools: promisify ContentProvider.requestContent and all its clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaseline 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: third_party/WebKit/Source/devtools/front_end/sdk/NetworkRequest.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/NetworkRequest.js b/third_party/WebKit/Source/devtools/front_end/sdk/NetworkRequest.js
index d829e8ffc423712605e86c6f0400e7c641f2a7d5..602c9d52e4c0fcdefd82ec476e23c5da1b85e9bb 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/NetworkRequest.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/NetworkRequest.js
@@ -933,24 +933,23 @@ WebInspector.NetworkRequest.prototype = {
/**
* @override
- * @param {function(?string)} callback
+ * @return {!Promise<?string>}
*/
- requestContent: function(callback)
+ requestContent: function()
{
// We do not support content retrieval for WebSockets at the moment.
// Since WebSockets are potentially long-living, fail requests immediately
// to prevent caller blocking until resource is marked as finished.
- if (this._resourceType === WebInspector.resourceTypes.WebSocket) {
- callback(null);
- return;
- }
- if (typeof this._content !== "undefined") {
- callback(this.content || null);
- return;
- }
+ if (this._resourceType === WebInspector.resourceTypes.WebSocket)
+ return Promise.resolve(/** @type {?string} */(null));
+ if (typeof this._content !== "undefined")
+ return Promise.resolve(/** @type {?string} */(this.content || null));
+ var callback;
+ var promise = new Promise(fulfill => callback = fulfill);
this._pendingContentCallbacks.push(callback);
if (this.finished)
this._innerRequestContent();
+ return promise;
pfeldman 2016/01/20 19:23:51 cache promise
},
/**

Powered by Google App Engine
This is Rietveld 408576698