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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/Script.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/Script.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/Script.js b/third_party/WebKit/Source/devtools/front_end/sdk/Script.js
index ed72da66c2ed5e6074d32197a32813bf8116bf57..9614f6277ee469c5f4dfe3d4ada4512d4a6b5fe3 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/Script.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/Script.js
@@ -138,14 +138,19 @@ WebInspector.Script.prototype = {
/**
* @override
- * @param {function(?string)} callback
+ * @return {!Promise<?string>}
*/
- requestContent: function(callback)
+ requestContent: function()
{
- if (this._source) {
- callback(this._source);
- return;
- }
+ if (this._source)
+ return Promise.resolve(this._source);
+ if (!this.scriptId)
+ return Promise.resolve(/** @type {?string} */(""));
+
+ var callback;
+ var promise = new Promise(fulfill => callback = fulfill);
pfeldman 2016/01/20 19:23:51 cache promise
+ this.target().debuggerAgent().getScriptSource(this.scriptId, didGetScriptSource.bind(this));
+ return promise;
/**
* @this {WebInspector.Script}
@@ -157,11 +162,6 @@ WebInspector.Script.prototype = {
this._source = WebInspector.Script._trimSourceURLComment(error ? "" : source);
callback(this._source);
}
- if (this.scriptId) {
- // Script failed to parse.
- this.target().debuggerAgent().getScriptSource(this.scriptId, didGetScriptSource.bind(this));
- } else
- callback("");
},
/**

Powered by Google App Engine
This is Rietveld 408576698