Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: Source/devtools/front_end/sdk/BreakpointManager.js

Issue 350153004: DevTools: Activate breakpoints in breakpointManager (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address vsevik's comment Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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 * @param {!WebInspector.Setting} breakpointStorage 35 * @param {!WebInspector.Setting} breakpointStorage
35 * @param {!WebInspector.Workspace} workspace 36 * @param {!WebInspector.Workspace} workspace
36 * @param {!WebInspector.TargetManager} targetManager 37 * @param {!WebInspector.TargetManager} targetManager
37 */ 38 */
38 WebInspector.BreakpointManager = function(breakpointStorage, workspace, targetMa nager) 39 WebInspector.BreakpointManager = function(breakpointStorage, workspace, targetMa nager)
39 { 40 {
40 this._storage = new WebInspector.BreakpointManager.Storage(this, breakpointS torage); 41 this._storage = new WebInspector.BreakpointManager.Storage(this, breakpointS torage);
41 this._workspace = workspace; 42 this._workspace = workspace;
42 this._targetManager = targetManager; 43 this._targetManager = targetManager;
43 44
45 this._breakpointsActive = true;
44 this._breakpointsForUISourceCode = new Map(); 46 this._breakpointsForUISourceCode = new Map();
45 this._breakpointsForPrimaryUISourceCode = new Map(); 47 this._breakpointsForPrimaryUISourceCode = new Map();
46 /** @type {!StringMultimap.<!WebInspector.BreakpointManager.Breakpoint>} */ 48 /** @type {!StringMultimap.<!WebInspector.BreakpointManager.Breakpoint>} */
47 this._provisionalBreakpoints = new StringMultimap(); 49 this._provisionalBreakpoints = new StringMultimap();
48 50
49 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemove d, this._projectRemoved, this); 51 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemove d, this._projectRemoved, this);
50 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAdded, this); 52 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAdded, this);
51 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR emoved, this._uiSourceCodeRemoved, this); 53 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR emoved, this._uiSourceCodeRemoved, this);
52 } 54 }
53 55
54 WebInspector.BreakpointManager.Events = { 56 WebInspector.BreakpointManager.Events = {
55 BreakpointAdded: "breakpoint-added", 57 BreakpointAdded: "breakpoint-added",
56 BreakpointRemoved: "breakpoint-removed" 58 BreakpointRemoved: "breakpoint-removed",
59 BreakpointsActiveStateChanged: "BreakpointsActiveStateChanged"
57 } 60 }
58 61
59 WebInspector.BreakpointManager._sourceFileId = function(uiSourceCode) 62 WebInspector.BreakpointManager._sourceFileId = function(uiSourceCode)
60 { 63 {
61 if (!uiSourceCode.url) 64 if (!uiSourceCode.url)
62 return ""; 65 return "";
63 return uiSourceCode.uri(); 66 return uiSourceCode.uri();
64 } 67 }
65 68
66 /** 69 /**
67 * @param {string} sourceFileId 70 * @param {string} sourceFileId
68 * @param {number} lineNumber 71 * @param {number} lineNumber
69 * @param {number} columnNumber 72 * @param {number} columnNumber
70 * @return {string} 73 * @return {string}
71 */ 74 */
72 WebInspector.BreakpointManager._breakpointStorageId = function(sourceFileId, lin eNumber, columnNumber) 75 WebInspector.BreakpointManager._breakpointStorageId = function(sourceFileId, lin eNumber, columnNumber)
73 { 76 {
74 if (!sourceFileId) 77 if (!sourceFileId)
75 return ""; 78 return "";
76 return sourceFileId + ":" + lineNumber + ":" + columnNumber; 79 return sourceFileId + ":" + lineNumber + ":" + columnNumber;
77 } 80 }
78 81
79 WebInspector.BreakpointManager.prototype = { 82 WebInspector.BreakpointManager.prototype = {
80 83
81 /** 84 /**
85 * @param {!WebInspector.Target} target
86 */
87 targetAdded: function(target) {
88 if (!this._breakpointsActive)
89 target.debuggerAgent().setBreakpointsActive(this._breakpointsActive) ;
90 },
91
92 /**
93 * @param {!WebInspector.Target} target
94 */
95 targetRemoved: function(target) { },
96
97
98 /**
82 * @param {string} sourceFileId 99 * @param {string} sourceFileId
83 * @return {!StringMap.<!WebInspector.BreakpointManager.Breakpoint>} 100 * @return {!StringMap.<!WebInspector.BreakpointManager.Breakpoint>}
84 */ 101 */
85 _provisionalBreakpointsForSourceFileId: function(sourceFileId) 102 _provisionalBreakpointsForSourceFileId: function(sourceFileId)
86 { 103 {
87 var result = new StringMap(); 104 var result = new StringMap();
88 var breakpoints = this._provisionalBreakpoints.get(sourceFileId).values( ); 105 var breakpoints = this._provisionalBreakpoints.get(sourceFileId).values( );
89 for (var i = 0; i < breakpoints.length; ++i) 106 for (var i = 0; i < breakpoints.length; ++i)
90 result.put(breakpoints[i]._breakpointStorageId(), breakpoints[i]); 107 result.put(breakpoints[i]._breakpointStorageId(), breakpoints[i]);
91 return result; 108 return result;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 /** 199 /**
183 * @param {!WebInspector.UISourceCode} uiSourceCode 200 * @param {!WebInspector.UISourceCode} uiSourceCode
184 * @param {number} lineNumber 201 * @param {number} lineNumber
185 * @param {number} columnNumber 202 * @param {number} columnNumber
186 * @param {string} condition 203 * @param {string} condition
187 * @param {boolean} enabled 204 * @param {boolean} enabled
188 * @return {!WebInspector.BreakpointManager.Breakpoint} 205 * @return {!WebInspector.BreakpointManager.Breakpoint}
189 */ 206 */
190 setBreakpoint: function(uiSourceCode, lineNumber, columnNumber, condition, e nabled) 207 setBreakpoint: function(uiSourceCode, lineNumber, columnNumber, condition, e nabled)
191 { 208 {
192 var targets = this._targetManager.targets(); 209 this.setBreakpointsActive(true);
193 for (var i = 0; i < targets.length; ++i)
194 targets[i].debuggerModel.setBreakpointsActive(true);
195 return this._innerSetBreakpoint(uiSourceCode, lineNumber, columnNumber, condition, enabled); 210 return this._innerSetBreakpoint(uiSourceCode, lineNumber, columnNumber, condition, enabled);
196 }, 211 },
197 212
198 /** 213 /**
199 * @param {!WebInspector.UISourceCode} uiSourceCode 214 * @param {!WebInspector.UISourceCode} uiSourceCode
200 * @param {number} lineNumber 215 * @param {number} lineNumber
201 * @param {number} columnNumber 216 * @param {number} columnNumber
202 * @param {string} condition 217 * @param {string} condition
203 * @param {boolean} enabled 218 * @param {boolean} enabled
204 * @return {!WebInspector.BreakpointManager.Breakpoint} 219 * @return {!WebInspector.BreakpointManager.Breakpoint}
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 columnBreakpoints.remove(breakpoint); 411 columnBreakpoints.remove(breakpoint);
397 if (!columnBreakpoints.length) 412 if (!columnBreakpoints.length)
398 lineBreakpoints.remove(String(uiLocation.columnNumber)); 413 lineBreakpoints.remove(String(uiLocation.columnNumber));
399 if (!lineBreakpoints.size()) 414 if (!lineBreakpoints.size())
400 breakpoints.remove(String(uiLocation.lineNumber)); 415 breakpoints.remove(String(uiLocation.lineNumber));
401 if (!breakpoints.size()) 416 if (!breakpoints.size())
402 this._breakpointsForUISourceCode.remove(uiLocation.uiSourceCode); 417 this._breakpointsForUISourceCode.remove(uiLocation.uiSourceCode);
403 this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.Brea kpointRemoved, {breakpoint: breakpoint, uiLocation: uiLocation}); 418 this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.Brea kpointRemoved, {breakpoint: breakpoint, uiLocation: uiLocation});
404 }, 419 },
405 420
421 /**
422 * @param {boolean} active
423 */
424 setBreakpointsActive: function(active)
425 {
426 if (this._breakpointsActive === active)
427 return;
428
429 this._breakpointsActive = active;
430 var targets = WebInspector.targetManager.targets();
431 for (var i = 0; i < targets.length; ++i)
432 targets[i].debuggerAgent().setBreakpointsActive(active);
433
434 this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.Brea kpointsActiveStateChanged, active);
435 },
436
437 /**
438 * @return {boolean}
439 */
440 breakpointsActive: function()
441 {
442 return this._breakpointsActive;
443 },
444
406 __proto__: WebInspector.Object.prototype 445 __proto__: WebInspector.Object.prototype
407 } 446 }
408 447
409 /** 448 /**
410 * @constructor 449 * @constructor
411 * @implements {WebInspector.TargetManager.Observer} 450 * @implements {WebInspector.TargetManager.Observer}
412 * @param {!WebInspector.BreakpointManager} breakpointManager 451 * @param {!WebInspector.BreakpointManager} breakpointManager
413 * @param {string} projectId 452 * @param {string} projectId
414 * @param {string} path 453 * @param {string} path
415 * @param {string} sourceFileId 454 * @param {string} sourceFileId
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 { 929 {
891 this.sourceFileId = breakpoint._sourceFileId; 930 this.sourceFileId = breakpoint._sourceFileId;
892 this.lineNumber = breakpoint.lineNumber(); 931 this.lineNumber = breakpoint.lineNumber();
893 this.columnNumber = breakpoint.columnNumber(); 932 this.columnNumber = breakpoint.columnNumber();
894 this.condition = breakpoint.condition(); 933 this.condition = breakpoint.condition();
895 this.enabled = breakpoint.enabled(); 934 this.enabled = breakpoint.enabled();
896 } 935 }
897 936
898 /** @type {!WebInspector.BreakpointManager} */ 937 /** @type {!WebInspector.BreakpointManager} */
899 WebInspector.breakpointManager; 938 WebInspector.breakpointManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698