| 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 |
| 11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. | 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
| 17 * | 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | |
| 31 /** | 30 /** |
| 32 * @constructor | |
| 33 * @implements {WebInspector.ContentProvider} | 31 * @implements {WebInspector.ContentProvider} |
| 34 * @param {string} sourceURL | 32 * @unrestricted |
| 35 * @param {!WebInspector.ResourceType} contentType | |
| 36 */ | 33 */ |
| 37 WebInspector.CompilerSourceMappingContentProvider = function(sourceURL, contentT
ype) | 34 WebInspector.CompilerSourceMappingContentProvider = class { |
| 38 { | 35 /** |
| 36 * @param {string} sourceURL |
| 37 * @param {!WebInspector.ResourceType} contentType |
| 38 */ |
| 39 constructor(sourceURL, contentType) { |
| 39 this._sourceURL = sourceURL; | 40 this._sourceURL = sourceURL; |
| 40 this._contentType = contentType; | 41 this._contentType = contentType; |
| 41 }; | 42 } |
| 42 | 43 |
| 43 WebInspector.CompilerSourceMappingContentProvider.prototype = { | 44 /** |
| 44 /** | 45 * @override |
| 45 * @override | 46 * @return {string} |
| 46 * @return {string} | 47 */ |
| 47 */ | 48 contentURL() { |
| 48 contentURL: function() | 49 return this._sourceURL; |
| 49 { | 50 } |
| 50 return this._sourceURL; | 51 |
| 51 }, | 52 /** |
| 53 * @override |
| 54 * @return {!WebInspector.ResourceType} |
| 55 */ |
| 56 contentType() { |
| 57 return this._contentType; |
| 58 } |
| 59 |
| 60 /** |
| 61 * @override |
| 62 * @return {!Promise<?string>} |
| 63 */ |
| 64 requestContent() { |
| 65 var callback; |
| 66 var promise = new Promise(fulfill => callback = fulfill); |
| 67 WebInspector.multitargetNetworkManager.loadResource(this._sourceURL, content
Loaded.bind(this)); |
| 68 return promise; |
| 52 | 69 |
| 53 /** | 70 /** |
| 54 * @override | 71 * @param {number} statusCode |
| 55 * @return {!WebInspector.ResourceType} | 72 * @param {!Object.<string, string>} headers |
| 73 * @param {string} content |
| 74 * @this {WebInspector.CompilerSourceMappingContentProvider} |
| 56 */ | 75 */ |
| 57 contentType: function() | 76 function contentLoaded(statusCode, headers, content) { |
| 58 { | 77 if (statusCode >= 400) { |
| 59 return this._contentType; | 78 console.error( |
| 60 }, | 79 'Could not load content for ' + this._sourceURL + ' : ' + |
| 80 'HTTP status code: ' + statusCode); |
| 81 callback(null); |
| 82 return; |
| 83 } |
| 84 |
| 85 callback(content); |
| 86 } |
| 87 } |
| 88 |
| 89 /** |
| 90 * @override |
| 91 * @param {string} query |
| 92 * @param {boolean} caseSensitive |
| 93 * @param {boolean} isRegex |
| 94 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callb
ack |
| 95 */ |
| 96 searchInContent(query, caseSensitive, isRegex, callback) { |
| 97 this.requestContent().then(contentLoaded); |
| 61 | 98 |
| 62 /** | 99 /** |
| 63 * @override | 100 * @param {?string} content |
| 64 * @return {!Promise<?string>} | |
| 65 */ | 101 */ |
| 66 requestContent: function() | 102 function contentLoaded(content) { |
| 67 { | 103 if (typeof content !== 'string') { |
| 68 var callback; | 104 callback([]); |
| 69 var promise = new Promise(fulfill => callback = fulfill); | 105 return; |
| 70 WebInspector.multitargetNetworkManager.loadResource(this._sourceURL, con
tentLoaded.bind(this)); | 106 } |
| 71 return promise; | |
| 72 | 107 |
| 73 /** | 108 callback(WebInspector.ContentProvider.performSearchInContent(content, quer
y, caseSensitive, isRegex)); |
| 74 * @param {number} statusCode | |
| 75 * @param {!Object.<string, string>} headers | |
| 76 * @param {string} content | |
| 77 * @this {WebInspector.CompilerSourceMappingContentProvider} | |
| 78 */ | |
| 79 function contentLoaded(statusCode, headers, content) | |
| 80 { | |
| 81 if (statusCode >= 400) { | |
| 82 console.error("Could not load content for " + this._sourceURL +
" : " + "HTTP status code: " + statusCode); | |
| 83 callback(null); | |
| 84 return; | |
| 85 } | |
| 86 | |
| 87 callback(content); | |
| 88 } | |
| 89 }, | |
| 90 | |
| 91 /** | |
| 92 * @override | |
| 93 * @param {string} query | |
| 94 * @param {boolean} caseSensitive | |
| 95 * @param {boolean} isRegex | |
| 96 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback | |
| 97 */ | |
| 98 searchInContent: function(query, caseSensitive, isRegex, callback) | |
| 99 { | |
| 100 this.requestContent().then(contentLoaded); | |
| 101 | |
| 102 /** | |
| 103 * @param {?string} content | |
| 104 */ | |
| 105 function contentLoaded(content) | |
| 106 { | |
| 107 if (typeof content !== "string") { | |
| 108 callback([]); | |
| 109 return; | |
| 110 } | |
| 111 | |
| 112 callback(WebInspector.ContentProvider.performSearchInContent(content
, query, caseSensitive, isRegex)); | |
| 113 } | |
| 114 } | 109 } |
| 110 } |
| 115 }; | 111 }; |
| OLD | NEW |