Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding | 7 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
| 8 * @param {!WebInspector.NetworkMapping} networkMapping | 8 * @param {!WebInspector.NetworkMapping} networkMapping |
| 9 * @implements {WebInspector.TargetManager.Observer} | |
| 9 */ | 10 */ |
| 10 WebInspector.BlackboxManager = function(debuggerWorkspaceBinding, networkMapping ) | 11 WebInspector.BlackboxManager = function(debuggerWorkspaceBinding, networkMapping ) |
| 11 { | 12 { |
| 12 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; | 13 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; |
| 13 this._networkMapping = networkMapping; | 14 this._networkMapping = networkMapping; |
| 14 | 15 |
| 15 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this ); | 16 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this ); |
| 16 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.GlobalObjectCleared, this._globalObjectCleared, th is); | 17 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.GlobalObjectCleared, this._globalObjectCleared, th is); |
| 17 WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this. _patternChanged.bind(this)); | 18 WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this. _patternChanged.bind(this)); |
| 18 WebInspector.moduleSetting("skipContentScripts").addChangeListener(this._pat ternChanged.bind(this)); | 19 WebInspector.moduleSetting("skipContentScripts").addChangeListener(this._pat ternChanged.bind(this)); |
| 19 | 20 |
| 20 /** @type {!Map<!WebInspector.DebuggerModel, !Map<string, !Array<!DebuggerAg ent.ScriptPosition>>>} */ | 21 /** @type {!Map<!WebInspector.DebuggerModel, !Map<string, !Array<!DebuggerAg ent.ScriptPosition>>>} */ |
| 21 this._debuggerModelData = new Map(); | 22 this._debuggerModelData = new Map(); |
| 22 /** @type {!Map<string, boolean>} */ | 23 /** @type {!Map<string, boolean>} */ |
| 23 this._isBlackboxedURLCache = new Map(); | 24 this._isBlackboxedURLCache = new Map(); |
| 25 | |
| 26 WebInspector.targetManager.observeTargets(this); | |
| 24 } | 27 } |
| 25 | 28 |
| 26 WebInspector.BlackboxManager.prototype = { | 29 WebInspector.BlackboxManager.prototype = { |
| 27 /** | 30 /** |
| 28 * @param {function(!WebInspector.Event)} listener | 31 * @param {function(!WebInspector.Event)} listener |
| 29 * @param {!Object=} thisObject | 32 * @param {!Object=} thisObject |
| 30 */ | 33 */ |
| 31 addChangeListener: function(listener, thisObject) | 34 addChangeListener: function(listener, thisObject) |
| 32 { | 35 { |
| 33 WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(l istener, thisObject); | 36 WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(l istener, thisObject); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 */ | 145 */ |
| 143 function mappingComparator(a, b) | 146 function mappingComparator(a, b) |
| 144 { | 147 { |
| 145 if (a.lineNumber !== b.lineNumber) | 148 if (a.lineNumber !== b.lineNumber) |
| 146 return a.lineNumber - b.lineNumber; | 149 return a.lineNumber - b.lineNumber; |
| 147 return a.columnNumber - b.columnNumber; | 150 return a.columnNumber - b.columnNumber; |
| 148 } | 151 } |
| 149 }, | 152 }, |
| 150 | 153 |
| 151 /** | 154 /** |
| 155 * @override | |
| 156 * @param {!WebInspector.Target} target | |
| 157 */ | |
| 158 targetAdded: function(target) | |
| 159 { | |
| 160 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | |
| 161 if (debuggerModel) | |
| 162 this._addBlackboxPatterns(debuggerModel); | |
| 163 }, | |
| 164 | |
| 165 /** | |
| 166 * @override | |
| 167 * @param {!WebInspector.Target} target | |
| 168 */ | |
| 169 targetRemoved: function(target) | |
| 170 { | |
| 171 }, | |
| 172 | |
| 173 /** | |
| 174 * @param {!WebInspector.DebuggerModel} debuggerModel | |
| 175 * @return {!Promise<boolean>} | |
| 176 */ | |
| 177 _addBlackboxPatterns: function(debuggerModel) | |
| 178 { | |
| 179 var regexPatterns = WebInspector.moduleSetting("skipStackFramesPattern") .getAsArray(); | |
| 180 var patterns = /** @type {!Array<!DebuggerAgent.BlackboxPattern>} */([]) ; | |
| 181 for (var item of regexPatterns) { | |
| 182 if (!item.disabled && item.pattern) | |
| 183 patterns.push({ regexp: item.pattern }); | |
| 184 } | |
| 185 return debuggerModel.addBlackboxPatterns(patterns); | |
| 186 }, | |
| 187 | |
| 188 /** | |
| 152 * @param {!WebInspector.UISourceCode} uiSourceCode | 189 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 153 * @return {?string} | 190 * @return {?string} |
| 154 */ | 191 */ |
| 155 _uiSourceCodeURL: function(uiSourceCode) | 192 _uiSourceCodeURL: function(uiSourceCode) |
| 156 { | 193 { |
| 157 var networkURL = this._networkMapping.networkURL(uiSourceCode); | 194 var networkURL = this._networkMapping.networkURL(uiSourceCode); |
| 158 var projectType = uiSourceCode.project().type(); | 195 var projectType = uiSourceCode.project().type(); |
| 159 if (projectType === WebInspector.projectTypes.Debugger) | 196 if (projectType === WebInspector.projectTypes.Debugger) |
| 160 return null; | 197 return null; |
| 161 var url = projectType === WebInspector.projectTypes.Formatter ? uiSource Code.url() : networkURL; | 198 var url = projectType === WebInspector.projectTypes.Formatter ? uiSource Code.url() : networkURL; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 { | 292 { |
| 256 this._isBlackboxedURLCache.clear(); | 293 this._isBlackboxedURLCache.clear(); |
| 257 | 294 |
| 258 var promises = []; | 295 var promises = []; |
| 259 for (var debuggerModel of WebInspector.DebuggerModel.instances()) { | 296 for (var debuggerModel of WebInspector.DebuggerModel.instances()) { |
| 260 for (var scriptId in debuggerModel.scripts) { | 297 for (var scriptId in debuggerModel.scripts) { |
| 261 var script = debuggerModel.scripts[scriptId]; | 298 var script = debuggerModel.scripts[scriptId]; |
| 262 promises.push(this._addScript(script) | 299 promises.push(this._addScript(script) |
| 263 .then(loadSourceMap.bind(this, script))); | 300 .then(loadSourceMap.bind(this, script))); |
| 264 } | 301 } |
| 302 promises.push(clearBlackboxPatterns(debuggerModel).then(addBlackboxP atterns.bind(this, debuggerModel))); | |
|
dgozman
2016/03/08 18:48:12
This should go before _addScript calls.
| |
| 265 } | 303 } |
| 266 Promise.all(promises).then(this._patternChangeFinishedForTests.bind(this )); | 304 Promise.all(promises).then(this._patternChangeFinishedForTests.bind(this )); |
| 267 | 305 |
| 268 /** | 306 /** |
| 269 * @param {!WebInspector.Script} script | 307 * @param {!WebInspector.Script} script |
| 270 * @return {!Promise<undefined>} | 308 * @return {!Promise<undefined>} |
| 271 * @this {WebInspector.BlackboxManager} | 309 * @this {WebInspector.BlackboxManager} |
| 272 */ | 310 */ |
| 273 function loadSourceMap(script) | 311 function loadSourceMap(script) |
| 274 { | 312 { |
| 275 return this.sourceMapLoaded(script, this._debuggerWorkspaceBinding.s ourceMapForScript(script)); | 313 return this.sourceMapLoaded(script, this._debuggerWorkspaceBinding.s ourceMapForScript(script)); |
| 276 } | 314 } |
| 315 | |
| 316 /** | |
| 317 * @param {!WebInspector.DebuggerModel} debuggerModel | |
| 318 * @return {!Promise<boolean>} | |
| 319 */ | |
| 320 function clearBlackboxPatterns(debuggerModel) | |
| 321 { | |
| 322 return debuggerModel.clearBlackboxPatterns(); | |
|
dgozman
2016/03/08 18:48:12
Inline it!
| |
| 323 } | |
| 324 | |
| 325 /** | |
| 326 * @param {!WebInspector.DebuggerModel} debuggerModel | |
| 327 * @param {boolean} wasCleared | |
| 328 * @return {!Promise<boolean>} | |
| 329 * @this {WebInspector.BlackboxManager} | |
| 330 */ | |
| 331 function addBlackboxPatterns(debuggerModel, wasCleared) | |
| 332 { | |
| 333 if (!wasCleared) | |
|
dgozman
2016/03/08 18:48:12
Ignore this and inline.
| |
| 334 return Promise.resolve(false); | |
| 335 else | |
| 336 return this._addBlackboxPatterns(debuggerModel); | |
| 337 } | |
| 277 }, | 338 }, |
| 278 | 339 |
| 279 _patternChangeFinishedForTests: function() | 340 _patternChangeFinishedForTests: function() |
| 280 { | 341 { |
| 281 // This method is sniffed in tests. | 342 // This method is sniffed in tests. |
| 282 }, | 343 }, |
| 283 | 344 |
| 284 /** | 345 /** |
| 285 * @param {!WebInspector.Event} event | 346 * @param {!WebInspector.Event} event |
| 286 */ | 347 */ |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 hasChanged = previousScriptState.length !== positions.length; | 416 hasChanged = previousScriptState.length !== positions.length; |
| 356 for (var i = 0; !hasChanged && i < positions.length; ++i) | 417 for (var i = 0; !hasChanged && i < positions.length; ++i) |
| 357 hasChanged = positions[i].line !== previousScriptState[i].line | | positions[i].column !== previousScriptState[i].column; | 418 hasChanged = positions[i].line !== previousScriptState[i].line | | positions[i].column !== previousScriptState[i].column; |
| 358 if (!hasChanged) | 419 if (!hasChanged) |
| 359 return Promise.resolve(); | 420 return Promise.resolve(); |
| 360 } else { | 421 } else { |
| 361 if (positions.length === 0) | 422 if (positions.length === 0) |
| 362 return Promise.resolve().then(updateState.bind(this, false)); | 423 return Promise.resolve().then(updateState.bind(this, false)); |
| 363 } | 424 } |
| 364 | 425 |
| 365 return script.setBlackboxedRanges(positions).then(updateState.bind(this) ); | 426 return script.addBlackboxPattern(positions).then(updateState.bind(this)) ; |
| 366 | 427 |
| 367 /** | 428 /** |
| 368 * @param {boolean} success | 429 * @param {boolean} success |
| 369 * @this {WebInspector.BlackboxManager} | 430 * @this {WebInspector.BlackboxManager} |
| 370 */ | 431 */ |
| 371 function updateState(success) | 432 function updateState(success) |
| 372 { | 433 { |
| 373 if (success) { | 434 if (success) { |
| 374 this._setScriptPositions(script, positions); | 435 this._setScriptPositions(script, positions); |
| 375 this._debuggerWorkspaceBinding.updateLocations(script); | 436 this._debuggerWorkspaceBinding.updateLocations(script); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 if (scheme === "chrome-extension") | 472 if (scheme === "chrome-extension") |
| 412 prefix += parsedURL.host + "\\b"; | 473 prefix += parsedURL.host + "\\b"; |
| 413 prefix += ".*"; | 474 prefix += ".*"; |
| 414 } | 475 } |
| 415 return prefix + name.escapeForRegExp() + (url.endsWith(name) ? "$" : "\\ b"); | 476 return prefix + name.escapeForRegExp() + (url.endsWith(name) ? "$" : "\\ b"); |
| 416 } | 477 } |
| 417 } | 478 } |
| 418 | 479 |
| 419 /** @type {!WebInspector.BlackboxManager} */ | 480 /** @type {!WebInspector.BlackboxManager} */ |
| 420 WebInspector.blackboxManager; | 481 WebInspector.blackboxManager; |
| OLD | NEW |