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 |
(...skipping 17 matching lines...) Expand all Loading... |
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 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.Object} |
34 * @implements {WebInspector.TargetManager.Observer} | 34 * @implements {WebInspector.TargetManager.Observer} |
35 * @param {!WebInspector.Setting} breakpointStorage | 35 * @param {!WebInspector.Setting} breakpointStorage |
36 * @param {!WebInspector.Workspace} workspace | 36 * @param {!WebInspector.Workspace} workspace |
37 * @param {!WebInspector.TargetManager} targetManager | 37 * @param {!WebInspector.TargetManager} targetManager |
| 38 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
38 */ | 39 */ |
39 WebInspector.BreakpointManager = function(breakpointStorage, workspace, targetMa
nager) | 40 WebInspector.BreakpointManager = function(breakpointStorage, workspace, targetMa
nager, debuggerWorkspaceBinding) |
40 { | 41 { |
41 this._storage = new WebInspector.BreakpointManager.Storage(this, breakpointS
torage); | 42 this._storage = new WebInspector.BreakpointManager.Storage(this, breakpointS
torage); |
42 this._workspace = workspace; | 43 this._workspace = workspace; |
43 this._targetManager = targetManager; | 44 this._targetManager = targetManager; |
| 45 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; |
44 | 46 |
45 this._breakpointsActive = true; | 47 this._breakpointsActive = true; |
46 this._breakpointsForUISourceCode = new Map(); | 48 this._breakpointsForUISourceCode = new Map(); |
47 this._breakpointsForPrimaryUISourceCode = new Map(); | 49 this._breakpointsForPrimaryUISourceCode = new Map(); |
48 /** @type {!StringMultimap.<!WebInspector.BreakpointManager.Breakpoint>} */ | 50 /** @type {!StringMultimap.<!WebInspector.BreakpointManager.Breakpoint>} */ |
49 this._provisionalBreakpoints = new StringMultimap(); | 51 this._provisionalBreakpoints = new StringMultimap(); |
50 | 52 |
51 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemove
d, this._projectRemoved, this); | 53 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemove
d, this._projectRemoved, this); |
52 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAdded, this); | 54 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAdded, this); |
53 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR
emoved, this._uiSourceCodeRemoved, this); | 55 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR
emoved, this._uiSourceCodeRemoved, this); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 this._updateState(condition, enabled); | 482 this._updateState(condition, enabled); |
481 this._breakpointManager._targetManager.observeTargets(this); | 483 this._breakpointManager._targetManager.observeTargets(this); |
482 } | 484 } |
483 | 485 |
484 WebInspector.BreakpointManager.Breakpoint.prototype = { | 486 WebInspector.BreakpointManager.Breakpoint.prototype = { |
485 /** | 487 /** |
486 * @param {!WebInspector.Target} target | 488 * @param {!WebInspector.Target} target |
487 */ | 489 */ |
488 targetAdded: function(target) | 490 targetAdded: function(target) |
489 { | 491 { |
490 this._targetBreakpoints.put(target, new WebInspector.BreakpointManager.T
argetBreakpoint(target, this)); | 492 this._targetBreakpoints.put(target, new WebInspector.BreakpointManager.T
argetBreakpoint(target, this, this._breakpointManager._debuggerWorkspaceBinding)
); |
491 }, | 493 }, |
492 | 494 |
493 /** | 495 /** |
494 * @param {!WebInspector.Target} target | 496 * @param {!WebInspector.Target} target |
495 */ | 497 */ |
496 targetRemoved: function(target) | 498 targetRemoved: function(target) |
497 { | 499 { |
498 var targetBreakpoint = this._targetBreakpoints.remove(target); | 500 var targetBreakpoint = this._targetBreakpoints.remove(target); |
499 targetBreakpoint._cleanUpAfterDebuggerIsGone(); | 501 targetBreakpoint._cleanUpAfterDebuggerIsGone(); |
500 targetBreakpoint._removeEventListeners(); | 502 targetBreakpoint._removeEventListeners(); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 for (var i = 0; i < targetBreakpoints.length; ++i) | 694 for (var i = 0; i < targetBreakpoints.length; ++i) |
693 targetBreakpoints[i]._resetLocations(); | 695 targetBreakpoints[i]._resetLocations(); |
694 } | 696 } |
695 } | 697 } |
696 | 698 |
697 /** | 699 /** |
698 * @constructor | 700 * @constructor |
699 * @extends {WebInspector.SDKObject} | 701 * @extends {WebInspector.SDKObject} |
700 * @param {!WebInspector.Target} target | 702 * @param {!WebInspector.Target} target |
701 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint | 703 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint |
| 704 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
702 */ | 705 */ |
703 WebInspector.BreakpointManager.TargetBreakpoint = function(target, breakpoint) | 706 WebInspector.BreakpointManager.TargetBreakpoint = function(target, breakpoint, d
ebuggerWorkspaceBinding) |
704 { | 707 { |
705 WebInspector.SDKObject.call(this, target); | 708 WebInspector.SDKObject.call(this, target); |
706 this._breakpoint = breakpoint; | 709 this._breakpoint = breakpoint; |
707 /** @type {!Array.<!WebInspector.Script.Location>} */ | 710 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; |
| 711 |
| 712 /** @type {!Array.<!WebInspector.DebuggerWorkspaceBinding.Location>} */ |
708 this._liveLocations = []; | 713 this._liveLocations = []; |
709 | 714 |
710 /** @type {!Object.<string, !WebInspector.UILocation>} */ | 715 /** @type {!Object.<string, !WebInspector.UILocation>} */ |
711 this._uiLocations = {}; | 716 this._uiLocations = {}; |
712 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debu
ggerWasDisabled, this._cleanUpAfterDebuggerIsGone, this); | 717 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debu
ggerWasDisabled, this._cleanUpAfterDebuggerIsGone, this); |
713 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debu
ggerWasEnabled, this._scheduleUpdateInDebugger, this); | 718 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debu
ggerWasEnabled, this._scheduleUpdateInDebugger, this); |
714 this._hasPendingUpdate = false; | 719 this._hasPendingUpdate = false; |
715 this._isUpdating = false; | 720 this._isUpdating = false; |
716 this._currentState = null; | 721 this._currentState = null; |
717 if (target.debuggerModel.debuggerEnabled()) | 722 if (target.debuggerModel.debuggerEnabled()) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 _scriptDiverged: function() | 771 _scriptDiverged: function() |
767 { | 772 { |
768 var uiSourceCode = this._breakpoint.uiSourceCode(); | 773 var uiSourceCode = this._breakpoint.uiSourceCode(); |
769 if (!uiSourceCode) | 774 if (!uiSourceCode) |
770 return false; | 775 return false; |
771 var scriptFile = uiSourceCode.scriptFileForTarget(this.target()); | 776 var scriptFile = uiSourceCode.scriptFileForTarget(this.target()); |
772 return !!scriptFile && scriptFile.hasDivergedFromVM(); | 777 return !!scriptFile && scriptFile.hasDivergedFromVM(); |
773 | 778 |
774 }, | 779 }, |
775 | 780 |
| 781 /** |
| 782 * @param {function()} callback |
| 783 */ |
776 _updateInDebugger: function(callback) | 784 _updateInDebugger: function(callback) |
777 { | 785 { |
| 786 if (this.target().isDetached()) { |
| 787 this._cleanUpAfterDebuggerIsGone(); |
| 788 callback(); |
| 789 return; |
| 790 } |
| 791 |
778 var uiSourceCode = this._breakpoint.uiSourceCode(); | 792 var uiSourceCode = this._breakpoint.uiSourceCode(); |
779 var lineNumber = this._breakpoint._lineNumber; | 793 var lineNumber = this._breakpoint._lineNumber; |
780 var columnNumber = this._breakpoint._columnNumber; | 794 var columnNumber = this._breakpoint._columnNumber; |
781 var condition = this._breakpoint.condition(); | 795 var condition = this._breakpoint.condition(); |
782 | 796 |
783 var debuggerLocation = uiSourceCode ? WebInspector.debuggerWorkspaceBind
ing.uiLocationToRawLocation(this.target(), uiSourceCode, lineNumber, columnNumbe
r) : null; | 797 var debuggerLocation = uiSourceCode ? this._debuggerWorkspaceBinding.uiL
ocationToRawLocation(this.target(), uiSourceCode, lineNumber, columnNumber) : nu
ll; |
784 var newState; | 798 var newState; |
785 if (this._breakpoint._isRemoved || !this._breakpoint.enabled() || this._
scriptDiverged()) | 799 if (this._breakpoint._isRemoved || !this._breakpoint.enabled() || this._
scriptDiverged()) |
786 newState = null; | 800 newState = null; |
787 else if (debuggerLocation) { | 801 else if (debuggerLocation) { |
788 var script = debuggerLocation.script(); | 802 var script = debuggerLocation.script(); |
789 if (script.sourceURL) | 803 if (script.sourceURL) |
790 newState = new WebInspector.BreakpointManager.Breakpoint.State(s
cript.sourceURL, null, debuggerLocation.lineNumber, debuggerLocation.columnNumbe
r, condition); | 804 newState = new WebInspector.BreakpointManager.Breakpoint.State(s
cript.sourceURL, null, debuggerLocation.lineNumber, debuggerLocation.columnNumbe
r, condition); |
791 else | 805 else |
792 newState = new WebInspector.BreakpointManager.Breakpoint.State(n
ull, debuggerLocation.scriptId, debuggerLocation.lineNumber, debuggerLocation.co
lumnNumber, condition) | 806 newState = new WebInspector.BreakpointManager.Breakpoint.State(n
ull, debuggerLocation.scriptId, debuggerLocation.lineNumber, debuggerLocation.co
lumnNumber, condition) |
793 } else if (this._breakpoint._currentState && this._breakpoint._currentSt
ate.url) { | 807 } else if (this._breakpoint._currentState && this._breakpoint._currentSt
ate.url) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 this._uiLocations[location.id()] = uiLocation; | 890 this._uiLocations[location.id()] = uiLocation; |
877 this._breakpoint._replaceUILocation(oldUILocation, uiLocation); | 891 this._breakpoint._replaceUILocation(oldUILocation, uiLocation); |
878 }, | 892 }, |
879 | 893 |
880 /** | 894 /** |
881 * @param {!WebInspector.DebuggerModel.Location} location | 895 * @param {!WebInspector.DebuggerModel.Location} location |
882 * @return {boolean} | 896 * @return {boolean} |
883 */ | 897 */ |
884 _addResolvedLocation: function(location) | 898 _addResolvedLocation: function(location) |
885 { | 899 { |
886 var uiLocation = WebInspector.debuggerWorkspaceBinding.rawLocationToUILo
cation(location); | 900 var uiLocation = this._debuggerWorkspaceBinding.rawLocationToUILocation(
location); |
887 var breakpoint = this._breakpoint._breakpointManager.findBreakpoint(uiLo
cation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber); | 901 var breakpoint = this._breakpoint._breakpointManager.findBreakpoint(uiLo
cation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber); |
888 if (breakpoint && breakpoint !== this._breakpoint) { | 902 if (breakpoint && breakpoint !== this._breakpoint) { |
889 // location clash | 903 // location clash |
890 this._breakpoint.remove(); | 904 this._breakpoint.remove(); |
891 return false; | 905 return false; |
892 } | 906 } |
893 this._liveLocations.push(WebInspector.debuggerWorkspaceBinding.createLiv
eLocation(location, this._locationUpdated.bind(this, location))); | 907 this._liveLocations.push(this._debuggerWorkspaceBinding.createLiveLocati
on(location, this._locationUpdated.bind(this, location))); |
894 return true; | 908 return true; |
895 }, | 909 }, |
896 | 910 |
897 _cleanUpAfterDebuggerIsGone: function() | 911 _cleanUpAfterDebuggerIsGone: function() |
898 { | 912 { |
899 this._resetLocations(); | 913 this._resetLocations(); |
900 if (this._debuggerId) | 914 if (this._debuggerId) |
901 this._didRemoveFromDebugger(function() {}); | 915 this._didRemoveFromDebugger(function() {}); |
902 }, | 916 }, |
903 | 917 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 { | 1042 { |
1029 this.sourceFileId = breakpoint._sourceFileId; | 1043 this.sourceFileId = breakpoint._sourceFileId; |
1030 this.lineNumber = breakpoint.lineNumber(); | 1044 this.lineNumber = breakpoint.lineNumber(); |
1031 this.columnNumber = breakpoint.columnNumber(); | 1045 this.columnNumber = breakpoint.columnNumber(); |
1032 this.condition = breakpoint.condition(); | 1046 this.condition = breakpoint.condition(); |
1033 this.enabled = breakpoint.enabled(); | 1047 this.enabled = breakpoint.enabled(); |
1034 } | 1048 } |
1035 | 1049 |
1036 /** @type {!WebInspector.BreakpointManager} */ | 1050 /** @type {!WebInspector.BreakpointManager} */ |
1037 WebInspector.breakpointManager; | 1051 WebInspector.breakpointManager; |
OLD | NEW |