Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 }, | 583 }, |
| 584 | 584 |
| 585 /** | 585 /** |
| 586 * @param {!RuntimeAgent.ScriptId} scriptId | 586 * @param {!RuntimeAgent.ScriptId} scriptId |
| 587 * @param {string} sourceURL | 587 * @param {string} sourceURL |
| 588 * @param {number} startLine | 588 * @param {number} startLine |
| 589 * @param {number} startColumn | 589 * @param {number} startColumn |
| 590 * @param {number} endLine | 590 * @param {number} endLine |
| 591 * @param {number} endColumn | 591 * @param {number} endColumn |
| 592 * @param {!RuntimeAgent.ExecutionContextId} executionContextId | 592 * @param {!RuntimeAgent.ExecutionContextId} executionContextId |
| 593 * @param {string} hash | |
| 594 * @param {boolean} isContentScript | 593 * @param {boolean} isContentScript |
| 595 * @param {boolean} isInternalScript | 594 * @param {boolean} isInternalScript |
| 596 * @param {boolean} isLiveEdit | 595 * @param {boolean} isLiveEdit |
| 596 * @param {string=} hash | |
| 597 * @param {string=} sourceMapURL | 597 * @param {string=} sourceMapURL |
| 598 * @param {boolean=} hasSourceURL | 598 * @param {boolean=} hasSourceURL |
| 599 * @param {boolean=} deprecatedCommentWasUsed | 599 * @param {boolean=} deprecatedCommentWasUsed |
| 600 * @param {boolean=} hasSyntaxError | 600 * @param {boolean=} hasSyntaxError |
| 601 * @return {!WebInspector.Script} | 601 * @return {!WebInspector.Script} |
| 602 */ | 602 */ |
| 603 _parsedScriptSource: function(scriptId, sourceURL, startLine, startColumn, e ndLine, endColumn, executionContextId, hash, isContentScript, isInternalScript, isLiveEdit, sourceMapURL, hasSourceURL, deprecatedCommentWasUsed, hasSyntaxError ) | 603 _parsedScriptSource: function(scriptId, sourceURL, startLine, startColumn, e ndLine, endColumn, executionContextId, isContentScript, isInternalScript, isLive Edit, hash, sourceMapURL, hasSourceURL, deprecatedCommentWasUsed, hasSyntaxError ) |
| 604 { | 604 { |
| 605 var script = new WebInspector.Script(this, scriptId, sourceURL, startLin e, startColumn, endLine, endColumn, executionContextId, hash, isContentScript, i sInternalScript, isLiveEdit, sourceMapURL, hasSourceURL); | 605 var script = new WebInspector.Script(this, scriptId, sourceURL, startLin e, startColumn, endLine, endColumn, executionContextId, isContentScript, isInter nalScript, isLiveEdit, hash, sourceMapURL, hasSourceURL); |
| 606 this._registerScript(script); | 606 this._registerScript(script); |
| 607 if (!hasSyntaxError) | 607 if (!hasSyntaxError) |
| 608 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Pars edScriptSource, script); | 608 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Pars edScriptSource, script); |
| 609 else | 609 else |
| 610 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Fail edToParseScriptSource, script); | 610 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Fail edToParseScriptSource, script); |
| 611 | 611 |
| 612 if (deprecatedCommentWasUsed) { | 612 if (deprecatedCommentWasUsed) { |
| 613 var text = WebInspector.UIString("'//@ sourceURL' and '//@ sourceMap pingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead."); | 613 var text = WebInspector.UIString("'//@ sourceURL' and '//@ sourceMap pingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead."); |
| 614 var msg = new WebInspector.ConsoleMessage(this.target(), WebInspecto r.ConsoleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageLevel.Warn ing, text, undefined, undefined, undefined, undefined, undefined, undefined, und efined, undefined, undefined, scriptId); | 614 var msg = new WebInspector.ConsoleMessage(this.target(), WebInspecto r.ConsoleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageLevel.Warn ing, text, undefined, undefined, undefined, undefined, undefined, undefined, und efined, undefined, undefined, scriptId); |
| 615 var consoleModel = this.target().consoleModel; | 615 var consoleModel = this.target().consoleModel; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 630 | 630 |
| 631 var scripts = this._scriptsBySourceURL.get(script.sourceURL); | 631 var scripts = this._scriptsBySourceURL.get(script.sourceURL); |
| 632 if (!scripts) { | 632 if (!scripts) { |
| 633 scripts = []; | 633 scripts = []; |
| 634 this._scriptsBySourceURL.set(script.sourceURL, scripts); | 634 this._scriptsBySourceURL.set(script.sourceURL, scripts); |
| 635 } | 635 } |
| 636 scripts.push(script); | 636 scripts.push(script); |
| 637 }, | 637 }, |
| 638 | 638 |
| 639 /** | 639 /** |
| 640 * @param {!Array<!DebuggerAgent.BlackboxPattern>} patterns | |
| 641 * @return {!Promise<boolean>} | |
| 642 */ | |
| 643 addBlackboxPatterns: function(patterns) | |
| 644 { | |
| 645 return new Promise(addBlackboxPatterns.bind(this)); | |
|
dgozman
2016/03/08 18:48:12
Let's use lushnikov's wisdom:
var promiseCallback
| |
| 646 | |
| 647 /** | |
| 648 * @param {function(?)} fulfill | |
| 649 * @param {function(*)} reject | |
| 650 * @this {WebInspector.DebuggerModel} | |
| 651 */ | |
| 652 function addBlackboxPatterns(fulfill, reject) | |
| 653 { | |
| 654 this._agent.addBlackboxPatterns(patterns, callback); | |
| 655 /** | |
| 656 * @param {?Protocol.Error} error | |
| 657 */ | |
| 658 function callback(error) | |
| 659 { | |
| 660 if (error) | |
| 661 console.error(error); | |
| 662 fulfill(!error); | |
| 663 } | |
| 664 } | |
| 665 }, | |
| 666 | |
| 667 /** | |
| 668 * @return {!Promise<boolean>} | |
| 669 */ | |
| 670 clearBlackboxPatterns: function() | |
| 671 { | |
| 672 return new Promise(clearBlackboxPatterns.bind(this)); | |
| 673 | |
| 674 /** | |
| 675 * @param {function(?)} fulfill | |
| 676 * @param {function(*)} reject | |
| 677 * @this {WebInspector.DebuggerModel} | |
| 678 */ | |
| 679 function clearBlackboxPatterns(fulfill, reject) | |
| 680 { | |
| 681 this._agent.clearBlackboxPatterns(callback); | |
| 682 /** | |
| 683 * @param {?Protocol.Error} error | |
| 684 */ | |
| 685 function callback(error) | |
| 686 { | |
| 687 if (error) | |
| 688 console.error(error); | |
| 689 fulfill(!error); | |
| 690 } | |
| 691 } | |
| 692 }, | |
| 693 | |
| 694 /** | |
| 640 * @param {!WebInspector.Script} script | 695 * @param {!WebInspector.Script} script |
| 641 * @param {number} lineNumber | 696 * @param {number} lineNumber |
| 642 * @param {number} columnNumber | 697 * @param {number} columnNumber |
| 643 * @return {?WebInspector.DebuggerModel.Location} | 698 * @return {?WebInspector.DebuggerModel.Location} |
| 644 */ | 699 */ |
| 645 createRawLocation: function(script, lineNumber, columnNumber) | 700 createRawLocation: function(script, lineNumber, columnNumber) |
| 646 { | 701 { |
| 647 if (script.sourceURL) | 702 if (script.sourceURL) |
| 648 return this.createRawLocationByURL(script.sourceURL, lineNumber, col umnNumber); | 703 return this.createRawLocationByURL(script.sourceURL, lineNumber, col umnNumber); |
| 649 return new WebInspector.DebuggerModel.Location(this, script.scriptId, li neNumber, columnNumber); | 704 return new WebInspector.DebuggerModel.Location(this, script.scriptId, li neNumber, columnNumber); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 980 | 1035 |
| 981 /** | 1036 /** |
| 982 * @override | 1037 * @override |
| 983 * @param {!RuntimeAgent.ScriptId} scriptId | 1038 * @param {!RuntimeAgent.ScriptId} scriptId |
| 984 * @param {string} sourceURL | 1039 * @param {string} sourceURL |
| 985 * @param {number} startLine | 1040 * @param {number} startLine |
| 986 * @param {number} startColumn | 1041 * @param {number} startColumn |
| 987 * @param {number} endLine | 1042 * @param {number} endLine |
| 988 * @param {number} endColumn | 1043 * @param {number} endColumn |
| 989 * @param {!RuntimeAgent.ExecutionContextId} executionContextId | 1044 * @param {!RuntimeAgent.ExecutionContextId} executionContextId |
| 990 * @param {string} hash | |
| 991 * @param {boolean=} isContentScript | 1045 * @param {boolean=} isContentScript |
| 992 * @param {boolean=} isInternalScript | 1046 * @param {boolean=} isInternalScript |
| 993 * @param {boolean=} isLiveEdit | 1047 * @param {boolean=} isLiveEdit |
| 1048 * @param {string=} hash | |
| 994 * @param {string=} sourceMapURL | 1049 * @param {string=} sourceMapURL |
| 995 * @param {boolean=} hasSourceURL | 1050 * @param {boolean=} hasSourceURL |
| 996 * @param {boolean=} deprecatedCommentWasUsed | 1051 * @param {boolean=} deprecatedCommentWasUsed |
| 997 */ | 1052 */ |
| 998 scriptParsed: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, executionContextId, hash, isContentScript, isInternalScript, isLiveE dit, sourceMapURL, hasSourceURL, deprecatedCommentWasUsed) | 1053 scriptParsed: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, executionContextId, isContentScript, isInternalScript, isLiveEdit, h ash, sourceMapURL, hasSourceURL, deprecatedCommentWasUsed) |
| 999 { | 1054 { |
| 1000 this._debuggerModel._parsedScriptSource(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, executionContextId, hash, !!isContentScript, !! isInternalScript, !!isLiveEdit, sourceMapURL, hasSourceURL, deprecatedCommentWas Used, false); | 1055 this._debuggerModel._parsedScriptSource(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, executionContextId, !!isContentScript, !!isInte rnalScript, !!isLiveEdit, hash, sourceMapURL, hasSourceURL, deprecatedCommentWas Used, false); |
| 1001 }, | 1056 }, |
| 1002 | 1057 |
| 1003 /** | 1058 /** |
| 1004 * @override | 1059 * @override |
| 1005 * @param {!RuntimeAgent.ScriptId} scriptId | 1060 * @param {!RuntimeAgent.ScriptId} scriptId |
| 1006 * @param {string} sourceURL | 1061 * @param {string} sourceURL |
| 1007 * @param {number} startLine | 1062 * @param {number} startLine |
| 1008 * @param {number} startColumn | 1063 * @param {number} startColumn |
| 1009 * @param {number} endLine | 1064 * @param {number} endLine |
| 1010 * @param {number} endColumn | 1065 * @param {number} endColumn |
| 1011 * @param {!RuntimeAgent.ExecutionContextId} executionContextId | 1066 * @param {!RuntimeAgent.ExecutionContextId} executionContextId |
| 1012 * @param {string} hash | |
| 1013 * @param {boolean=} isContentScript | 1067 * @param {boolean=} isContentScript |
| 1014 * @param {boolean=} isInternalScript | 1068 * @param {boolean=} isInternalScript |
| 1069 * @param {string=} hash | |
| 1015 * @param {string=} sourceMapURL | 1070 * @param {string=} sourceMapURL |
| 1016 * @param {boolean=} hasSourceURL | 1071 * @param {boolean=} hasSourceURL |
| 1017 * @param {boolean=} deprecatedCommentWasUsed | 1072 * @param {boolean=} deprecatedCommentWasUsed |
| 1018 */ | 1073 */ |
| 1019 scriptFailedToParse: function(scriptId, sourceURL, startLine, startColumn, e ndLine, endColumn, executionContextId, hash, isContentScript, isInternalScript, sourceMapURL, hasSourceURL, deprecatedCommentWasUsed) | 1074 scriptFailedToParse: function(scriptId, sourceURL, startLine, startColumn, e ndLine, endColumn, executionContextId, isContentScript, isInternalScript, hash, sourceMapURL, hasSourceURL, deprecatedCommentWasUsed) |
| 1020 { | 1075 { |
| 1021 this._debuggerModel._parsedScriptSource(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, executionContextId, hash, !!isContentScript, !! isInternalScript, false, sourceMapURL, hasSourceURL, deprecatedCommentWasUsed, t rue); | 1076 this._debuggerModel._parsedScriptSource(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, executionContextId, !!isContentScript, !!isInte rnalScript, false, hash, sourceMapURL, hasSourceURL, deprecatedCommentWasUsed, t rue); |
| 1022 }, | 1077 }, |
| 1023 | 1078 |
| 1024 /** | 1079 /** |
| 1025 * @override | 1080 * @override |
| 1026 * @param {!DebuggerAgent.BreakpointId} breakpointId | 1081 * @param {!DebuggerAgent.BreakpointId} breakpointId |
| 1027 * @param {!DebuggerAgent.Location} location | 1082 * @param {!DebuggerAgent.Location} location |
| 1028 */ | 1083 */ |
| 1029 breakpointResolved: function(breakpointId, location) | 1084 breakpointResolved: function(breakpointId, location) |
| 1030 { | 1085 { |
| 1031 this._debuggerModel._breakpointResolved(breakpointId, location); | 1086 this._debuggerModel._breakpointResolved(breakpointId, location); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1445 /** | 1500 /** |
| 1446 * @param {?WebInspector.Target} target | 1501 * @param {?WebInspector.Target} target |
| 1447 * @return {?WebInspector.DebuggerModel} | 1502 * @return {?WebInspector.DebuggerModel} |
| 1448 */ | 1503 */ |
| 1449 WebInspector.DebuggerModel.fromTarget = function(target) | 1504 WebInspector.DebuggerModel.fromTarget = function(target) |
| 1450 { | 1505 { |
| 1451 if (!target || !target.hasJSContext()) | 1506 if (!target || !target.hasJSContext()) |
| 1452 return null; | 1507 return null; |
| 1453 return /** @type {?WebInspector.DebuggerModel} */ (target.model(WebInspector .DebuggerModel)); | 1508 return /** @type {?WebInspector.DebuggerModel} */ (target.model(WebInspector .DebuggerModel)); |
| 1454 } | 1509 } |
| OLD | NEW |