| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 * @override | 54 * @override |
| 55 * @return {!WebInspector.ResourceType} | 55 * @return {!WebInspector.ResourceType} |
| 56 */ | 56 */ |
| 57 contentType: function() | 57 contentType: function() |
| 58 { | 58 { |
| 59 return this._contentType; | 59 return this._contentType; |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @override | 63 * @override |
| 64 * @param {function(?string)} callback | 64 * @return {!Promise<?string>} |
| 65 */ | 65 */ |
| 66 requestContent: function(callback) | 66 requestContent: function() |
| 67 { | 67 { |
| 68 var callback; |
| 69 var promise = new Promise(fulfill => callback = fulfill); |
| 68 WebInspector.multitargetNetworkManager.loadResource(this._sourceURL, con
tentLoaded.bind(this)); | 70 WebInspector.multitargetNetworkManager.loadResource(this._sourceURL, con
tentLoaded.bind(this)); |
| 71 return promise; |
| 69 | 72 |
| 70 /** | 73 /** |
| 71 * @param {number} statusCode | 74 * @param {number} statusCode |
| 72 * @param {!Object.<string, string>} headers | 75 * @param {!Object.<string, string>} headers |
| 73 * @param {string} content | 76 * @param {string} content |
| 74 * @this {WebInspector.CompilerSourceMappingContentProvider} | 77 * @this {WebInspector.CompilerSourceMappingContentProvider} |
| 75 */ | 78 */ |
| 76 function contentLoaded(statusCode, headers, content) | 79 function contentLoaded(statusCode, headers, content) |
| 77 { | 80 { |
| 78 if (statusCode >= 400) { | 81 if (statusCode >= 400) { |
| 79 console.error("Could not load content for " + this._sourceURL +
" : " + "HTTP status code: " + statusCode); | 82 console.error("Could not load content for " + this._sourceURL +
" : " + "HTTP status code: " + statusCode); |
| 80 callback(null); | 83 callback(null); |
| 81 return; | 84 return; |
| 82 } | 85 } |
| 83 | 86 |
| 84 callback(content); | 87 callback(content); |
| 85 } | 88 } |
| 86 }, | 89 }, |
| 87 | 90 |
| 88 /** | 91 /** |
| 89 * @override | 92 * @override |
| 90 * @param {string} query | 93 * @param {string} query |
| 91 * @param {boolean} caseSensitive | 94 * @param {boolean} caseSensitive |
| 92 * @param {boolean} isRegex | 95 * @param {boolean} isRegex |
| 93 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback | 96 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback |
| 94 */ | 97 */ |
| 95 searchInContent: function(query, caseSensitive, isRegex, callback) | 98 searchInContent: function(query, caseSensitive, isRegex, callback) |
| 96 { | 99 { |
| 97 this.requestContent(contentLoaded); | 100 this.requestContent().then(contentLoaded); |
| 98 | 101 |
| 99 /** | 102 /** |
| 100 * @param {?string} content | 103 * @param {?string} content |
| 101 */ | 104 */ |
| 102 function contentLoaded(content) | 105 function contentLoaded(content) |
| 103 { | 106 { |
| 104 if (typeof content !== "string") { | 107 if (typeof content !== "string") { |
| 105 callback([]); | 108 callback([]); |
| 106 return; | 109 return; |
| 107 } | 110 } |
| 108 | 111 |
| 109 callback(WebInspector.ContentProvider.performSearchInContent(content
, query, caseSensitive, isRegex)); | 112 callback(WebInspector.ContentProvider.performSearchInContent(content
, query, caseSensitive, isRegex)); |
| 110 } | 113 } |
| 111 } | 114 } |
| 112 } | 115 } |
| OLD | NEW |