2011-02-02 Mikhail Naganov <mnaganov@chromium.org>
authormnaganov@chromium.org <mnaganov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Feb 2011 18:55:35 +0000 (18:55 +0000)
committermnaganov@chromium.org <mnaganov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Feb 2011 18:55:35 +0000 (18:55 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: [Chromium] Landing detailed heap snapshots, part 2.

        https://bugs.webkit.org/show_bug.cgi?id=53606

        Display progress while taking a snapshot, and hints while loading
        and parsing. This is needed because taking detailed heap snapshots
        takes time.

        * English.lproj/localizedStrings.js:
        * inspector/front-end/DetailedHeapshotView.js:
        (WebInspector.DetailedHeapshotProfileType.prototype.buttonClicked):
        * inspector/front-end/ProfilesPanel.js:
        (WebInspector.ProfilesPanel.prototype._reset):
        (WebInspector.ProfilesPanel.prototype._addProfileHeader):
        (WebInspector.ProfilesPanel.prototype.getProfiles):
        (WebInspector.ProfilesPanel.prototype.loadHeapSnapshot):
        (WebInspector.ProfilesPanel.prototype._finishHeapSnapshot.doParse):
        (WebInspector.ProfilesPanel.prototype._finishHeapSnapshot):
        (WebInspector.ProfilesPanel.prototype.takeHeapSnapshot):
        (WebInspector.ProfilesPanel.prototype._reportHeapSnapshotProgress):
        * inspector/front-end/SidebarTreeElement.js:
        (WebInspector.SidebarTreeElement.prototype.refreshTitles):

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

Source/WebCore/ChangeLog
Source/WebCore/English.lproj/localizedStrings.js
Source/WebCore/inspector/front-end/DetailedHeapshotView.js
Source/WebCore/inspector/front-end/ProfilesPanel.js
Source/WebCore/inspector/front-end/SidebarTreeElement.js

index 0fe849a..9652980 100644 (file)
@@ -1,3 +1,30 @@
+2011-02-02  Mikhail Naganov  <mnaganov@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: [Chromium] Landing detailed heap snapshots, part 2.
+
+        https://bugs.webkit.org/show_bug.cgi?id=53606
+
+        Display progress while taking a snapshot, and hints while loading
+        and parsing. This is needed because taking detailed heap snapshots
+        takes time.
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/DetailedHeapshotView.js:
+        (WebInspector.DetailedHeapshotProfileType.prototype.buttonClicked):
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype._reset):
+        (WebInspector.ProfilesPanel.prototype._addProfileHeader):
+        (WebInspector.ProfilesPanel.prototype.getProfiles):
+        (WebInspector.ProfilesPanel.prototype.loadHeapSnapshot):
+        (WebInspector.ProfilesPanel.prototype._finishHeapSnapshot.doParse):
+        (WebInspector.ProfilesPanel.prototype._finishHeapSnapshot):
+        (WebInspector.ProfilesPanel.prototype.takeHeapSnapshot):
+        (WebInspector.ProfilesPanel.prototype._reportHeapSnapshotProgress):
+        * inspector/front-end/SidebarTreeElement.js:
+        (WebInspector.SidebarTreeElement.prototype.refreshTitles):
+
 2011-02-02  David Hyatt  <hyatt@apple.com>
 
         Reviewed by Darin Adler.
