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

Unified Diff: third_party/WebKit/Source/devtools/front_end/common/StaticContentProvider.js

Issue 1974543002: DevTools: do not pro-actively query all StyleSheets for their content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/common/StaticContentProvider.js
diff --git a/third_party/WebKit/Source/devtools/front_end/common/StaticContentProvider.js b/third_party/WebKit/Source/devtools/front_end/common/StaticContentProvider.js
index afe68e92775a5d03e6a216098174d6f7feea1e13..86322e1bb0747af4966559c4f05b4e40d47f3952 100644
--- a/third_party/WebKit/Source/devtools/front_end/common/StaticContentProvider.js
+++ b/third_party/WebKit/Source/devtools/front_end/common/StaticContentProvider.js
@@ -7,13 +7,25 @@
* @implements {WebInspector.ContentProvider}
* @param {string} contentURL
* @param {!WebInspector.ResourceType} contentType
- * @param {!Promise<string>} contentGetter
+ * @param {function():!Promise<string>} lazyContent
*/
-WebInspector.StaticContentProvider = function(contentURL, contentType, contentGetter)
+WebInspector.StaticContentProvider = function(contentURL, contentType, lazyContent)
{
this._contentURL = contentURL;
this._contentType = contentType;
- this._contentGetter = contentGetter;
+ this._lazyContent = lazyContent;
+}
+
+/**
+ * @param {string} contentURL
+ * @param {!WebInspector.ResourceType} contentType
+ * @param {string} content
+ * @return {!WebInspector.StaticContentProvider}
+ */
+WebInspector.StaticContentProvider.fromString = function(contentURL, contentType, content)
+{
+ var lazyContent = () => Promise.resolve(content);
dgozman 2016/05/11 18:09:21 This looks hilarious.
+ return new WebInspector.StaticContentProvider(contentURL, contentType, lazyContent);
}
WebInspector.StaticContentProvider.prototype = {
@@ -41,7 +53,7 @@ WebInspector.StaticContentProvider.prototype = {
*/
requestContent: function()
{
- return /** @type {!Promise<?string>} */(this._contentGetter);
+ return /** @type {!Promise<?string>} */(this._lazyContent());
},
/**
@@ -61,6 +73,6 @@ WebInspector.StaticContentProvider.prototype = {
callback(WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex));
}
- this._contentGetter.then(performSearch);
+ this._lazyContent().then(performSearch);
}
}

Powered by Google App Engine
This is Rietveld 408576698