Chromium Code Reviews| Index: Source/devtools/front_end/profiler/CPUProfileView.js |
| diff --git a/Source/devtools/front_end/profiler/CPUProfileView.js b/Source/devtools/front_end/profiler/CPUProfileView.js |
| index be47ced830b5613d442ff1349d2932ea0a71ac75..3408f1f4818984377f6934679b42beb090276a73 100644 |
| --- a/Source/devtools/front_end/profiler/CPUProfileView.js |
| +++ b/Source/devtools/front_end/profiler/CPUProfileView.js |
| @@ -51,6 +51,7 @@ WebInspector.CPUProfileView = function(profileHeader) |
| this.viewSelectComboBox = new WebInspector.StatusBarComboBox(this._changeView.bind(this)); |
| var options = {}; |
| + options[WebInspector.CPUProfileView._TypeSunburst] = this.viewSelectComboBox.createOption(WebInspector.UIString("Sunburst"), "", WebInspector.CPUProfileView._TypeSunburst); |
| options[WebInspector.CPUProfileView._TypeFlame] = this.viewSelectComboBox.createOption(WebInspector.UIString("Chart"), "", WebInspector.CPUProfileView._TypeFlame); |
| options[WebInspector.CPUProfileView._TypeHeavy] = this.viewSelectComboBox.createOption(WebInspector.UIString("Heavy (Bottom Up)"), "", WebInspector.CPUProfileView._TypeHeavy); |
| options[WebInspector.CPUProfileView._TypeTree] = this.viewSelectComboBox.createOption(WebInspector.UIString("Tree (Top Down)"), "", WebInspector.CPUProfileView._TypeTree); |
| @@ -81,6 +82,7 @@ WebInspector.CPUProfileView = function(profileHeader) |
| this._flameChart.update(); |
| } |
| +WebInspector.CPUProfileView._TypeSunburst = "Sunburst"; |
| WebInspector.CPUProfileView._TypeFlame = "Flame"; |
| WebInspector.CPUProfileView._TypeTree = "Tree"; |
| WebInspector.CPUProfileView._TypeHeavy = "Heavy"; |
| @@ -269,6 +271,15 @@ WebInspector.CPUProfileView.prototype = { |
| this._flameChart.addEventListener(WebInspector.FlameChart.Events.EntrySelected, this._onEntrySelected.bind(this)); |
| }, |
| + _ensureSunburstChartCreated: function() |
| + { |
| + if (this._sunburstChart) |
| + return; |
| +// this._sunburstDataProvider = new WebInspector.CPUFlameChartDataProvider(this.profile, this._profileHeader.target()); |
| + this._sunburstChart = new WebInspector.CPUProfileSunburstChart(this.profile); |
| +// this._flameChart.addEventListener(WebInspector.FlameChart.Events.EntrySelected, this._onEntrySelected.bind(this)); |
| + }, |
| + |
| /** |
| * @param {!WebInspector.Event} event |
| */ |
| @@ -298,6 +309,11 @@ WebInspector.CPUProfileView.prototype = { |
| this._viewType.set(this.viewSelectComboBox.selectedOption().value); |
| switch (this._viewType.get()) { |
| + case WebInspector.CPUProfileView._TypeSunburst: |
| + this._ensureSunburstChartCreated(); |
| + this._visibleView = this._sunburstChart; |
| + this._searchableElement = this._sunburstChart; |
| + break; |
| case WebInspector.CPUProfileView._TypeFlame: |
| this._ensureFlameChartCreated(); |
| this._visibleView = this._flameChart; |
| @@ -810,3 +826,43 @@ WebInspector.CPUProfileHeader.prototype = { |
| __proto__: WebInspector.ProfileHeader.prototype |
| } |
| + |
| + |
| +/** |
| + * @constructor |
| + * @extends {WebInspector.VBox} |
| + * @param {!WebInspector.CPUProfileDataModel} profile |
| + */ |
| +WebInspector.CPUProfileSunburstChart = function(profile) |
| +{ |
| + WebInspector.VBox.call(this); |
| + this.element.id = "cpu-sunburst-chart"; |
| + this._rootNode = this._convertToD3Trace(profile.profileHead); |
| + |
| + var iframe = this.element.createChild("iframe", "vbox flex-auto visible"); |
| + iframe.src = "chrome-devtools://devtools/bundled/profiler/d3js_trace/index.html"; |
| + function onFrameLoad() |
| + { |
| + iframe.contentWindow.postMessage(this._rootNode, "*"); |
| + } |
| + iframe.onload = onFrameLoad.bind(this); |
| +} |
| + |
| +WebInspector.CPUProfileSunburstChart.prototype = { |
| + _convertToD3Trace: function(node) |
| + { |
| + var result = { |
| + name: node.functionName, |
| + size: node.hitCount, |
| + children: [] |
| + }; |
| + for (var i = 0; i < node.children.length; i++) { |
|
alph
2015/01/29 14:25:47
nit:
children: node.children.map(this._convertToD3
|
| + var child = this._convertToD3Trace(node.children[i]); |
| +// result.size += child.size; |
| + result.children.push(child); |
| + } |
| + return result; |
| + }, |
| + |
| + __proto__: WebInspector.VBox.prototype |
| +}; |