[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

mnaganov at chromium.org mnaganov at chromium.org
Sun Feb 20 23:48:58 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 8d2d9a40e7f4e1d7d3093701dcb938d7c4cbe5f0
Author: mnaganov at chromium.org <mnaganov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jan 25 17:11:06 2011 +0000

    2011-01-25  Mikhail Naganov  <mnaganov at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: [Chromium] Prepare for landing of detailed heap snapshots.
    
            - Introduce Preferences.detailedHeapProfiles flag for controlling
              querying of detailed heap snapshots.
            - Add boilerplate code for the new view.
            - Factor out common code.
    
            https://bugs.webkit.org/show_bug.cgi?id=52624
    
            * WebCore.gypi:
            * WebCore.vcproj/WebCore.vcproj:
            * bindings/js/ScriptProfiler.h:
            (WebCore::ScriptProfiler::HeapSnapshotControl::~HeapSnapshotControl):
            (WebCore::ScriptProfiler::takeHeapSnapshot):
            * bindings/v8/ScriptProfiler.cpp:
            (WebCore::ScriptProfiler::takeHeapSnapshot):
            * bindings/v8/ScriptProfiler.h:
            (WebCore::ScriptProfiler::HeapSnapshotControl::~HeapSnapshotControl):
            * inspector/Inspector.idl:
            * inspector/InspectorProfilerAgent.cpp:
            (WebCore::InspectorProfilerAgent::takeHeapSnapshot):
            * inspector/InspectorProfilerAgent.h:
            * inspector/front-end/DetailedHeapshotView.js: Added.
            (WebInspector.DetailedHeapshotView):
            (WebInspector.DetailedHeapshotView.prototype.get statusBarItems):
            (WebInspector.DetailedHeapshotView.prototype.get profile):
            (WebInspector.DetailedHeapshotView.prototype.set profile):
            (WebInspector.DetailedHeapshotView.prototype.show):
            (WebInspector.DetailedHeapshotView.prototype.hide):
            (WebInspector.DetailedHeapshotProfileType):
            (WebInspector.DetailedHeapshotProfileType.prototype.get buttonTooltip):
            (WebInspector.DetailedHeapshotProfileType.prototype.get buttonStyle):
            (WebInspector.DetailedHeapshotProfileType.prototype.buttonClicked):
            (WebInspector.DetailedHeapshotProfileType.prototype.get welcomeMessage):
            (WebInspector.DetailedHeapshotProfileType.prototype.createSidebarTreeElementForProfile):
            (WebInspector.DetailedHeapshotProfileType.prototype.createView):
            * inspector/front-end/HeapSnapshot.js: Added.
            (WebInspector.HeapSnapshotEdgesIterator):
            (WebInspector.HeapSnapshotEdgesIterator.prototype.get done):
            (WebInspector.HeapSnapshotEdgesIterator.prototype.get isElement):
            (WebInspector.HeapSnapshotEdgesIterator.prototype.get isHidden):
            (WebInspector.HeapSnapshotEdgesIterator.prototype.get name):
            (WebInspector.HeapSnapshotEdgesIterator.prototype.next):
            (WebInspector.HeapSnapshotEdgesIterator.prototype.get node):
            (WebInspector.HeapSnapshotEdgesIterator.prototype.get nodeIndex):
            (WebInspector.HeapSnapshotEdgesIterator.prototype._getNameOrIndex):
            (WebInspector.HeapSnapshotEdgesIterator.prototype._getType):
            (WebInspector.HeapSnapshotNodeWrapper):
            (WebInspector.HeapSnapshotNodeWrapper.prototype.get edges):
            (WebInspector.HeapSnapshotNodeWrapper.prototype.get edgesCount):
            (WebInspector.HeapSnapshotNodeWrapper.prototype.get instancesCount):
            (WebInspector.HeapSnapshotNodeWrapper.prototype.get isHidden):
            (WebInspector.HeapSnapshotNodeWrapper.prototype.get name):
            (WebInspector.HeapSnapshotNodeWrapper.prototype.get selfSize):
            (WebInspector.HeapSnapshotNodeWrapper.prototype._getName):
            (WebInspector.HeapSnapshotNodeWrapper.prototype._getEdges):
            (WebInspector.HeapSnapshotNodeWrapper.prototype._getType):
            (WebInspector.HeapSnapshot):
            (WebInspector.HeapSnapshot.prototype._init):
            (WebInspector.HeapSnapshot.prototype.get rootEdges):
            * inspector/front-end/HeapSnapshotView.js:
            (WebInspector.HeapSnapshotProfileType.prototype.buttonClicked):
            * inspector/front-end/ProfilesPanel.js:
            (WebInspector.ProfilesPanel.prototype._setRecordingProfile):
            (WebInspector.ProfilesPanel.prototype._reportHeapSnapshotProgress):
            (WebInspector.ProfilerDispatcher.prototype.setRecordingProfile):
            (WebInspector.ProfilerDispatcher.prototype.reportHeapSnapshotProgress):
            * inspector/front-end/Settings.js:
            * inspector/front-end/WebKit.qrc:
            * inspector/front-end/inspector.html:
            * inspector/front-end/inspector.js:
            (WebInspector._createPanels):
            * src/js/DevTools.js:
            ():
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76597 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index f29c7be..f75dd11 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,80 @@
+2011-01-25  Mikhail Naganov  <mnaganov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: [Chromium] Prepare for landing of detailed heap snapshots.
+
+        - Introduce Preferences.detailedHeapProfiles flag for controlling
+          querying of detailed heap snapshots.
+        - Add boilerplate code for the new view.
+        - Factor out common code.
+
+        https://bugs.webkit.org/show_bug.cgi?id=52624
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * bindings/js/ScriptProfiler.h:
+        (WebCore::ScriptProfiler::HeapSnapshotControl::~HeapSnapshotControl):
+        (WebCore::ScriptProfiler::takeHeapSnapshot):
+        * bindings/v8/ScriptProfiler.cpp:
+        (WebCore::ScriptProfiler::takeHeapSnapshot):
+        * bindings/v8/ScriptProfiler.h:
+        (WebCore::ScriptProfiler::HeapSnapshotControl::~HeapSnapshotControl):
+        * inspector/Inspector.idl:
+        * inspector/InspectorProfilerAgent.cpp:
+        (WebCore::InspectorProfilerAgent::takeHeapSnapshot):
+        * inspector/InspectorProfilerAgent.h:
+        * inspector/front-end/DetailedHeapshotView.js: Added.
+        (WebInspector.DetailedHeapshotView):
+        (WebInspector.DetailedHeapshotView.prototype.get statusBarItems):
+        (WebInspector.DetailedHeapshotView.prototype.get profile):
+        (WebInspector.DetailedHeapshotView.prototype.set profile):
+        (WebInspector.DetailedHeapshotView.prototype.show):
+        (WebInspector.DetailedHeapshotView.prototype.hide):
+        (WebInspector.DetailedHeapshotProfileType):
+        (WebInspector.DetailedHeapshotProfileType.prototype.get buttonTooltip):
+        (WebInspector.DetailedHeapshotProfileType.prototype.get buttonStyle):
+        (WebInspector.DetailedHeapshotProfileType.prototype.buttonClicked):
+        (WebInspector.DetailedHeapshotProfileType.prototype.get welcomeMessage):
+        (WebInspector.DetailedHeapshotProfileType.prototype.createSidebarTreeElementForProfile):
+        (WebInspector.DetailedHeapshotProfileType.prototype.createView):
+        * inspector/front-end/HeapSnapshot.js: Added.
+        (WebInspector.HeapSnapshotEdgesIterator):
+        (WebInspector.HeapSnapshotEdgesIterator.prototype.get done):
+        (WebInspector.HeapSnapshotEdgesIterator.prototype.get isElement):
+        (WebInspector.HeapSnapshotEdgesIterator.prototype.get isHidden):
+        (WebInspector.HeapSnapshotEdgesIterator.prototype.get name):
+        (WebInspector.HeapSnapshotEdgesIterator.prototype.next):
+        (WebInspector.HeapSnapshotEdgesIterator.prototype.get node):
+        (WebInspector.HeapSnapshotEdgesIterator.prototype.get nodeIndex):
+        (WebInspector.HeapSnapshotEdgesIterator.prototype._getNameOrIndex):
+        (WebInspector.HeapSnapshotEdgesIterator.prototype._getType):
+        (WebInspector.HeapSnapshotNodeWrapper):
+        (WebInspector.HeapSnapshotNodeWrapper.prototype.get edges):
+        (WebInspector.HeapSnapshotNodeWrapper.prototype.get edgesCount):
+        (WebInspector.HeapSnapshotNodeWrapper.prototype.get instancesCount):
+        (WebInspector.HeapSnapshotNodeWrapper.prototype.get isHidden):
+        (WebInspector.HeapSnapshotNodeWrapper.prototype.get name):
+        (WebInspector.HeapSnapshotNodeWrapper.prototype.get selfSize):
+        (WebInspector.HeapSnapshotNodeWrapper.prototype._getName):
+        (WebInspector.HeapSnapshotNodeWrapper.prototype._getEdges):
+        (WebInspector.HeapSnapshotNodeWrapper.prototype._getType):
+        (WebInspector.HeapSnapshot):
+        (WebInspector.HeapSnapshot.prototype._init):
+        (WebInspector.HeapSnapshot.prototype.get rootEdges):
+        * inspector/front-end/HeapSnapshotView.js:
+        (WebInspector.HeapSnapshotProfileType.prototype.buttonClicked):
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype._setRecordingProfile):
+        (WebInspector.ProfilesPanel.prototype._reportHeapSnapshotProgress):
+        (WebInspector.ProfilerDispatcher.prototype.setRecordingProfile):
+        (WebInspector.ProfilerDispatcher.prototype.reportHeapSnapshotProgress):
+        * inspector/front-end/Settings.js:
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+        * inspector/front-end/inspector.js:
+        (WebInspector._createPanels):
+
 2011-01-25  Yury Semikhatsky  <yurys at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index ac6fe6b..bf0293a 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -4663,6 +4663,7 @@
             'inspector/front-end/DatabaseTableView.js',
             'inspector/front-end/DataGrid.js',
             'inspector/front-end/DebuggerModel.js',
