Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 this._mappings = []; | 82 this._mappings = []; |
| 83 this._sources = {}; | 83 this._sources = {}; |
| 84 this._sourceContentByURL = {}; | 84 this._sourceContentByURL = {}; |
| 85 this._parseMappingPayload(payload); | 85 this._parseMappingPayload(payload); |
| 86 } | 86 } |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * @param {string} sourceMapURL | 89 * @param {string} sourceMapURL |
| 90 * @param {string} compiledURL | 90 * @param {string} compiledURL |
| 91 * @param {function(?WebInspector.SourceMap)} callback | 91 * @param {function(?WebInspector.SourceMap)} callback |
| 92 * @param {function(string)=} contentCallback | |
| 92 * @this {WebInspector.SourceMap} | 93 * @this {WebInspector.SourceMap} |
| 93 */ | 94 */ |
| 94 WebInspector.SourceMap.load = function(sourceMapURL, compiledURL, callback) | 95 WebInspector.SourceMap.load = function(sourceMapURL, compiledURL, callback, cont entCallback) |
| 95 { | 96 { |
| 96 WebInspector.multitargetNetworkManager.loadResource(sourceMapURL, contentLoa ded); | 97 WebInspector.multitargetNetworkManager.loadResource(sourceMapURL, contentLoa ded); |
| 97 | 98 |
| 98 /** | 99 /** |
| 99 * @param {number} statusCode | 100 * @param {number} statusCode |
| 100 * @param {!Object.<string, string>} headers | 101 * @param {!Object.<string, string>} headers |
| 101 * @param {string} content | 102 * @param {string} content |
| 102 */ | 103 */ |
| 103 function contentLoaded(statusCode, headers, content) | 104 function contentLoaded(statusCode, headers, content) |
| 104 { | 105 { |
| 105 if (!content || statusCode >= 400) { | 106 if (!content || statusCode >= 400) { |
| 106 callback(null); | 107 callback(null); |
| 107 return; | 108 return; |
| 108 } | 109 } |
| 109 | 110 |
| 110 if (content.slice(0, 3) === ")]}") | 111 if (content.slice(0, 3) === ")]}") |
| 111 content = content.substring(content.indexOf('\n')); | 112 content = content.substring(content.indexOf('\n')); |
| 113 if (contentCallback) contentCallback(content); | |
|
pfeldman
2016/01/19 19:35:04
Looks like a hack, you should reuse the only callb
kozy
2016/01/20 00:41:22
Done.
| |
| 112 try { | 114 try { |
| 113 var payload = /** @type {!SourceMapV3} */ (JSON.parse(content)); | 115 var payload = /** @type {!SourceMapV3} */ (JSON.parse(content)); |
| 114 var baseURL = sourceMapURL.startsWith("data:") ? compiledURL : sourc eMapURL; | 116 var baseURL = sourceMapURL.startsWith("data:") ? compiledURL : sourc eMapURL; |
| 115 callback(new WebInspector.SourceMap(compiledURL, baseURL, payload)); | 117 callback(new WebInspector.SourceMap(compiledURL, baseURL, payload)); |
| 116 } catch(e) { | 118 } catch(e) { |
| 117 console.error(e.message); | 119 console.error(e.message); |
| 118 WebInspector.console.error("Failed to parse SourceMap: " + sourceMap URL); | 120 WebInspector.console.error("Failed to parse SourceMap: " + sourceMap URL); |
| 119 callback(null); | 121 callback(null); |
| 120 } | 122 } |
| 121 } | 123 } |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 * @param {number=} sourceColumnNumber | 418 * @param {number=} sourceColumnNumber |
| 417 */ | 419 */ |
| 418 WebInspector.SourceMap.Entry = function(lineNumber, columnNumber, sourceURL, sou rceLineNumber, sourceColumnNumber) | 420 WebInspector.SourceMap.Entry = function(lineNumber, columnNumber, sourceURL, sou rceLineNumber, sourceColumnNumber) |
| 419 { | 421 { |
| 420 this.lineNumber = lineNumber; | 422 this.lineNumber = lineNumber; |
| 421 this.columnNumber = columnNumber; | 423 this.columnNumber = columnNumber; |
| 422 this.sourceURL = sourceURL; | 424 this.sourceURL = sourceURL; |
| 423 this.sourceLineNumber = sourceLineNumber; | 425 this.sourceLineNumber = sourceLineNumber; |
| 424 this.sourceColumnNumber = sourceColumnNumber; | 426 this.sourceColumnNumber = sourceColumnNumber; |
| 425 } | 427 } |
| OLD | NEW |