2011-06-16 Pavel Podivilov <podivilov@chromium.org>
authorpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Jun 2011 12:40:35 +0000 (12:40 +0000)
committerpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Jun 2011 12:40:35 +0000 (12:40 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: breakpointsWithoutSourceFile values should be a maps, not arrays.
        https://bugs.webkit.org/show_bug.cgi?id=62714

        * inspector/front-end/DebuggerPresentationModel.js:
        (WebInspector.DebuggerPresentationModel.prototype._restoreBreakpoints):
        (WebInspector.DebuggerPresentationModel.prototype.setFormatSourceFiles):
        (WebInspector.DebuggerPresentationModel.prototype._restoreBreakpointsFromSettings):
        (WebInspector.DebuggerPresentationModel.prototype._saveBreakpoints):
        (WebInspector.DebuggerPresentationModel.prototype._reset):
        * inspector/front-end/Settings.js:
        (WebInspector.Settings):
        (WebInspector.Settings.prototype._set):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@89135 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
Source/WebCore/inspector/front-end/Settings.js

index 5b20470..ac211bc 100644 (file)
@@ -1,3 +1,20 @@
+2011-06-16  Pavel Podivilov  <podivilov@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: breakpointsWithoutSourceFile values should be a maps, not arrays.
+        https://bugs.webkit.org/show_bug.cgi?id=62714
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel.prototype._restoreBreakpoints):
+        (WebInspector.DebuggerPresentationModel.prototype.setFormatSourceFiles):
+        (WebInspector.DebuggerPresentationModel.prototype._restoreBreakpointsFromSettings):
+        (WebInspector.DebuggerPresentationModel.prototype._saveBreakpoints):
+        (WebInspector.DebuggerPresentationModel.prototype._reset):
+        * inspector/front-end/Settings.js:
+        (WebInspector.Settings):
+        (WebInspector.Settings.prototype._set):
+
 2011-06-17  Joone Hur  <joone.hur@collabora.co.uk>
 
         Reviewed by Martin Robinson.
index 1e2286a..55baea4 100644 (file)
@@ -159,8 +159,10 @@ WebInspector.DebuggerPresentationModel.prototype = {
     _restoreBreakpoints: function(sourceFile)
     {
         var pendingBreakpoints = this._breakpointsWithoutSourceFile[sourceFile.id];
-        for (var i = 0; pendingBreakpoints && i < pendingBreakpoints.length; ++i) {
-            var breakpointData = pendingBreakpoints[i];
+        if (!pendingBreakpoints)
+            return;
+        for (var lineNumber in pendingBreakpoints) {
+            var breakpointData = pendingBreakpoints[lineNumber];
             if ("debuggerId" in breakpointData) {
                 var breakpoint = new WebInspector.PresentationBreakpoint(sourceFile, breakpointData.lineNumber, breakpointData.condition, breakpointData.enabled);
                 this._bindDebuggerId(breakpoint, breakpointData.debuggerId);
@@ -253,8 +255,8 @@ WebInspector.DebuggerPresentationModel.prototype = {
 
         for (var id in this._breakpointsWithoutSourceFile) {
             var breakpoints = this._breakpointsWithoutSourceFile[id];
-            for (var i = 0; i < breakpoints.length; ++i)
-                this._removeBreakpointFromDebugger(breakpoints[i]);
+            for (var lineNumber in breakpoints)
+                this._removeBreakpointFromDebugger(breakpoints[lineNumber]);
         }
 
         var messages = this._messages;
@@ -521,10 +523,10 @@ WebInspector.DebuggerPresentationModel.prototype = {
             // Add breakpoint once source file becomes available.
             var pendingBreakpoints = this._breakpointsWithoutSourceFile[sourceFileId];
             if (!pendingBreakpoints) {
-                pendingBreakpoints = [];
+                pendingBreakpoints = {};
                 this._breakpointsWithoutSourceFile[sourceFileId] = pendingBreakpoints;
             }
-            pendingBreakpoints.push(breakpointData);
+            pendingBreakpoints[breakpointData.lineNumber] = breakpointData;
         }
     },
 
@@ -543,8 +545,11 @@ WebInspector.DebuggerPresentationModel.prototype = {
         }
 
         // Store not added breakpoints.
-        for (var sourceFileId in this._breakpointsWithoutSourceFile)
-            serializedBreakpoints = serializedBreakpoints.concat(this._breakpointsWithoutSourceFile[sourceFileId]);
+        for (var sourceFileId in this._breakpointsWithoutSourceFile) {
+            var breakpoints = this._breakpointsWithoutSourceFile[sourceFileId];
+            for (var lineNumber in breakpoints)
+                serializedBreakpoints.push(breakpoints[lineNumber]);
+        }
 
         // Sanitize debugger ids.
         for (var i = 0; i < serializedBreakpoints.length; ++i) {
@@ -624,10 +629,10 @@ WebInspector.DebuggerPresentationModel.prototype = {
             for (var line in sourceFile.breakpoints) {
                 var breakpoints = this._breakpointsWithoutSourceFile[sourceFile.id];
                 if (!breakpoints) {
-                    breakpoints = [];
+                    breakpoints = {};
                     this._breakpointsWithoutSourceFile[sourceFile.id] = breakpoints;
                 }
-                breakpoints.push(sourceFile.breakpoints[line].serialize());
+                breakpoints[line] = sourceFile.breakpoints[line].serialize();
             }
         }
 
index 9394b88..7adcfde 100644 (file)
@@ -79,11 +79,12 @@ WebInspector.Settings = function()
     this.installApplicationSetting("domBreakpoints", []);
     this.installApplicationSetting("xhrBreakpoints", []);
 
-    this._migrateSettings();
+    // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused
+    // periodical breakpoints duplication leading to inspector slowness.
+    if (window.localStorage.breakpoints && window.localStorage.breakpoints.length > 500000)
+        delete window.localStorage.breakpoints;
 }
 
-WebInspector.Settings.version = "1";
-
 WebInspector.Settings.prototype = {
     installApplicationSetting: function(key, defaultValue)
     {
@@ -110,21 +111,6 @@ WebInspector.Settings.prototype = {
     {
         if (window.localStorage != null)
             window.localStorage[key] = JSON.stringify(value);
-    },
-
-    _migrateSettings: function()
-    {
-        if (!window.localStorage)
-            return;
-        var version = localStorage.version;
-        if (version === WebInspector.Settings.version)
-            return;
-
-        var breakpointKeys = ["breakpoints", "eventListenerBreakpoints", "domBreakpoints", "xhrBreakpoints"];
-        for (var i = 0; i < breakpointKeys.length; i++)
-            delete localStorage[breakpointKeys[i]];
-
-        localStorage.version = WebInspector.Settings.version;
     }
 }