+            'inspector/front-end/DetailedHeapshotView.js',
             'inspector/front-end/DOMAgent.js',
             'inspector/front-end/DOMStorage.js',
             'inspector/front-end/DOMStorageItemsView.js',
@@ -4681,6 +4682,7 @@
             'inspector/front-end/FontView.js',
             'inspector/front-end/GoToLineDialog.js',
             'inspector/front-end/HAREntry.js',
+            'inspector/front-end/HeapSnapshot.js',
             'inspector/front-end/HeapSnapshotView.js',
             'inspector/front-end/HelpScreen.js',
             'inspector/front-end/ImageView.js',
diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
index 6f8a6a4..efe64cd 100755
--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -65457,6 +65457,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\DetailedHeapshotView.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\DOMAgent.js"
 					>
 				</File>
@@ -65537,6 +65541,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\HeapSnapshot.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\HeapSnapshotView.js"
 					>
 				</File>
diff --git a/Source/WebCore/bindings/js/ScriptProfiler.h b/Source/WebCore/bindings/js/ScriptProfiler.h
index d4dd606..4c0c07f 100644
--- a/Source/WebCore/bindings/js/ScriptProfiler.h
+++ b/Source/WebCore/bindings/js/ScriptProfiler.h
@@ -38,9 +38,18 @@ namespace WebCore {
 class ScriptProfiler {
     WTF_MAKE_NONCOPYABLE(ScriptProfiler);
 public:
+    class HeapSnapshotProgress {
+    public:
+        virtual ~HeapSnapshotProgress() { }
+        virtual void Start(int totalWork) = 0;
+        virtual void Worked(int workDone) = 0;
+        virtual void Done() = 0;
+        virtual bool isCanceled() = 0;
+    };
+
     static void start(ScriptState* state, const String& title);
     static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
-    static PassRefPtr<ScriptHeapSnapshot> takeHeapSnapshot(const String&) { return 0; }
+    static PassRefPtr<ScriptHeapSnapshot> takeHeapSnapshot(const String&, HeapSnapshotProgress*) { return 0; }
     static bool isProfilerAlwaysEnabled();
 };
 
diff --git a/Source/WebCore/bindings/v8/ScriptProfiler.cpp b/Source/WebCore/bindings/v8/ScriptProfiler.cpp
index 02dea14..5de1b36 100644
--- a/Source/WebCore/bindings/v8/ScriptProfiler.cpp
+++ b/Source/WebCore/bindings/v8/ScriptProfiler.cpp
@@ -53,10 +53,40 @@ PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String&
     return profile ? ScriptProfile::create(profile) : 0;
 }
 
