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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {WebInspector.ContentProvider} 7 * @implements {WebInspector.ContentProvider}
8 * @param {string} contentURL
8 * @param {!WebInspector.ResourceType} contentType 9 * @param {!WebInspector.ResourceType} contentType
9 * @param {string} content 10 * @param {!Promise<string>} contentGetter
10 * @param {string} contentURL
11 */ 11 */
12 WebInspector.StaticContentProvider = function(contentType, content, contentURL) 12 WebInspector.StaticContentProvider = function(contentURL, contentType, contentGe tter)
13 { 13 {
14 this._content = content; 14 this._contentURL = contentURL;
15 this._contentType = contentType; 15 this._contentType = contentType;
16 this._contentURL = contentURL; 16 this._contentGetter = contentGetter;
17 }
18
19 /**
20 * @param {string} content
21 * @param {string} query
22 * @param {boolean} caseSensitive
23 * @param {boolean} isRegex
24 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callbac k
25 */
26 WebInspector.StaticContentProvider.searchInContent = function(content, query, ca seSensitive, isRegex, callback)
27 {
28 function performSearch()
29 {
30 callback(WebInspector.ContentProvider.performSearchInContent(content, qu ery, caseSensitive, isRegex));
31 }
32
33 // searchInContent should call back later.
34 setTimeout(performSearch.bind(null), 0);
35 } 17 }
36 18
37 WebInspector.StaticContentProvider.prototype = { 19 WebInspector.StaticContentProvider.prototype = {
38 /** 20 /**
39 * @override 21 * @override
40 * @return {string} 22 * @return {string}
41 */ 23 */
42 contentURL: function() 24 contentURL: function()
43 { 25 {
44 return this._contentURL; 26 return this._contentURL;
45 }, 27 },
46 28
47 /** 29 /**
48 * @override 30 * @override
49 * @return {!WebInspector.ResourceType} 31 * @return {!WebInspector.ResourceType}
50 */ 32 */
51 contentType: function() 33 contentType: function()
52 { 34 {
53 return this._contentType; 35 return this._contentType;
54 }, 36 },
55 37
56 /** 38 /**
57 * @override 39 * @override
58 * @return {!Promise<?string>} 40 * @return {!Promise<?string>}
59 */ 41 */
60 requestContent: function() 42 requestContent: function()
61 { 43 {
62 return Promise.resolve(/** @type {?string} */(this._content)); 44 return /** @type {!Promise<?string>} */(this._contentGetter);
63 }, 45 },
64 46
65 /** 47 /**
66 * @override 48 * @override
67 * @param {string} query 49 * @param {string} query
68 * @param {boolean} caseSensitive 50 * @param {boolean} caseSensitive
69 * @param {boolean} isRegex 51 * @param {boolean} isRegex
70 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback 52 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback
71 */ 53 */
72 searchInContent: function(query, caseSensitive, isRegex, callback) 54 searchInContent: function(query, caseSensitive, isRegex, callback)
73 { 55 {
74 WebInspector.StaticContentProvider.searchInContent(this._content, query, caseSensitive, isRegex, callback); 56 /**
57 * @param {string} content
58 */
59 function performSearch(content)
60 {
61 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex));
62 }
63
64 this._contentGetter.then(performSearch);
75 } 65 }
76 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698