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

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

Issue 1954423002: DevTools: introduce CSSStyleSheetHeader.originalContentProvider() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify-network-project
Patch Set: address comments 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 ec6c6b2d1aa6e981127e9fb9c179d89ebc785725..afe68e92775a5d03e6a216098174d6f7feea1e13 100644
--- a/third_party/WebKit/Source/devtools/front_end/common/StaticContentProvider.js
+++ b/third_party/WebKit/Source/devtools/front_end/common/StaticContentProvider.js
@@ -5,33 +5,15 @@
/**
* @constructor
* @implements {WebInspector.ContentProvider}
- * @param {!WebInspector.ResourceType} contentType
- * @param {string} content
* @param {string} contentURL
+ * @param {!WebInspector.ResourceType} contentType
+ * @param {!Promise<string>} contentGetter
*/
-WebInspector.StaticContentProvider = function(contentType, content, contentURL)
+WebInspector.StaticContentProvider = function(contentURL, contentType, contentGetter)
{
- this._content = content;
- this._contentType = contentType;
this._contentURL = contentURL;
-}
-
-/**
- * @param {string} content
- * @param {string} query
- * @param {boolean} caseSensitive
- * @param {boolean} isRegex
- * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callback
- */
-WebInspector.StaticContentProvider.searchInContent = function(content, query, caseSensitive, isRegex, callback)
-{
- function performSearch()
- {
- callback(WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex));
- }
-
- // searchInContent should call back later.
- setTimeout(performSearch.bind(null), 0);
+ this._contentType = contentType;
+ this._contentGetter = contentGetter;
}
WebInspector.StaticContentProvider.prototype = {
@@ -59,7 +41,7 @@ WebInspector.StaticContentProvider.prototype = {
*/
requestContent: function()
{
- return Promise.resolve(/** @type {?string} */(this._content));
+ return /** @type {!Promise<?string>} */(this._contentGetter);
},
/**
@@ -71,6 +53,14 @@ WebInspector.StaticContentProvider.prototype = {
*/
searchInContent: function(query, caseSensitive, isRegex, callback)
{
- WebInspector.StaticContentProvider.searchInContent(this._content, query, caseSensitive, isRegex, callback);
+ /**
+ * @param {string} content
+ */
+ function performSearch(content)
+ {
+ callback(WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex));
+ }
+
+ this._contentGetter.then(performSearch);
}
}

Powered by Google App Engine
This is Rietveld 408576698