-PassRefPtr<ScriptHeapSnapshot> ScriptProfiler::takeHeapSnapshot(const String& title)
+namespace {
+
+class ActivityControlAdapter : public v8::ActivityControl {
+public:
+    ActivityControlAdapter(ScriptProfiler::HeapSnapshotProgress* progress)
+            : m_progress(progress), m_firstReport(true) { }
+    ControlOption ReportProgressValue(int done, int total)
+    {
+        ControlOption result = m_progress->isCanceled() ? kAbort : kContinue;
+        if (m_firstReport) {
+            m_firstReport = false;
+            m_progress->Start(total);
+        } else
+            m_progress->Worked(done);
+        if (done >= total)
+            m_progress->Done();
+        return result;
+    }
+private:
+    ScriptProfiler::HeapSnapshotProgress* m_progress;
+    bool m_firstReport;
+};
+
+} // namespace
+
+PassRefPtr<ScriptHeapSnapshot> ScriptProfiler::takeHeapSnapshot(const String& title, HeapSnapshotProgress* control)
 {
     v8::HandleScope hs;
-    const v8::HeapSnapshot* snapshot = v8::HeapProfiler::TakeSnapshot(v8String(title), v8::HeapSnapshot::kAggregated);
+    const v8::HeapSnapshot* snapshot = 0;
+    if (control) {
+        ActivityControlAdapter adapter(control);
+        snapshot = v8::HeapProfiler::TakeSnapshot(v8String(title), v8::HeapSnapshot::kFull, &adapter);
+    } else
+        snapshot = v8::HeapProfiler::TakeSnapshot(v8String(title), v8::HeapSnapshot::kAggregated);
     return snapshot ? ScriptHeapSnapshot::create(snapshot) : 0;
 }
 
diff --git a/Source/WebCore/bindings/v8/ScriptProfiler.h b/Source/WebCore/bindings/v8/ScriptProfiler.h
index e0969e1..83aab7b 100644
--- a/Source/WebCore/bindings/v8/ScriptProfiler.h
+++ b/Source/WebCore/bindings/v8/ScriptProfiler.h
@@ -44,9 +44,18 @@ class InspectorObject;
 class ScriptProfiler {
     WTF_MAKE_NONCOPYABLE(ScriptProfiler);
 public:
+    class HeapSnapshotProgress {
+    public:
+        virtual ~HeapSnapshotProgress() { }
+        virtual void Start(int totalWork) = 0;
+        virtual void Worked(int workDone) = 0;
+        virtual void Done() = 0;
+        virtual bool isCanceled() = 0;
+    };
+
     static void start(ScriptState* state, const String& title);
     static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
-    static PassRefPtr<ScriptHeapSnapshot> takeHeapSnapshot(const String& title);
+    static PassRefPtr<ScriptHeapSnapshot> takeHeapSnapshot(const String& title, HeapSnapshotProgress*);
     static bool isProfilerAlwaysEnabled();
 };
 
