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

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

Issue 2695123004: DevTools: Only provide static script content to UISourceCode (Closed)
Patch Set: merge 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 | « third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js ('k') | 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/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..63d101b95b2092a6f544abd6cacf0bb298955900 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._originalContentProvider = null;
+ this._originalSource = null;
}
/**
@@ -186,11 +188,34 @@ SDK.Script = class {
} else {
this._source = '';
}
+ if (this._originalSource === null)
+ this._originalSource = this._source;
callback(this._source);
}
}
/**
+ * @return {!Common.ContentProvider}
+ */
+ originalContentProvider() {
+ if (!this._originalContentProvider) {
pfeldman 2017/02/27 22:56:09 return this.requestContent().then(() => this._orig
einbinder 2017/02/28 00:51:22 () => this.requestContent().then(() => this._origi
+ var lazyContent = this._requestOriginalContent.bind(this);
+ this._originalContentProvider =
+ new Common.StaticContentProvider(this.contentURL(), this.contentType(), lazyContent);
+ }
+ return this._originalContentProvider;
+ }
+
+ /**
+ * @return {!Promise<?string>}
+ */
+ _requestOriginalContent() {
+ if (this._originalSource === null)
+ return this.requestContent();
+ return Promise.resolve(/** @type {?string} */ (this._originalSource));
+ }
+
+ /**
* @override
* @param {string} query
* @param {boolean} caseSensitive
@@ -261,8 +286,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');
}
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698