index 0fb4be8..10cb757 100644 (file)
Binary files a/Source/WebCore/English.lproj/localizedStrings.js and b/Source/WebCore/English.lproj/localizedStrings.js differ
index cbe265c..5291bf2 100644 (file)
@@ -70,7 +70,7 @@ WebInspector.DetailedHeapshotProfileType.prototype = {
 
     buttonClicked: function()
     {
-        InspectorBackend.takeHeapSnapshot(true);
+        WebInspector.panels.profiles.takeHeapSnapshot(true);
     },
 
     get welcomeMessage()
index 653760b..b87ea7f 100644 (file)
@@ -195,7 +195,7 @@ WebInspector.ProfilesPanel.prototype = {
         this._profiles = [];
         this._profilesIdMap = {};
         this._profileGroups = {};
-        this._profileGroupsForLinks = {}
+        this._profileGroupsForLinks = {};
         this._profilesWereRequested = false;
 
         this.sidebarTreeElement.removeStyleClass("some-expandable");
@@ -259,6 +259,13 @@ WebInspector.ProfilesPanel.prototype = {
 
     _addProfileHeader: function(profile)
     {
+        if (this.hasTemporaryProfile(profile.typeId)) {
+            if (profile.typeId === WebInspector.CPUProfileType.TypeId)
+                this._removeProfileHeader(this._temporaryRecordingProfile);
+            else
+                this._removeProfileHeader(this._temporaryTakingSnapshot);
+        }
+
         var typeId = profile.typeId;
         var profileType = this.getProfileType(typeId);
         var sidebarParent = profileType.treeElement;
@@ -308,6 +315,7 @@ WebInspector.ProfilesPanel.prototype = {
         }
 
         var profileTreeElement = profileType.createSidebarTreeElementForProfile(profile);
+        profile.sideBarElement = profileTreeElement;
         profileTreeElement.small = small;
         if (alternateTitle)
             profileTreeElement.mainTitle = alternateTitle;
@@ -379,9 +387,11 @@ WebInspector.ProfilesPanel.prototype = {
     {
         var result = [];
         var profilesCount = this._profiles.length;
-        for (var i = 0; i < profilesCount; ++i)
-            if (this._profiles[i].typeId === typeId)
-                result.push(this._profiles[i]);
+        for (var i = 0; i < profilesCount; ++i) {
+            var profile = this._profiles[i];
+            if (!profile.isTemporary && profile.typeId === typeId)
+                result.push(profile);
+        }
         return result;
     },
 
@@ -399,17 +409,6 @@ WebInspector.ProfilesPanel.prototype = {
         return !!this._profilesIdMap[this._makeKey(profile.uid, profile.typeId)];
     },
 
-    updateProfile: function(profile)
-    {
-        var profilesCount = this._profiles.length;
-        for (var i = 0; i < profilesCount; ++i)
-            if (this._profiles[i].typeId === profile.typeId
-                && this._profiles[i].uid === profile.uid) {
-                this._profiles[i] = profile;
-                break;
-            }
-    },
-
     loadHeapSnapshot: function(uid, callback)
     {
         var profile = this._profilesIdMap[this._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)];
@@ -424,6 +423,7 @@ WebInspector.ProfilesPanel.prototype = {
             profile._is_loading = true;
             profile._callbacks = [callback];
             profile._json = "";
+            profile.sideBarElement.subtitle = WebInspector.UIString("Loading…");
             InspectorBackend.getProfile(profile.typeId, profile.uid);
         }
     },
@@ -445,13 +445,23 @@ WebInspector.ProfilesPanel.prototype = {
 
         var callbacks = profile._callbacks;
         delete profile._callbacks;
-        var loadedSnapshot = JSON.parse(profile._json);
-        delete profile._json;
-        delete profile._is_loading;
-        profile._loaded = true;
-        WebInspector.HeapSnapshotView.prototype.processLoadedSnapshot(profile, loadedSnapshot);
-        for (var i = 0; i < callbacks.length; ++i)
-            callbacks[i](profile);
+        profile.sideBarElement.subtitle = WebInspector.UIString("Parsing…");
+        window.setTimeout(doParse, 0);
+
+        function doParse()
+        {
+            var loadedSnapshot = JSON.parse(profile._json);
+            delete profile._json;
+            delete profile._is_loading;
+            profile._loaded = true;
+            profile.sideBarElement.subtitle = "";
+            if (!Preferences.detailedHeapProfiles)
+                WebInspector.HeapSnapshotView.prototype.processLoadedSnapshot(profile, loadedSnapshot);
+            else
+                WebInspector.DetailedHeapshotView.prototype.processLoadedSnapshot(profile, loadedSnapshot);
+            for (var i = 0; i < callbacks.length; ++i)
+                callbacks[i](profile);
+        }
     },
 
     showView: function(view)
@@ -635,8 +645,29 @@ WebInspector.ProfilesPanel.prototype = {
         this.updateProfileTypeButtons();
     },
 
+    takeHeapSnapshot: function(detailed)
+    {
+        if (!this.hasTemporaryProfile(WebInspector.HeapSnapshotProfileType.TypeId)) {
+            if (!this._temporaryTakingSnapshot) {
+                this._temporaryTakingSnapshot = {
+                    typeId: WebInspector.HeapSnapshotProfileType.TypeId,
+                    title: WebInspector.UIString("Snapshotting…"),
+                    uid: -1,
+                    isTemporary: true
+                };
+            }
+            this._addProfileHeader(this._temporaryTakingSnapshot);
+        }
+        InspectorBackend.takeHeapSnapshot(detailed);
+    },
+
     _reportHeapSnapshotProgress: function(done, total)
     {
+        if (this.hasTemporaryProfile(WebInspector.HeapSnapshotProfileType.TypeId)) {
+            this._temporaryTakingSnapshot.sideBarElement.subtitle = WebInspector.UIString("%.2f%%", (done / total) * 100);
+            if (done >= total)
+                this._removeProfileHeader(this._temporaryTakingSnapshot);
+        }
     }
 }
 
@@ -730,16 +761,6 @@ WebInspector.ProfileSidebarTreeElement.prototype = {
         this.refreshTitles();
     },
 
-    get subtitle()
-    {
-        // There is no subtitle.
-    },
-
-    set subtitle(x)
-    {
-        // Can't change subtitle.
-    },
-
     set searchMatches(matches)
     {
         if (!matches) {
index c08b0ef..a27c457 100644 (file)
@@ -164,8 +164,10 @@ WebInspector.SidebarTreeElement.prototype = {
             if (this.subtitleElement.textContent !== subtitle)
                 this.subtitleElement.textContent = subtitle;
             this.titlesElement.removeStyleClass("no-subtitle");
-        } else
+        } else {
+            this.subtitleElement.textContent = "";
             this.titlesElement.addStyleClass("no-subtitle");
+        }
     },
 
     isEventWithinDisclosureTriangle: function(event)