diff --git a/Source/WebCore/inspector/Inspector.idl b/Source/WebCore/inspector/Inspector.idl
index ad0d8f4..a91765f 100644
--- a/Source/WebCore/inspector/Inspector.idl
+++ b/Source/WebCore/inspector/Inspector.idl
@@ -304,12 +304,13 @@ module core {
         [domain=Profiler] void clearProfiles();
 
         // FIXME: split into Profiler and HeapProfiler.
-        [domain=Profiler] void takeHeapSnapshot();
+        [domain=Profiler] void takeHeapSnapshot(in boolean detailed);
         [notify, domain=Profiler] void addProfileHeader(out Object header);
         [notify, domain=Profiler] void addHeapSnapshotChunk(out unsigned long uid, out String chunk);
         [notify, domain=Profiler] void finishHeapSnapshot(out unsigned long uid);
         [notify, domain=Profiler] void setRecordingProfile(out boolean isProfiling);
         [notify, domain=Profiler] void resetProfiles();
+        [notify, domain=Profiler] void reportHeapSnapshotProgress(out int done, out int total);
 #endif // ENABLE_JAVASCRIPT_DEBUGGER
     };
 }
diff --git a/Source/WebCore/inspector/InspectorProfilerAgent.cpp b/Source/WebCore/inspector/InspectorProfilerAgent.cpp
index e7198b8..4693050 100644
--- a/Source/WebCore/inspector/InspectorProfilerAgent.cpp
+++ b/Source/WebCore/inspector/InspectorProfilerAgent.cpp
@@ -267,12 +267,37 @@ void InspectorProfilerAgent::stopUserInitiatedProfiling(bool ignoreProfile)
     toggleRecordButton(false);
 }
 
