Changeset 192771 in webkit


Ignore:
Timestamp:
Nov 25, 2015 12:53:51 PM (8 years ago)
Author:
BJ Burg
Message:

Web Inspector: save Inspector's breakpoints to localStorage whenever they are modified
https://bugs.webkit.org/show_bug.cgi?id=151581

Reviewed by Timothy Hatcher.

Serialize all breakpoints to the "breakpoints" Setting in local storage
whenever any breakpoint model object is added, removed, or modified.

Remove the old listener that attempted to save breakpoints on the
pagehide event. It did not fire in important scenarios like exiting
the browser via Cmd-Q or killing the process via Ctrl-C / SIGKILL.

This is not expected to be a performance problem because most people
do not keep thousands of breakpoints active, and breakpoints are not
set very often. If it's a problem, we can mitigate it with coalescing.

  • UserInterface/Controllers/DebuggerManager.js:

(WebInspector.DebuggerManager.prototype.addBreakpoint):
(WebInspector.DebuggerManager.prototype.removeBreakpoint):
(WebInspector.DebuggerManager.prototype._breakpointDisabledStateDidChange):
(WebInspector.DebuggerManager.prototype._saveBreakpoints):
(WebInspector.DebuggerManager.prototype._inspectorClosing): Deleted.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r192764 r192771  
     12015-11-24  Brian Burg  <bburg@apple.com>
     2
     3        Web Inspector: save Inspector's breakpoints to localStorage whenever they are modified
     4        https://bugs.webkit.org/show_bug.cgi?id=151581
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Serialize all breakpoints to the "breakpoints" Setting in local storage
     9        whenever any breakpoint model object is added, removed, or modified.
     10
     11        Remove the old listener that attempted to save breakpoints on the
     12        pagehide event. It did not fire in important scenarios like exiting
     13        the browser via Cmd-Q or killing the process via Ctrl-C / SIGKILL.
     14
     15        This is not expected to be a performance problem because most people
     16        do not keep thousands of breakpoints active, and breakpoints are not
     17        set very often. If it's a problem, we can mitigate it with coalescing.
     18
     19        * UserInterface/Controllers/DebuggerManager.js:
     20        (WebInspector.DebuggerManager.prototype.addBreakpoint):
     21        (WebInspector.DebuggerManager.prototype.removeBreakpoint):
     22        (WebInspector.DebuggerManager.prototype._breakpointDisabledStateDidChange):
     23        (WebInspector.DebuggerManager.prototype._saveBreakpoints):
     24        (WebInspector.DebuggerManager.prototype._inspectorClosing): Deleted.
     25
    1262015-11-24  Brian Burg  <bburg@apple.com>
    227
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js

    r190542 r192771  
    4242        WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
    4343
    44         window.addEventListener("pagehide", this._inspectorClosing.bind(this));
    45 
    4644        this._allExceptionsBreakpointEnabledSetting = new WebInspector.Setting("break-on-all-exceptions", false);
    4745        this._allUncaughtExceptionsBreakpointEnabledSetting = new WebInspector.Setting("break-on-all-uncaught-exceptions", false);
     
    363361            this._setBreakpoint(breakpoint, shouldSpeculativelyResolve ? speculativelyResolveBreakpoint.bind(null, breakpoint) : null);
    364362
     363        this._saveBreakpoints();
     364
    365365        if (!skipEventDispatch)
    366366            this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.BreakpointAdded, {breakpoint});
     
    403403        breakpoint.disabled = true;
    404404        breakpoint.clearActions();
     405
     406        this._saveBreakpoints();
    405407
    406408        this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.BreakpointRemoved, {breakpoint});
     
    765767    _breakpointDisabledStateDidChange(event)
    766768    {
    767         var breakpoint = event.target;
    768 
     769        this._saveBreakpoints();
     770
     771        let breakpoint = event.target;
    769772        if (breakpoint === this._allExceptionsBreakpoint) {
    770773            if (!breakpoint.disabled)
     
    791794    _breakpointEditablePropertyDidChange(event)
    792795    {
    793         var breakpoint = event.target;
     796        this._saveBreakpoints();
     797
     798        let breakpoint = event.target;
    794799        if (breakpoint.disabled)
    795800            return;
     
    863868    }
    864869
    865     _inspectorClosing(event)
    866     {
    867         this._saveBreakpoints();
    868     }
    869 
    870870    _saveBreakpoints()
    871871    {
    872         var savedBreakpoints = [];
    873 
    874         for (var i = 0; i < this._breakpoints.length; ++i) {
    875             var breakpoint = this._breakpoints[i];
    876 
    877             // Only breakpoints with URLs can be saved. Breakpoints for transient scripts can't.
    878             if (!breakpoint.url)
    879                 continue;
    880 
    881             savedBreakpoints.push(breakpoint.info);
    882         }
    883 
    884         this._breakpointsSetting.value = savedBreakpoints;
     872        if (this._restoringBreakpoints)
     873            return;
     874
     875        let breakpointsToSave = this._breakpoints.filter((breakpoint) => !!breakpoint.url);
     876        let serializedBreakpoints = breakpointsToSave.map((breakpoint) => breakpoint.info);
     877        this._breakpointsSetting.value = serializedBreakpoints;
    885878    }
    886879
Note: See TracChangeset for help on using the changeset viewer.