2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
33 * @extends {WebInspector.Object}
34 * @param {!WebInspector.Setting} breakpointStorage
35 * @param {!WebInspector.DebuggerModel} debuggerModel
36 * @param {!WebInspector.Workspace} workspace
38 WebInspector.BreakpointManager = function(breakpointStorage, debuggerModel, workspace)
40 this._storage = new WebInspector.BreakpointManager.Storage(this, breakpointStorage);
41 this._debuggerModel = debuggerModel;
42 this._workspace = workspace;
44 this._breakpointForDebuggerId = {};
45 this._breakpointsForUISourceCode = new Map();
46 this._breakpointsForPrimaryUISourceCode = new Map();
47 this._sourceFilesWithRestoredBreakpoints = {};
49 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointResolved, this._breakpointResolved, this);
50 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._projectWillReset, this);
51 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this);
52 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this);
55 WebInspector.BreakpointManager.Events = {
56 BreakpointAdded: "breakpoint-added",
57 BreakpointRemoved: "breakpoint-removed"
60 WebInspector.BreakpointManager._sourceFileId = function(uiSourceCode)
62 if (!uiSourceCode.url)
64 var deobfuscatedPrefix = uiSourceCode.formatted() ? "deobfuscated:" : "";
65 return deobfuscatedPrefix + uiSourceCode.uri();
69 * @param {string} sourceFileId
70 * @param {number} lineNumber
71 * @param {number} columnNumber
74 WebInspector.BreakpointManager._breakpointStorageId = function(sourceFileId, lineNumber, columnNumber)
78 return sourceFileId + ":" + lineNumber + ":" + columnNumber;
81 WebInspector.BreakpointManager.prototype = {
83 * @param {string} sourceFileId
85 _provisionalBreakpointsForSourceFileId: function(sourceFileId)
87 var result = new StringMap();
88 for (var debuggerId in this._breakpointForDebuggerId) {
89 var breakpoint = this._breakpointForDebuggerId[debuggerId];
90 if (breakpoint._sourceFileId === sourceFileId)
91 result.put(breakpoint._breakpointStorageId(), breakpoint);
97 * @param {!WebInspector.UISourceCode} uiSourceCode
99 _restoreBreakpoints: function(uiSourceCode)
101 var sourceFileId = WebInspector.BreakpointManager._sourceFileId(uiSourceCode);
102 if (!sourceFileId || this._sourceFilesWithRestoredBreakpoints[sourceFileId])
104 this._sourceFilesWithRestoredBreakpoints[sourceFileId] = true;
106 this._storage.mute();
107 var breakpointItems = this._storage.breakpointItems(uiSourceCode);
108 var provisionalBreakpoints = this._provisionalBreakpointsForSourceFileId(sourceFileId);
109 for (var i = 0; i < breakpointItems.length; ++i) {
110 var breakpointItem = breakpointItems[i];
111 var itemStorageId = WebInspector.BreakpointManager._breakpointStorageId(breakpointItem.sourceFileId, breakpointItem.lineNumber, breakpointItem.columnNumber);
112 var provisionalBreakpoint = provisionalBreakpoints.get(itemStorageId);
113 if (provisionalBreakpoint) {
114 if (!this._breakpointsForPrimaryUISourceCode.get(uiSourceCode))
115 this._breakpointsForPrimaryUISourceCode.put(uiSourceCode, []);
116 this._breakpointsForPrimaryUISourceCode.get(uiSourceCode).push(provisionalBreakpoint);
117 provisionalBreakpoint._updateInDebugger();
119 this._innerSetBreakpoint(uiSourceCode, breakpointItem.lineNumber, breakpointItem.columnNumber, breakpointItem.condition, breakpointItem.enabled);
122 this._storage.unmute();
126 * @param {!WebInspector.Event} event
128 _uiSourceCodeAdded: function(event)
130 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
131 this._restoreBreakpoints(uiSourceCode);
132 if (uiSourceCode.contentType() === WebInspector.resourceTypes.Script || uiSourceCode.contentType() === WebInspector.resourceTypes.Document) {
133 uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.SourceMappingChanged, this._uiSourceCodeMappingChanged, this);
134 uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._uiSourceCodeFormatted, this);
139 * @param {!WebInspector.Event} event
141 _uiSourceCodeFormatted: function(event)
143 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.target);
144 this._restoreBreakpoints(uiSourceCode);
148 * @param {!WebInspector.Event} event
150 _uiSourceCodeRemoved: function(event)
152 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
153 this._removeUISourceCode(uiSourceCode);
157 * @param {!WebInspector.Event} event
159 _uiSourceCodeMappingChanged: function(event)
161 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.target);
162 var breakpoints = this._breakpointsForPrimaryUISourceCode.get(uiSourceCode) || [];
163 for (var i = 0; i < breakpoints.length; ++i)
164 breakpoints[i]._updateInDebugger();
168 * @param {!WebInspector.UISourceCode} uiSourceCode
170 _removeUISourceCode: function(uiSourceCode)
172 var breakpoints = this._breakpointsForPrimaryUISourceCode.get(uiSourceCode) || [];
173 for (var i = 0; i < breakpoints.length; ++i)
174 breakpoints[i]._resetLocations();
175 var sourceFileId = WebInspector.BreakpointManager._sourceFileId(uiSourceCode);
176 delete this._sourceFilesWithRestoredBreakpoints[sourceFileId];
177 uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._uiSourceCodeFormatted, this);
178 uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.SourceMappingChanged, this._uiSourceCodeMappingChanged, this);
179 this._breakpointsForPrimaryUISourceCode.remove(uiSourceCode);
183 * @param {!WebInspector.UISourceCode} uiSourceCode
184 * @param {number} lineNumber
185 * @param {number} columnNumber
186 * @param {string} condition
187 * @param {boolean} enabled
188 * @return {!WebInspector.BreakpointManager.Breakpoint}
190 setBreakpoint: function(uiSourceCode, lineNumber, columnNumber, condition, enabled)
192 this._debuggerModel.setBreakpointsActive(true);
193 return this._innerSetBreakpoint(uiSourceCode, lineNumber, columnNumber, condition, enabled);
197 * @param {!WebInspector.UISourceCode} uiSourceCode
198 * @param {number} lineNumber
199 * @param {number} columnNumber
200 * @param {string} condition
201 * @param {boolean} enabled
202 * @return {!WebInspector.BreakpointManager.Breakpoint}
204 _innerSetBreakpoint: function(uiSourceCode, lineNumber, columnNumber, condition, enabled)
206 var breakpoint = this.findBreakpoint(uiSourceCode, lineNumber, columnNumber);
208 breakpoint._updateBreakpoint(condition, enabled);
211 var projectId = uiSourceCode.project().id();
212 var path = uiSourceCode.path();
213 var sourceFileId = WebInspector.BreakpointManager._sourceFileId(uiSourceCode);
214 breakpoint = new WebInspector.BreakpointManager.Breakpoint(this, projectId, path, sourceFileId, lineNumber, columnNumber, condition, enabled);
215 if (!this._breakpointsForPrimaryUISourceCode.get(uiSourceCode))
216 this._breakpointsForPrimaryUISourceCode.put(uiSourceCode, []);
217 this._breakpointsForPrimaryUISourceCode.get(uiSourceCode).push(breakpoint);
222 * @param {!WebInspector.UISourceCode} uiSourceCode
223 * @param {number} lineNumber
224 * @param {number} columnNumber
225 * @return {?WebInspector.BreakpointManager.Breakpoint}
227 findBreakpoint: function(uiSourceCode, lineNumber, columnNumber)
229 var breakpoints = this._breakpointsForUISourceCode.get(uiSourceCode);
230 var lineBreakpoints = breakpoints ? breakpoints.get(String(lineNumber)) : null;
231 var columnBreakpoints = lineBreakpoints ? lineBreakpoints.get(String(columnNumber)) : null;
232 return columnBreakpoints ? columnBreakpoints[0] : null;
236 * @param {!WebInspector.UISourceCode} uiSourceCode
237 * @param {number} lineNumber
238 * @return {?WebInspector.BreakpointManager.Breakpoint}
240 findBreakpointOnLine: function(uiSourceCode, lineNumber)
242 var breakpoints = this._breakpointsForUISourceCode.get(uiSourceCode);
243 var lineBreakpoints = breakpoints ? breakpoints.get(String(lineNumber)) : null;
244 return lineBreakpoints ? lineBreakpoints.values()[0][0] : null;
248 * @param {!WebInspector.UISourceCode} uiSourceCode
249 * @return {!Array.<!WebInspector.BreakpointManager.Breakpoint>}
251 breakpointsForUISourceCode: function(uiSourceCode)
254 var uiSourceCodeBreakpoints = this._breakpointsForUISourceCode.get(uiSourceCode);
255 var breakpoints = uiSourceCodeBreakpoints ? uiSourceCodeBreakpoints.values() : [];
256 for (var i = 0; i < breakpoints.length; ++i) {
257 var lineBreakpoints = breakpoints[i];
258 var columnBreakpointArrays = lineBreakpoints ? lineBreakpoints.values() : [];
259 result = result.concat.apply(result, columnBreakpointArrays);
265 * @return {!Array.<!WebInspector.BreakpointManager.Breakpoint>}
267 allBreakpoints: function()
270 var uiSourceCodes = this._breakpointsForUISourceCode.keys();
271 for (var i = 0; i < uiSourceCodes.length; ++i)
272 result = result.concat(this.breakpointsForUISourceCode(uiSourceCodes[i]));
277 * @param {!WebInspector.UISourceCode} uiSourceCode
278 * @return {!Array.<!{breakpoint: !WebInspector.BreakpointManager.Breakpoint, uiLocation: !WebInspector.UILocation}>}
280 breakpointLocationsForUISourceCode: function(uiSourceCode)
282 var uiSourceCodeBreakpoints = this._breakpointsForUISourceCode.get(uiSourceCode);
283 var lineNumbers = uiSourceCodeBreakpoints ? uiSourceCodeBreakpoints.keys() : [];
285 for (var i = 0; i < lineNumbers.length; ++i) {
286 var lineBreakpoints = uiSourceCodeBreakpoints.get(lineNumbers[i]);
287 var columnNumbers = lineBreakpoints.keys();
288 for (var j = 0; j < columnNumbers.length; ++j) {
289 var columnBreakpoints = lineBreakpoints.get(columnNumbers[j]);
290 var lineNumber = parseInt(lineNumbers[i], 10);
291 var columnNumber = parseInt(columnNumbers[j], 10);
292 for (var k = 0; k < columnBreakpoints.length; ++k) {
293 var breakpoint = columnBreakpoints[k];
294 var uiLocation = new WebInspector.UILocation(uiSourceCode, lineNumber, columnNumber);
295 result.push({breakpoint: breakpoint, uiLocation: uiLocation});
303 * @return {!Array.<!{breakpoint: !WebInspector.BreakpointManager.Breakpoint, uiLocation: !WebInspector.UILocation}>}
305 allBreakpointLocations: function()
308 var uiSourceCodes = this._breakpointsForUISourceCode.keys();
309 for (var i = 0; i < uiSourceCodes.length; ++i)
310 result = result.concat(this.breakpointLocationsForUISourceCode(uiSourceCodes[i]));
315 * @param {boolean} toggleState
317 toggleAllBreakpoints: function(toggleState)
319 var breakpoints = this.allBreakpoints();
320 for (var i = 0; i < breakpoints.length; ++i)
321 breakpoints[i].setEnabled(toggleState);
324 removeAllBreakpoints: function()
326 var breakpoints = this.allBreakpoints();
327 for (var i = 0; i < breakpoints.length; ++i)
328 breakpoints[i].remove();
331 removeProvisionalBreakpoints: function()
333 for (var debuggerId in this._breakpointForDebuggerId)
334 this._debuggerModel.removeBreakpoint(debuggerId);
337 _projectWillReset: function(event)
339 var project = /** @type {!WebInspector.Project} */ (event.data);
340 var uiSourceCodes = project.uiSourceCodes();
341 for (var i = 0; i < uiSourceCodes.length; ++i)
342 this._removeUISourceCode(uiSourceCodes[i]);
345 _breakpointResolved: function(event)
347 var breakpointId = /** @type {!DebuggerAgent.BreakpointId} */ (event.data.breakpointId);
348 var location = /** @type {!WebInspector.DebuggerModel.Location} */ (event.data.location);
349 var breakpoint = this._breakpointForDebuggerId[breakpointId];
352 breakpoint._addResolvedLocation(location);
356 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
357 * @param {boolean} removeFromStorage
359 _removeBreakpoint: function(breakpoint, removeFromStorage)
361 var uiSourceCode = breakpoint.uiSourceCode();
362 var breakpoints = uiSourceCode ? this._breakpointsForPrimaryUISourceCode.get(uiSourceCode) || [] : [];
363 var index = breakpoints.indexOf(breakpoint);
365 breakpoints.splice(index, 1);
366 console.assert(!breakpoint._debuggerId)
367 if (removeFromStorage)
368 this._storage._removeBreakpoint(breakpoint);
372 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
373 * @param {!WebInspector.UILocation} uiLocation
375 _uiLocationAdded: function(breakpoint, uiLocation)
377 var breakpoints = this._breakpointsForUISourceCode.get(uiLocation.uiSourceCode);
379 breakpoints = new StringMap();
380 this._breakpointsForUISourceCode.put(uiLocation.uiSourceCode, breakpoints);
382 var lineBreakpoints = breakpoints.get(String(uiLocation.lineNumber));
383 if (!lineBreakpoints) {
384 lineBreakpoints = new StringMap();
385 breakpoints.put(String(uiLocation.lineNumber), lineBreakpoints);
387 var columnBreakpoints = lineBreakpoints.get(String(uiLocation.columnNumber));
388 if (!columnBreakpoints) {
389 columnBreakpoints = [];
390 lineBreakpoints.put(String(uiLocation.columnNumber), columnBreakpoints);
392 columnBreakpoints.push(breakpoint);
393 this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.BreakpointAdded, {breakpoint: breakpoint, uiLocation: uiLocation});
397 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
398 * @param {!WebInspector.UILocation} uiLocation
400 _uiLocationRemoved: function(breakpoint, uiLocation)
402 var breakpoints = this._breakpointsForUISourceCode.get(uiLocation.uiSourceCode);
406 var lineBreakpoints = breakpoints.get(String(uiLocation.lineNumber));
407 if (!lineBreakpoints)
409 var columnBreakpoints = lineBreakpoints.get(String(uiLocation.columnNumber));
410 if (!columnBreakpoints)
412 columnBreakpoints.remove(breakpoint);
413 if (!columnBreakpoints.length)
414 lineBreakpoints.remove(String(uiLocation.columnNumber));
415 if (!lineBreakpoints.size())
416 breakpoints.remove(String(uiLocation.lineNumber));
417 if (!breakpoints.size())
418 this._breakpointsForUISourceCode.remove(uiLocation.uiSourceCode);
419 this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.BreakpointRemoved, {breakpoint: breakpoint, uiLocation: uiLocation});
422 __proto__: WebInspector.Object.prototype
427 * @param {!WebInspector.BreakpointManager} breakpointManager
428 * @param {string} projectId
429 * @param {string} path
430 * @param {string} sourceFileId
431 * @param {number} lineNumber
432 * @param {number} columnNumber
433 * @param {string} condition
434 * @param {boolean} enabled
436 WebInspector.BreakpointManager.Breakpoint = function(breakpointManager, projectId, path, sourceFileId, lineNumber, columnNumber, condition, enabled)
438 this._breakpointManager = breakpointManager;
439 this._projectId = projectId;
441 this._lineNumber = lineNumber;
442 this._columnNumber = columnNumber;
443 this._sourceFileId = sourceFileId;
444 /** @type {!Array.<!WebInspector.Script.Location>} */
445 this._liveLocations = [];
446 /** @type {!Object.<string, !WebInspector.UILocation>} */
447 this._uiLocations = {};
449 // Force breakpoint update.
450 /** @type {string} */ this._condition;
451 /** @type {boolean} */ this._enabled;
452 this._updateBreakpoint(condition, enabled);
455 WebInspector.BreakpointManager.Breakpoint.prototype = {
459 projectId: function()
461 return this._projectId;
475 lineNumber: function()
477 return this._lineNumber;
483 columnNumber: function()
485 return this._columnNumber;
489 * @return {?WebInspector.UISourceCode}
491 uiSourceCode: function()
493 return this._breakpointManager._workspace.uiSourceCode(this._projectId, this._path);
497 * @param {!WebInspector.DebuggerModel.Location} location
499 _addResolvedLocation: function(location)
501 this._liveLocations.push(this._breakpointManager._debuggerModel.createLiveLocation(location, this._locationUpdated.bind(this, location)));
505 * @param {!WebInspector.DebuggerModel.Location} location
506 * @param {!WebInspector.UILocation} uiLocation
508 _locationUpdated: function(location, uiLocation)
510 var stringifiedLocation = location.scriptId + ":" + location.lineNumber + ":" + location.columnNumber;
511 var oldUILocation = /** @type {!WebInspector.UILocation} */ (this._uiLocations[stringifiedLocation]);
513 this._breakpointManager._uiLocationRemoved(this, oldUILocation);
514 if (this._uiLocations[""]) {
515 var defaultLocation = this._uiLocations[""];
516 delete this._uiLocations[""];
517 this._breakpointManager._uiLocationRemoved(this, defaultLocation);
519 this._uiLocations[stringifiedLocation] = uiLocation;
520 this._breakpointManager._uiLocationAdded(this, uiLocation);
528 return this._enabled;
532 * @param {boolean} enabled
534 setEnabled: function(enabled)
536 this._updateBreakpoint(this._condition, enabled);
542 condition: function()
544 return this._condition;
548 * @param {string} condition
550 setCondition: function(condition)
552 this._updateBreakpoint(condition, this._enabled);
556 * @param {string} condition
557 * @param {boolean} enabled
559 _updateBreakpoint: function(condition, enabled)
561 if (this._enabled === enabled && this._condition === condition)
563 this._removeFromDebugger();
564 this._enabled = enabled;
565 this._condition = condition;
566 this._breakpointManager._storage._updateBreakpoint(this);
567 this._fakeBreakpointAtPrimaryLocation();
568 this._updateInDebugger();
571 _updateInDebugger: function()
573 var uiSourceCode = this.uiSourceCode();
574 if (!uiSourceCode || !uiSourceCode.hasSourceMapping())
576 var scriptFile = uiSourceCode && uiSourceCode.scriptFile();
577 if (this._enabled && !(scriptFile && scriptFile.hasDivergedFromVM()))
578 this._setInDebugger();
582 * @param {boolean=} keepInStorage
584 remove: function(keepInStorage)
586 var removeFromStorage = !keepInStorage;
587 this._resetLocations();
588 this._removeFromDebugger();
589 this._breakpointManager._removeBreakpoint(this, removeFromStorage);
592 _setInDebugger: function()
594 this._removeFromDebugger();
595 var uiSourceCode = this._breakpointManager._workspace.uiSourceCode(this._projectId, this._path);
598 var rawLocation = uiSourceCode.uiLocationToRawLocation(this._lineNumber, this._columnNumber);
599 var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Location} */ (rawLocation);
600 if (debuggerModelLocation)
601 this._breakpointManager._debuggerModel.setBreakpointByScriptLocation(debuggerModelLocation, this._condition, this._didSetBreakpointInDebugger.bind(this));
602 else if (uiSourceCode.url)
603 this._breakpointManager._debuggerModel.setBreakpointByURL(uiSourceCode.url, this._lineNumber, this._columnNumber, this._condition, this._didSetBreakpointInDebugger.bind(this));
607 * @this {WebInspector.BreakpointManager.Breakpoint}
608 * @param {?DebuggerAgent.BreakpointId} breakpointId
609 * @param {!Array.<!WebInspector.DebuggerModel.Location>} locations
611 _didSetBreakpointInDebugger: function(breakpointId, locations)
614 this._resetLocations();
615 this._breakpointManager._removeBreakpoint(this, false);
619 this._debuggerId = breakpointId;
620 this._breakpointManager._breakpointForDebuggerId[breakpointId] = this;
622 if (!locations.length) {
623 this._fakeBreakpointAtPrimaryLocation();
627 this._resetLocations();
628 for (var i = 0; i < locations.length; ++i) {
629 var script = this._breakpointManager._debuggerModel.scriptForId(locations[i].scriptId);
630 var uiLocation = script.rawLocationToUILocation(locations[i].lineNumber, locations[i].columnNumber);
631 if (this._breakpointManager.findBreakpoint(uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber)) {
638 for (var i = 0; i < locations.length; ++i)
639 this._addResolvedLocation(locations[i]);
642 _removeFromDebugger: function()
644 if (!this._debuggerId)
646 this._breakpointManager._debuggerModel.removeBreakpoint(this._debuggerId);
647 delete this._breakpointManager._breakpointForDebuggerId[this._debuggerId];
648 delete this._debuggerId;
651 _resetLocations: function()
653 for (var stringifiedLocation in this._uiLocations)
654 this._breakpointManager._uiLocationRemoved(this, this._uiLocations[stringifiedLocation]);
655 for (var i = 0; i < this._liveLocations.length; ++i)
656 this._liveLocations[i].dispose();
657 this._liveLocations = [];
658 this._uiLocations = {};
664 _breakpointStorageId: function()
666 return WebInspector.BreakpointManager._breakpointStorageId(this._sourceFileId, this._lineNumber, this._columnNumber);
669 _fakeBreakpointAtPrimaryLocation: function()
671 this._resetLocations();
672 var uiSourceCode = this._breakpointManager._workspace.uiSourceCode(this._projectId, this._path);
675 var uiLocation = new WebInspector.UILocation(uiSourceCode, this._lineNumber, this._columnNumber);
676 this._uiLocations[""] = uiLocation;
677 this._breakpointManager._uiLocationAdded(this, uiLocation);
683 * @param {!WebInspector.BreakpointManager} breakpointManager
684 * @param {!WebInspector.Setting} setting
686 WebInspector.BreakpointManager.Storage = function(breakpointManager, setting)
688 this._breakpointManager = breakpointManager;
689 this._setting = setting;
690 var breakpoints = this._setting.get();
691 /** @type {!Object.<string, !WebInspector.BreakpointManager.Storage.Item>} */
692 this._breakpoints = {};
693 for (var i = 0; i < breakpoints.length; ++i) {
694 var breakpoint = /** @type {!WebInspector.BreakpointManager.Storage.Item} */ (breakpoints[i]);
695 breakpoint.columnNumber = breakpoint.columnNumber || 0;
696 this._breakpoints[breakpoint.sourceFileId + ":" + breakpoint.lineNumber + ":" + breakpoint.columnNumber] = breakpoint;
700 WebInspector.BreakpointManager.Storage.prototype = {
712 * @param {!WebInspector.UISourceCode} uiSourceCode
713 * @return {!Array.<!WebInspector.BreakpointManager.Storage.Item>}
715 breakpointItems: function(uiSourceCode)
718 var sourceFileId = WebInspector.BreakpointManager._sourceFileId(uiSourceCode);
719 for (var id in this._breakpoints) {
720 var breakpoint = this._breakpoints[id];
721 if (breakpoint.sourceFileId === sourceFileId)
722 result.push(breakpoint);
728 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
730 _updateBreakpoint: function(breakpoint)
732 if (this._muted || !breakpoint._breakpointStorageId())
734 this._breakpoints[breakpoint._breakpointStorageId()] = new WebInspector.BreakpointManager.Storage.Item(breakpoint);
739 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
741 _removeBreakpoint: function(breakpoint)
745 delete this._breakpoints[breakpoint._breakpointStorageId()];
751 var breakpointsArray = [];
752 for (var id in this._breakpoints)
753 breakpointsArray.push(this._breakpoints[id]);
754 this._setting.set(breakpointsArray);
760 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
762 WebInspector.BreakpointManager.Storage.Item = function(breakpoint)
764 this.sourceFileId = breakpoint._sourceFileId;
765 this.lineNumber = breakpoint.lineNumber();
766 this.columnNumber = breakpoint.columnNumber();
767 this.condition = breakpoint.condition();
768 this.enabled = breakpoint.enabled();
771 /** @type {!WebInspector.BreakpointManager} */
772 WebInspector.breakpointManager;