-void InspectorProfilerAgent::takeHeapSnapshot()
+namespace {
+
+class HeapSnapshotProgress: public ScriptProfiler::HeapSnapshotProgress {
+public:
+    explicit HeapSnapshotProgress(InspectorFrontend* frontend)
+        : m_frontend(frontend) { }
+    void Start(int totalWork)
+    {
+        m_totalWork = totalWork;
+    }
+    void Worked(int workDone)
+    {
+        if (m_frontend)
+            m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork);
+    }
+    void Done() { }
+    bool isCanceled() { return false; }
+private:
+    InspectorFrontend* m_frontend;
+    int m_totalWork;
+};
+
+};
+
+void InspectorProfilerAgent::takeHeapSnapshot(bool detailed)
 {
     String title = makeString(UserInitiatedProfileName, '.', String::number(m_nextUserInitiatedHeapSnapshotNumber));
     ++m_nextUserInitiatedHeapSnapshotNumber;
 
-    RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title);
+    HeapSnapshotProgress progress(m_frontend);
+    RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title, detailed ? &progress : 0);
     if (snapshot) {
         m_snapshots.add(snapshot->uid(), snapshot);
         if (m_frontend)
diff --git a/Source/WebCore/inspector/InspectorProfilerAgent.h b/Source/WebCore/inspector/InspectorProfilerAgent.h
index 09de717..93637f5 100644
--- a/Source/WebCore/inspector/InspectorProfilerAgent.h
+++ b/Source/WebCore/inspector/InspectorProfilerAgent.h
@@ -70,7 +70,7 @@ public:
     void setFrontend(InspectorFrontend* frontend) { m_frontend = frontend; }
     void startUserInitiatedProfiling();
     void stopUserInitiatedProfiling(bool ignoreProfile = false);
-    void takeHeapSnapshot();
+    void takeHeapSnapshot(bool detailed);
     void toggleRecordButton(bool isProfiling);
 
 private:
diff --git a/Source/WebCore/inspector/front-end/DetailedHeapshotView.js b/Source/WebCore/inspector/front-end/DetailedHeapshotView.js
new file mode 100644
index 0000000..cbe265c
--- /dev/null
+++ b/Source/WebCore/inspector/front-end/DetailedHeapshotView.js
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.DetailedHeapshotView = function(parent, profile)
+{
+    WebInspector.View.call(this);
+
+    this.element.addStyleClass("heap-snapshot-view");
+
+    this.parent = parent;
+    this.profile = profile;
+}
+
+WebInspector.DetailedHeapshotView.prototype = {
+    get profile()
+    {
+        return this._profile;
+    },
+
+    set profile(profile)
+    {
+        this._profile = profile;
+    }
+};
+
+WebInspector.DetailedHeapshotView.prototype.__proto__ = WebInspector.View.prototype;
+
+WebInspector.DetailedHeapshotProfileType = function()
+{
+    WebInspector.ProfileType.call(this, WebInspector.HeapSnapshotProfileType.TypeId, WebInspector.UIString("HEAP SNAPSHOTS"));
+}
+
+WebInspector.DetailedHeapshotProfileType.prototype = {
+    get buttonTooltip()
+    {
+        return WebInspector.UIString("Take heap snapshot.");
+    },
+
+    get buttonStyle()
+    {
+        return "heap-snapshot-status-bar-item status-bar-item";
+    },
+
+    buttonClicked: function()
+    {
+        InspectorBackend.takeHeapSnapshot(true);
+    },
+
+    get welcomeMessage()
+    {
+        return WebInspector.UIString("Get a heap snapshot by pressing the %s button on the status bar.");
+    },
+
+    createSidebarTreeElementForProfile: function(profile)
+    {
+        return new WebInspector.ProfileSidebarTreeElement(profile, WebInspector.UIString("Snapshot %d"), "heap-snapshot-sidebar-tree-item");
+    },
+
+    createView: function(profile)
+    {
+        return new WebInspector.DetailedHeapshotView(WebInspector.panels.profiles, profile);
+    }
+}
+
+WebInspector.DetailedHeapshotProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype;
diff --git a/Source/WebCore/inspector/front-end/HeapSnapshot.js b/Source/WebCore/inspector/front-end/HeapSnapshot.js
new file mode 100644
index 0000000..6f91a80
--- /dev/null
+++ b/Source/WebCore/inspector/front-end/HeapSnapshot.js
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.HeapSnapshotEdgesIterator = function(snapshot, edges)
+{
+    this._snapshot = snapshot;
+    this._edges = edges;
+    this._edgeIndex = 0;
+}
+
+WebInspector.HeapSnapshotEdgesIterator.prototype = {
+    get done()
+    {
+        return this._edgeIndex >= this._edges.length;
+    },
+
+    get isElement()
+    {
+        return this._type() === this._snapshot._edgeElementType;
+    },
+
+    get isHidden()
+    {
+        return this._type() === this._snapshot._edgeHiddenType;
+    },
+
+    get name()
+    {
+        return this.isElement || this.isHidden ? this._nameOrIndex() : this._snapshot._strings[this._nameOrIndex()];
+    },
+
+    next: function()
+    {
+        this._edgeIndex += this._snapshot._edgeFieldsCount;
+    },
+
+    get node()
+    {
+        return new WebInspector.HeapSnapshotNodeWrapper(this._snapshot, this.nodeIndex);
+    },
+
+    get nodeIndex()
+    {
+        return this._edges[this._edgeIndex + this._snapshot._edgeToNodeOffset];
+    },
+
+    _nameOrIndex: function()
+    {
+        return this._edges[this._edgeIndex + this._snapshot._edgeNameOffset];
+    },
+
+    _type: function()
+    {
+        return this._edges[this._edgeIndex + this._snapshot._edgeTypeOffset];
+    }
+};
+
+WebInspector.HeapSnapshotNodeWrapper = function(snapshot, nodeIndex)
+{
+    this._snapshot = snapshot;
+    this._nodes = snapshot._nodes;
+    this._nodeIndex = nodeIndex;
+}
+
+WebInspector.HeapSnapshotNodeWrapper.prototype = {
+    get edges()
+    {
+        return new WebInspector.HeapSnapshotEdgesIterator(this._snapshot, this._edges());
+    },
+
+    get edgesCount()
+    {
+        return this._nodes[this._nodeIndex + this._snapshot._edgesCountOffset];
+    },
+
+    get instancesCount()
+    {
+        return this._nodes[this._nodeIndex + this._snapshot._nodeInstancesCountOffset];
+    },
+
+    get isHidden()
+    {
+        return this._type() === this._snapshot._nodeHiddenType;
+    },
+
+    get name()
+    {
+        return this._snapshot._strings[this._name()];
+    },
+
+    get selfSize()
+    {
+        return this._nodes[this._nodeIndex + this._snapshot._nodeSelfSizeOffset]; 
+    },
+
+    _name: function()
+    {
+        return this._nodes[this._nodeIndex + this._snapshot._nodeNameOffset]; 
+    },
+
+    _edges: function()
+    {
+        var firstEdgeIndex = this._nodeIndex + this._snapshot._firstEdgeOffset;
+        return this._nodes.slice(firstEdgeIndex, firstEdgeIndex + this.edgesCount * this._snapshot._edgeFieldsCount);
+    },
+
+    _type: function()
+    {
+        return this._nodes[this._nodeIndex + this._snapshot._nodeTypeOffset];
+    }
+};
+
+WebInspector.HeapSnapshot = function(profile)
+{
+    this._profile = profile;
+    this._nodes = profile.nodes;
+    this._strings = profile.strings;
+
+    this._init();
+}
+
+WebInspector.HeapSnapshot.prototype = {
+    _init: function()
+    {
+        this._metaNodeIndex = 0;
+        this._rootNodeIndex = 1;
+        var meta = this._nodes[this._metaNodeIndex];
+        this._nodeTypeOffset = meta.fields.indexOf("type");
+        this._nodeNameOffset = meta.fields.indexOf("name");
+        this._nodeIdOffset = meta.fields.indexOf("id");
+        this._nodeInstancesCountOffset = this._nodeIdOffset;
+        this._nodeSelfSizeOffset = meta.fields.indexOf("self_size");
+        this._edgesCountOffset = meta.fields.indexOf("children_count");
+        this._firstEdgeOffset = meta.fields.indexOf("children");
+        this._nodeTypes = meta.types[this._nodeTypeOffset];
+        this._nodeHiddenType = this._nodeTypes.indexOf("hidden");
+        var edgesMeta = meta.types[this._firstEdgeOffset];
+        this._edgeFieldsCount = edgesMeta.fields.length;
+        this._edgeTypeOffset = edgesMeta.fields.indexOf("type");
+        this._edgeNameOffset = edgesMeta.fields.indexOf("name_or_index");
+        this._edgeToNodeOffset = edgesMeta.fields.indexOf("to_node");
+        this._edgeTypes = edgesMeta.types[this._edgeTypeOffset];
+        this._edgeElementType = this._edgeTypes.indexOf("element");
+        this._edgeHiddenType = this._edgeTypes.indexOf("hidden");
+    },
+
+    get rootEdges()
+    {
+        return (new WebInspector.HeapSnapshotNodeWrapper(this, this._rootNodeIndex)).edges;
+    }
+};
diff --git a/Source/WebCore/inspector/front-end/HeapSnapshotView.js b/Source/WebCore/inspector/front-end/HeapSnapshotView.js
index ec48bf2..1135183 100644
--- a/Source/WebCore/inspector/front-end/HeapSnapshotView.js
+++ b/Source/WebCore/inspector/front-end/HeapSnapshotView.js
@@ -27,154 +27,6 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-WebInspector.HeapSnapshotEdgesIterator = function(snapshot, edges)
-{
-    this._snapshot = snapshot;
-    this._edges = edges;
-    this._edgeIndex = 0;
-}
-
-WebInspector.HeapSnapshotEdgesIterator.prototype = {
-    get done()
-    {
-        return this._edgeIndex >= this._edges.length;
-    },
-
-    get isElement()
-    {
-        return this._getType() === this._snapshot._edgeElementType;
-    },
-
-    get isHidden()
-    {
-        return this._getType() === this._snapshot._edgeHiddenType;
-    },
-
-    get name()
-    {
-        return this.isElement || this.isHidden ? this._getNameOrIndex() : this._snapshot._strings[this._getNameOrIndex()];
-    },
-
-    next: function()
-    {
-        this._edgeIndex += this._snapshot._edgeFieldsCount;
-    },
-
-    get node()
-    {
-        return new WebInspector.HeapSnapshotNodeWrapper(this._snapshot, this.nodeIndex);
-    },
-
-    get nodeIndex()
-    {
-        return this._edges[this._edgeIndex + this._snapshot._edgeToNodeOffset];
-    },
-
-    _getNameOrIndex: function()
-    {
-        return this._edges[this._edgeIndex + this._snapshot._edgeNameOffset];
-    },
-
-    _getType: function()
-    {
-        return this._edges[this._edgeIndex + this._snapshot._edgeTypeOffset];
-    }
-};
-
-WebInspector.HeapSnapshotNodeWrapper = function(snapshot, nodeIndex)
-{
-    this._snapshot = snapshot;
-    this._nodes = snapshot._nodes;
-    this._nodeIndex = nodeIndex;
-}
-
-WebInspector.HeapSnapshotNodeWrapper.prototype = {
-    get edges()
-    {
-        return new WebInspector.HeapSnapshotEdgesIterator(this._snapshot, this._getEdges());
-    },
-
-    get edgesCount()
-    {
-        return this._nodes[this._nodeIndex + this._snapshot._edgesCountOffset];
-    },
-
-    get instancesCount()
-    {
-        return this._nodes[this._nodeIndex + this._snapshot._nodeInstancesCountOffset];
-    },
-
-    get isHidden()
-    {
-        return this._getType() === this._snapshot._nodeHiddenType;
-    },
-
-    get name()
-    {
-        return this._snapshot._strings[this._getName()];
-    },
-
-    get selfSize()
-    {
-        return this._nodes[this._nodeIndex + this._snapshot._nodeSelfSizeOffset]; 
-    },
-
-    _getName: function()
-    {
-        return this._nodes[this._nodeIndex + this._snapshot._nodeNameOffset]; 
-    },
-
-    _getEdges: function()
-    {
-        var firstEdgeIndex = this._nodeIndex + this._snapshot._firstEdgeOffset;
-        return this._nodes.slice(firstEdgeIndex, firstEdgeIndex + this.edgesCount * this._snapshot._edgeFieldsCount);
-    },
-
-    _getType: function()
-    {
-        return this._nodes[this._nodeIndex + this._snapshot._nodeTypeOffset];
-    }
-};
-
-WebInspector.HeapSnapshot = function(profile)
-{
-    this._profile = profile;
-    this._nodes = profile.nodes;
-    this._strings = profile.strings;
-
-    this._init();
-}
-
-WebInspector.HeapSnapshot.prototype = {
-    _init: function()
-    {
-        this._metaNodeIndex = 0;
-        this._rootNodeIndex = 1;
-        var meta = this._nodes[this._metaNodeIndex];
-        this._nodeTypeOffset = meta.fields.indexOf("type");
-        this._nodeNameOffset = meta.fields.indexOf("name");
-        this._nodeIdOffset = meta.fields.indexOf("id");
-        this._nodeInstancesCountOffset = this._nodeIdOffset;
-        this._nodeSelfSizeOffset = meta.fields.indexOf("self_size");
-        this._edgesCountOffset = meta.fields.indexOf("children_count");
-        this._firstEdgeOffset = meta.fields.indexOf("children");
-        this._nodeTypes = meta.types[this._nodeTypeOffset];
-        this._nodeHiddenType = this._nodeTypes.indexOf("hidden");
-        var edgesMeta = meta.types[this._firstEdgeOffset];
-        this._edgeFieldsCount = edgesMeta.fields.length;
-        this._edgeTypeOffset = edgesMeta.fields.indexOf("type");
-        this._edgeNameOffset = edgesMeta.fields.indexOf("name_or_index");
-        this._edgeToNodeOffset = edgesMeta.fields.indexOf("to_node");
-        this._edgeTypes = edgesMeta.types[this._edgeTypeOffset];
-        this._edgeElementType = this._edgeTypes.indexOf("element");
-        this._edgeHiddenType = this._edgeTypes.indexOf("hidden");
-    },
-
-    get rootEdges()
-    {
-        return (new WebInspector.HeapSnapshotNodeWrapper(this, this._rootNodeIndex)).edges;
-    }
-};
 
 WebInspector.HeapSnapshotView = function(parent, profile)
 {
@@ -246,7 +98,7 @@ WebInspector.HeapSnapshotView = function(parent, profile)
 
     function profileCallback(profile)
     {
-        var list = this._getProfiles();
+        var list = this._profiles();
         var profileIndex;
         for (var i = 0; i < list.length; ++i)
             if (list[i].uid === profile.uid) {
@@ -440,7 +292,7 @@ WebInspector.HeapSnapshotView.prototype = {
 
     _changeBase: function()
     {
-        if (this.baseSnapshot.uid === this._getProfiles()[this.baseSelectElement.selectedIndex].uid)
+        if (this.baseSnapshot.uid === this._profiles()[this.baseSelectElement.selectedIndex].uid)
             return;
 
         this._resetDataGridList(resetCompleted.bind(this));
@@ -468,7 +320,7 @@ WebInspector.HeapSnapshotView.prototype = {
         return this._snapshotDataGridList;
     },
 
-    _getProfiles: function()
+    _profiles: function()
     {
         return WebInspector.panels.profiles.getProfiles(WebInspector.HeapSnapshotProfileType.TypeId);
     },
@@ -581,7 +433,7 @@ WebInspector.HeapSnapshotView.prototype = {
 
     _resetDataGridList: function(callback)
     {
-        this._loadProfile(this._getProfiles()[this.baseSelectElement.selectedIndex], profileLoaded.bind(this));
+        this._loadProfile(this._profiles()[this.baseSelectElement.selectedIndex], profileLoaded.bind(this));
 
         function profileLoaded(profile)
         {
@@ -614,7 +466,7 @@ WebInspector.HeapSnapshotView.prototype = {
 
     _updateBaseOptions: function()
     {
-        var list = this._getProfiles();
+        var list = this._profiles();
         // We're assuming that snapshots can only be added.
         if (this.baseSelectElement.length === list.length)
             return;
@@ -1155,7 +1007,7 @@ WebInspector.HeapSnapshotProfileType.prototype = {
 
     buttonClicked: function()
     {
-        InspectorBackend.takeHeapSnapshot();
+        InspectorBackend.takeHeapSnapshot(false);
     },
 
     get welcomeMessage()
diff --git a/Source/WebCore/inspector/front-end/ProfilesPanel.js b/Source/WebCore/inspector/front-end/ProfilesPanel.js
index 2e0ab28..bbe0c5e 100644
--- a/Source/WebCore/inspector/front-end/ProfilesPanel.js
+++ b/Source/WebCore/inspector/front-end/ProfilesPanel.js
@@ -370,8 +370,9 @@ WebInspector.ProfilesPanel.prototype = {
         this.profileViewStatusBarItemsContainer.removeChildren();
 
         var statusBarItems = view.statusBarItems;
-        for (var i = 0; i < statusBarItems.length; ++i)
-            this.profileViewStatusBarItemsContainer.appendChild(statusBarItems[i]);
+        if (statusBarItems)
+            for (var i = 0; i < statusBarItems.length; ++i)
+                this.profileViewStatusBarItemsContainer.appendChild(statusBarItems[i]);
     },
 
     getProfiles: function(typeId)
@@ -629,6 +630,10 @@ WebInspector.ProfilesPanel.prototype = {
                 this._removeProfileHeader(this._temporaryRecordingProfile);
         }
         this.updateProfileTypeButtons();
+    },
+
+    _reportHeapSnapshotProgress: function(done, total)
+    {
     }
 }
 
@@ -674,6 +679,11 @@ WebInspector.ProfilerDispatcher.prototype = {
     setRecordingProfile: function(isProfiling)
     {
         this._profiler._setRecordingProfile(isProfiling);
+    },
+
+    reportHeapSnapshotProgress: function(done, total)
+    {
+        this._profiler._reportHeapSnapshotProgress(done, total);
     }
 }
 
diff --git a/Source/WebCore/inspector/front-end/Settings.js b/Source/WebCore/inspector/front-end/Settings.js
index e26b1d7..ef6b263 100644
--- a/Source/WebCore/inspector/front-end/Settings.js
+++ b/Source/WebCore/inspector/front-end/Settings.js
@@ -49,7 +49,9 @@ var Preferences = {
     useDataURLForResourceImageIcons: true,
     showTimingTab: false,
     showCookiesTab: false,
-    debugMode: false
+    debugMode: false,
+    heapProfilerPresent: false,
+    detailedHeapProfiles: false
 }
 
 WebInspector.Settings = function()
diff --git a/Source/WebCore/inspector/front-end/WebKit.qrc b/Source/WebCore/inspector/front-end/WebKit.qrc
index e8401e4..58e6869 100644
--- a/Source/WebCore/inspector/front-end/WebKit.qrc
+++ b/Source/WebCore/inspector/front-end/WebKit.qrc
@@ -28,6 +28,7 @@
     <file>Database.js</file>
     <file>DatabaseQueryView.js</file>
     <file>DatabaseTableView.js</file>
+    <file>DetailedHeapshotView.js</file>
     <file>DataGrid.js</file>
     <file>DebuggerModel.js</file>
     <file>DOMAgent.js</file>
@@ -48,6 +49,7 @@
     <file>FontView.js</file>
     <file>GoToLineDialog.js</file>
     <file>HAREntry.js</file>
+    <file>HeapSnapshot.js</file>
     <file>HeapSnapshotView.js</file>
     <file>HelpScreen.js</file>
     <file>ImageView.js</file>
diff --git a/Source/WebCore/inspector/front-end/inspector.html b/Source/WebCore/inspector/front-end/inspector.html
index aff8572..193deeb 100644
--- a/Source/WebCore/inspector/front-end/inspector.html
+++ b/Source/WebCore/inspector/front-end/inspector.html
@@ -139,7 +139,9 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="BottomUpProfileDataGridTree.js"></script>
     <script type="text/javascript" src="TopDownProfileDataGridTree.js"></script>
     <script type="text/javascript" src="ProfileView.js"></script>
+    <script type="text/javascript" src="HeapSnapshot.js"></script>
     <script type="text/javascript" src="HeapSnapshotView.js"></script>
+    <script type="text/javascript" src="DetailedHeapshotView.js"></script>
     <script type="text/javascript" src="DebuggerModel.js"></script>
     <script type="text/javascript" src="DOMAgent.js"></script>
     <script type="text/javascript" src="TimelineAgent.js"></script>
diff --git a/Source/WebCore/inspector/front-end/inspector.js b/Source/WebCore/inspector/front-end/inspector.js
index 7e5caf7..0fa4209 100644
--- a/Source/WebCore/inspector/front-end/inspector.js
+++ b/Source/WebCore/inspector/front-end/inspector.js
@@ -223,8 +223,12 @@ var WebInspector = {
         if (hiddenPanels.indexOf("profiles") === -1) {
             this.panels.profiles = new WebInspector.ProfilesPanel();
             this.panels.profiles.registerProfileType(new WebInspector.CPUProfileType());
-            if (Preferences.heapProfilerPresent)
-                this.panels.profiles.registerProfileType(new WebInspector.HeapSnapshotProfileType());
+            if (Preferences.heapProfilerPresent) {
+                if (!Preferences.detailedHeapProfiles)
+                    this.panels.profiles.registerProfileType(new WebInspector.HeapSnapshotProfileType());
+                else
+                    this.panels.profiles.registerProfileType(new WebInspector.DetailedHeapshotProfileType());
+            }
         }
         if (hiddenPanels.indexOf("audits") === -1)
             this.panels.audits = new WebInspector.AuditsPanel();
diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog
index 4fd444f..d8c595d 100644
--- a/Source/WebKit/chromium/ChangeLog
+++ b/Source/WebKit/chromium/ChangeLog
@@ -1,3 +1,19 @@
+2011-01-25  Mikhail Naganov  <mnaganov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: [Chromium] Prepare for landing of detailed heap snapshots.
+
+        - Introduce Preferences.detailedHeapProfiles flag for controlling
+          querying of detailed heap snapshots.
+        - Add boilerplate code for the new view.
+        - Factor out common code.
+
+        https://bugs.webkit.org/show_bug.cgi?id=52624
+
+        * src/js/DevTools.js:
+        ():
+
 2011-01-25  Pavel Podivilov  <podivilov at chromium.org>
 
         Unreviewed, trivial debugger test fix.
diff --git a/Source/WebKit/chromium/src/js/DevTools.js b/Source/WebKit/chromium/src/js/DevTools.js
index d6536bc..637fd1f 100644
--- a/Source/WebKit/chromium/src/js/DevTools.js
+++ b/Source/WebKit/chromium/src/js/DevTools.js
@@ -41,6 +41,7 @@ var context = {};  // Used by WebCore's inspector routines.
     Preferences.ignoreWhitespace = false;
     Preferences.samplingCPUProfiler = true;
     Preferences.heapProfilerPresent = true;
+    Preferences.detailedHeapProfiles = false;
     Preferences.debuggerAlwaysEnabled = true;
     Preferences.profilerAlwaysEnabled = true;
     Preferences.canEditScriptSource = true;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list