Chromium Code Reviews| 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); |
| } |
| } |