Chromium Code Reviews| 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 c02c26fc0ec8a7e1fc63988c45fd1d6c84b7cfc5..3b25aa4a29debc19f1b4c9c101ed8aa1dd92528c 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/Script.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/Script.js |
| @@ -71,6 +71,8 @@ SDK.Script = class { |
| this._isLiveEdit = isLiveEdit; |
| this.sourceMapURL = sourceMapURL; |
| this.hasSourceURL = hasSourceURL; |
| + this._originalContentPromise = null; |
| + this._originalContentProvider = null; |
| } |
| /** |
| @@ -191,6 +193,27 @@ SDK.Script = class { |
| } |
| /** |
| + * @return {!Common.ContentProvider} |
| + */ |
| + originalContentProvider() { |
| + if (!this._originalContentProvider) { |
|
pfeldman
2017/02/15 23:33:38
then you would say
var lazyContent = this._origin
einbinder
2017/02/27 21:21:44
StaticContent provider takes a function():Promise<
|
| + var lazyContent = this.requestOriginalContent.bind(this); |
| + this._originalContentProvider = |
| + new Common.StaticContentProvider(this.contentURL(), this.contentType(), lazyContent); |
| + } |
| + return this._originalContentProvider; |
| + } |
| + |
| + /** |
| + * @return {!Promise<?string>} |
| + */ |
| + requestOriginalContent() { |
|
pfeldman
2017/02/15 23:33:38
And you would not need this.
einbinder
2017/02/16 00:12:36
This can be private
|
| + if (!this._originalContentPromise) |
| + this._originalContentPromise = this.requestContent(); |
| + return this._originalContentPromise; |
| + } |
| + |
| + /** |
| * @override |
| * @param {string} query |
| * @param {boolean} caseSensitive |
| @@ -261,8 +284,9 @@ SDK.Script = class { |
| newSource = this._appendSourceURLCommentIfNeeded(newSource); |
| if (this.scriptId) { |
| - this.debuggerModel.target().debuggerAgent().setScriptSource( |
| - this.scriptId, newSource, undefined, didEditScriptSource.bind(this)); |
| + this.requestOriginalContent().then( |
| + () => this.debuggerModel.target().debuggerAgent().setScriptSource( |
| + this.scriptId, newSource, undefined, didEditScriptSource.bind(this))); |
| } else { |
| callback('Script failed to parse'); |
| } |