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

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

Issue 1609973002: DevTools: promisify ContentProvider.requestContent and all its clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit 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/Resource.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/Resource.js b/third_party/WebKit/Source/devtools/front_end/sdk/Resource.js
index f6343ed54e31baf6aa6d1fc69b41a191c794ee44..2a6e1cceb0fdafe8d6be75d07669c67b96ce6828 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/Resource.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/Resource.js
@@ -94,7 +94,7 @@ WebInspector.Resource.populateImageSource = function(url, mimeType, contentProvi
image.src = imageSrc;
}
- contentProvider.requestContent(onResourceContent);
+ contentProvider.requestContent().then(onResourceContent);
}
WebInspector.Resource.prototype = {
@@ -211,18 +211,19 @@ WebInspector.Resource.prototype = {
/**
* @override
- * @param {function(?string)} callback
+ * @return {!Promise<?string>}
*/
- requestContent: function(callback)
+ requestContent: function()
{
- if (typeof this._content !== "undefined") {
- callback(this._content);
- return;
- }
+ if (typeof this._content !== "undefined")
+ return Promise.resolve(this._content);
+ var callback;
+ var promise = new Promise(fulfill => callback = fulfill);
this._pendingContentCallbacks.push(callback);
if (!this._request || this._request.finished)
this._innerRequestContent();
+ return promise;
},
/**
@@ -322,7 +323,7 @@ WebInspector.Resource.prototype = {
}
if (this.request) {
- this.request.requestContent(requestContentLoaded.bind(this));
+ this.request.requestContent().then(requestContentLoaded.bind(this));
return;
}

Powered by Google App Engine
This is Rietveld 408576698