Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: webkit/glue/devtools/js/devtools.js

Issue 115299: Add initial version of DevTools Profiler (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/devtools/js/devtools.html ('k') | webkit/glue/devtools/js/devtools_host_stub.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/devtools/js/devtools.js
===================================================================
--- webkit/glue/devtools/js/devtools.js (revision 15955)
+++ webkit/glue/devtools/js/devtools.js (working copy)
@@ -713,3 +713,112 @@
oldShow.call(this);
};
})();
+
+
+/**
+ * We don't use WebKit's BottomUpProfileDataGridTree, instead using
+ * our own (because BottomUpProfileDataGridTree's functionality is
+ * implemented in profile_view.js for V8's Tick Processor).
+ *
+ * @param {WebInspector.ProfileView} profileView Profile view.
+ * @param {devtools.profiler.ProfileView} profile Profile.
+ */
+WebInspector.BottomUpProfileDataGridTree = function(profileView, profile) {
+ return WebInspector.buildProfileDataGridTree_(
+ profileView, profile.heavyProfile);
+};
+
+
+/**
+ * We don't use WebKit's TopDownProfileDataGridTree, instead using
+ * our own (because TopDownProfileDataGridTree's functionality is
+ * implemented in profile_view.js for V8's Tick Processor).
+ *
+ * @param {WebInspector.ProfileView} profileView Profile view.
+ * @param {devtools.profiler.ProfileView} profile Profile.
+ */
+WebInspector.TopDownProfileDataGridTree = function(profileView, profile) {
+ return WebInspector.buildProfileDataGridTree_(
+ profileView, profile.treeProfile);
+};
+
+
+/**
+ * A helper function, checks whether a profile node has visible children.
+ *
+ * @param {devtools.profiler.ProfileView.Node} profileNode Profile node.
+ * @return {boolean} Whether a profile node has visible children.
+ */
+WebInspector.nodeHasChildren_ = function(profileNode) {
+ var children = profileNode.children;
+ for (var i = 0, n = children.length; i < n; ++i) {
+ if (children[i].visible) {
+ return true;
+ }
+ }
+ return false;
+};
+
+
+/**
+ * Common code for populating a profiler grid node or a tree with
+ * given profile nodes.
+ *
+ * @param {WebInspector.ProfileDataGridNode|
+ * WebInspector.ProfileDataGridTree} viewNode Grid node or a tree.
+ * @param {WebInspector.ProfileView} profileView Profile view.
+ * @param {Array<devtools.profiler.ProfileView.Node>} children Profile nodes.
+ * @param {WebInspector.ProfileDataGridTree} owningTree Grid tree.
+ */
+WebInspector.populateNode_ = function(
+ viewNode, profileView, children, owningTree) {
+ for (var i = 0, n = children.length; i < n; ++i) {
+ var child = children[i];
+ if (child.visible) {
+ viewNode.appendChild(
+ new WebInspector.ProfileDataGridNode(
+ profileView, child, owningTree,
+ WebInspector.nodeHasChildren_(child)));
+ }
+ }
+};
+
+
+/**
+ * A helper function for building a profile grid tree.
+ *
+ * @param {WebInspector.ProfileView} profileview Profile view.
+ * @param {devtools.profiler.ProfileView} profile Profile.
+ * @return {WebInspector.ProfileDataGridTree} Profile grid tree.
+ */
+WebInspector.buildProfileDataGridTree_ = function(profileView, profile) {
+ var children = profile.head.children;
+ var dataGridTree = new WebInspector.ProfileDataGridTree(
+ profileView, profile.head);
+ WebInspector.populateNode_(dataGridTree, profileView, children, dataGridTree);
+ return dataGridTree;
+};
+
+
+/**
+ * @override
+ */
+WebInspector.ProfileDataGridNode.prototype._populate = function(event) {
+ var children = this.profileNode.children;
+ WebInspector.populateNode_(this, this.profileView, children, this.tree);
+ this.removeEventListener("populate", this._populate, this);
+};
+
+
+// As columns in data grid can't be changed after initialization,
+// we need to intercept the constructor and modify columns upon creation.
+(function InterceptDataGridForProfiler() {
+ var originalDataGrid = WebInspector.DataGrid;
+ WebInspector.DataGrid = function(columns) {
+ if (('average' in columns) && ('calls' in columns)) {
+ delete columns['average'];
+ delete columns['calls'];
+ }
+ return new originalDataGrid(columns);
+ };
+})();
« no previous file with comments | « webkit/glue/devtools/js/devtools.html ('k') | webkit/glue/devtools/js/devtools_host_stub.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698