Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 this.columnOffset = startColumn; | 64 this.columnOffset = startColumn; |
| 65 this.endLine = endLine; | 65 this.endLine = endLine; |
| 66 this.endColumn = endColumn; | 66 this.endColumn = endColumn; |
| 67 | 67 |
| 68 this._executionContextId = executionContextId; | 68 this._executionContextId = executionContextId; |
| 69 this.hash = hash; | 69 this.hash = hash; |
| 70 this._isContentScript = isContentScript; | 70 this._isContentScript = isContentScript; |
| 71 this._isLiveEdit = isLiveEdit; | 71 this._isLiveEdit = isLiveEdit; |
| 72 this.sourceMapURL = sourceMapURL; | 72 this.sourceMapURL = sourceMapURL; |
| 73 this.hasSourceURL = hasSourceURL; | 73 this.hasSourceURL = hasSourceURL; |
| 74 this._originalContentPromise = null; | |
| 75 this._originalContentProvider = null; | |
| 74 } | 76 } |
| 75 | 77 |
| 76 /** | 78 /** |
| 77 * @param {string} source | 79 * @param {string} source |
| 78 * @return {string} | 80 * @return {string} |
| 79 */ | 81 */ |
| 80 static _trimSourceURLComment(source) { | 82 static _trimSourceURLComment(source) { |
| 81 var sourceURLIndex = source.lastIndexOf('//# sourceURL='); | 83 var sourceURLIndex = source.lastIndexOf('//# sourceURL='); |
| 82 if (sourceURLIndex === -1) { | 84 if (sourceURLIndex === -1) { |
| 83 sourceURLIndex = source.lastIndexOf('//@ sourceURL='); | 85 sourceURLIndex = source.lastIndexOf('//@ sourceURL='); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 * @param {?Protocol.Error} error | 181 * @param {?Protocol.Error} error |
| 180 * @param {string} source | 182 * @param {string} source |
| 181 */ | 183 */ |
| 182 function didGetScriptSource(error, source) { | 184 function didGetScriptSource(error, source) { |
| 183 if (!error) { | 185 if (!error) { |
| 184 SDK.Script._reportDeprecatedCommentIfNeeded(this, source); | 186 SDK.Script._reportDeprecatedCommentIfNeeded(this, source); |
| 185 this._source = SDK.Script._trimSourceURLComment(source); | 187 this._source = SDK.Script._trimSourceURLComment(source); |
| 186 } else { | 188 } else { |
| 187 this._source = ''; | 189 this._source = ''; |
| 188 } | 190 } |
| 189 callback(this._source); | 191 callback(this._source); |
|
pfeldman
2017/02/15 23:33:38
Can we just say this._originalSource = this._sourc
einbinder
2017/02/16 00:12:36
That will cache the content on first request, not
| |
| 190 } | 192 } |
| 191 } | 193 } |
| 192 | 194 |
| 193 /** | 195 /** |
| 196 * @return {!Common.ContentProvider} | |
| 197 */ | |
| 198 originalContentProvider() { | |
| 199 if (!this._originalContentProvider) { | |
|
pfeldman
2017/02/15 23:33:38
then you would say
var lazyContent = this._origin
einbinder
2017/02/27 21:21:44
StaticContent provider takes a function():Promise<
| |
| 200 var lazyContent = this.requestOriginalContent.bind(this); | |
| 201 this._originalContentProvider = | |
| 202 new Common.StaticContentProvider(this.contentURL(), this.contentType() , lazyContent); | |
| 203 } | |
| 204 return this._originalContentProvider; | |
| 205 } | |
| 206 | |
| 207 /** | |
| 208 * @return {!Promise<?string>} | |
| 209 */ | |
| 210 requestOriginalContent() { | |
|
pfeldman
2017/02/15 23:33:38
And you would not need this.
einbinder
2017/02/16 00:12:36
This can be private
| |
| 211 if (!this._originalContentPromise) | |
| 212 this._originalContentPromise = this.requestContent(); | |
| 213 return this._originalContentPromise; | |
| 214 } | |
| 215 | |
| 216 /** | |
| 194 * @override | 217 * @override |
| 195 * @param {string} query | 218 * @param {string} query |
| 196 * @param {boolean} caseSensitive | 219 * @param {boolean} caseSensitive |
| 197 * @param {boolean} isRegex | 220 * @param {boolean} isRegex |
| 198 * @param {function(!Array.<!Protocol.Debugger.SearchMatch>)} callback | 221 * @param {function(!Array.<!Protocol.Debugger.SearchMatch>)} callback |
| 199 */ | 222 */ |
| 200 searchInContent(query, caseSensitive, isRegex, callback) { | 223 searchInContent(query, caseSensitive, isRegex, callback) { |
| 201 /** | 224 /** |
| 202 * @param {?Protocol.Error} error | 225 * @param {?Protocol.Error} error |
| 203 * @param {!Array.<!Protocol.Debugger.SearchMatch>} searchMatches | 226 * @param {!Array.<!Protocol.Debugger.SearchMatch>} searchMatches |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 this._source = newSource; | 277 this._source = newSource; |
| 255 var needsStepIn = !!stackChanged; | 278 var needsStepIn = !!stackChanged; |
| 256 callback(error, exceptionDetails, callFrames, asyncStackTrace, needsStepIn ); | 279 callback(error, exceptionDetails, callFrames, asyncStackTrace, needsStepIn ); |
| 257 } | 280 } |
| 258 | 281 |
| 259 newSource = SDK.Script._trimSourceURLComment(newSource); | 282 newSource = SDK.Script._trimSourceURLComment(newSource); |
| 260 // We append correct sourceURL to script for consistency only. It's not actu ally needed for things to work correctly. | 283 // We append correct sourceURL to script for consistency only. It's not actu ally needed for things to work correctly. |
| 261 newSource = this._appendSourceURLCommentIfNeeded(newSource); | 284 newSource = this._appendSourceURLCommentIfNeeded(newSource); |
| 262 | 285 |
| 263 if (this.scriptId) { | 286 if (this.scriptId) { |
| 264 this.debuggerModel.target().debuggerAgent().setScriptSource( | 287 this.requestOriginalContent().then( |
| 265 this.scriptId, newSource, undefined, didEditScriptSource.bind(this)); | 288 () => this.debuggerModel.target().debuggerAgent().setScriptSource( |
| 289 this.scriptId, newSource, undefined, didEditScriptSource.bind(this ))); | |
| 266 } else { | 290 } else { |
| 267 callback('Script failed to parse'); | 291 callback('Script failed to parse'); |
| 268 } | 292 } |
| 269 } | 293 } |
| 270 | 294 |
| 271 /** | 295 /** |
| 272 * @param {number} lineNumber | 296 * @param {number} lineNumber |
| 273 * @param {number=} columnNumber | 297 * @param {number=} columnNumber |
| 274 * @return {!SDK.DebuggerModel.Location} | 298 * @return {!SDK.DebuggerModel.Location} |
| 275 */ | 299 */ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 function callback(error) { | 353 function callback(error) { |
| 330 if (error) | 354 if (error) |
| 331 console.error(error); | 355 console.error(error); |
| 332 fulfill(!error); | 356 fulfill(!error); |
| 333 } | 357 } |
| 334 } | 358 } |
| 335 } | 359 } |
| 336 }; | 360 }; |
| 337 | 361 |
| 338 SDK.Script.sourceURLRegex = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m; | 362 SDK.Script.sourceURLRegex = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m; |
| OLD | NEW |