| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @implements {Timeline.TimelineModeView} | 6 * @implements {Timeline.TimelineModeView} |
| 7 * @implements {PerfUI.FlameChartDelegate} | 7 * @implements {PerfUI.FlameChartDelegate} |
| 8 * @implements {UI.Searchable} | 8 * @implements {UI.Searchable} |
| 9 * @unrestricted | 9 * @unrestricted |
| 10 */ | 10 */ |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 this._mainFlameChart.addEventListener(PerfUI.FlameChart.Events.EntryHighligh
ted, this._onEntryHighlighted, this); | 78 this._mainFlameChart.addEventListener(PerfUI.FlameChart.Events.EntryHighligh
ted, this._onEntryHighlighted, this); |
| 79 this._nextExtensionIndex = 0; | 79 this._nextExtensionIndex = 0; |
| 80 | 80 |
| 81 this._boundRefresh = this._refresh.bind(this); | 81 this._boundRefresh = this._refresh.bind(this); |
| 82 | 82 |
| 83 this._mainDataProvider.setEventColorMapping(Timeline.TimelineUIUtils.eventCo
lor); | 83 this._mainDataProvider.setEventColorMapping(Timeline.TimelineUIUtils.eventCo
lor); |
| 84 if (!Runtime.experiments.isEnabled('timelineColorByProduct')) | 84 if (!Runtime.experiments.isEnabled('timelineColorByProduct')) |
| 85 return; | 85 return; |
| 86 this._groupBySetting = | 86 this._groupBySetting = |
| 87 Common.settings.createSetting('timelineTreeGroupBy', Timeline.Aggregated
TimelineTreeView.GroupBy.None); | 87 Common.settings.createSetting('timelineTreeGroupBy', Timeline.Aggregated
TimelineTreeView.GroupBy.None); |
| 88 this._groupBySetting.addChangeListener(this._onGroupByChanged, this); | 88 this._groupBySetting.addChangeListener(this._updateColorMapper, this); |
| 89 this._onGroupByChanged(); | 89 this._updateColorMapper(); |
| 90 ProductRegistry.instance().then(registry => this._productRegistry = registry
); | 90 ProductRegistry.instance().then(registry => this._productRegistry = registry
); |
| 91 } | 91 } |
| 92 | 92 |
| 93 _onGroupByChanged() { | 93 _updateColorMapper() { |
| 94 /** @type {!Map<string, string>} */ | 94 /** @type {!Map<string, string>} */ |
| 95 this._urlToColorCache = new Map(); | 95 this._urlToColorCache = new Map(); |
| 96 if (!this._model) |
| 97 return; |
| 96 var colorByProduct = Runtime.experiments.isEnabled('timelineColorByProduct')
&& | 98 var colorByProduct = Runtime.experiments.isEnabled('timelineColorByProduct')
&& |
| 97 this._groupBySetting.get() === Timeline.AggregatedTimelineTreeView.Group
By.Product; | 99 this._groupBySetting.get() === Timeline.AggregatedTimelineTreeView.Group
By.Product; |
| 98 this._mainDataProvider.setEventColorMapping( | 100 this._mainDataProvider.setEventColorMapping( |
| 99 colorByProduct ? eventToColorByProduct.bind(this) : Timeline.TimelineUIU
tils.eventColor); | 101 colorByProduct ? this._colorByProductForEvent.bind(this) : Timeline.Time
lineUIUtils.eventColor); |
| 100 this._mainFlameChart.update(); | 102 this._mainFlameChart.update(); |
| 101 | |
| 102 /** | |
| 103 * @param {!SDK.TracingModel.Event} event | |
| 104 * @this {Timeline.TimelineFlameChartView} | |
| 105 * @return {string} | |
| 106 */ | |
| 107 function eventToColorByProduct(event) { | |
| 108 var url = Timeline.TimelineUIUtils.eventURL(event) || ''; | |
| 109 var color = this._urlToColorCache.get(url); | |
| 110 if (!color) { | |
| 111 var defaultColor = '#f2ecdc'; | |
| 112 if (!this._productRegistry) | |
| 113 return defaultColor; | |
| 114 var parsedURL = url.asParsedURL(); | |
| 115 if (!parsedURL) | |
| 116 return defaultColor; | |
| 117 var name = this._productRegistry.nameForUrl(parsedURL); | |
| 118 if (!name) { | |
| 119 name = parsedURL.host; | |
| 120 var rootFrames = this._model.timelineModel().rootFrames(); | |
| 121 if (rootFrames.some(pageFrame => new Common.ParsedURL(pageFrame.url).h
ost === name)) | |
| 122 return defaultColor; | |
| 123 } | |
| 124 color = name ? ProductRegistry.BadgePool.colorForEntryName(name) : defau
ltColor; | |
| 125 this._urlToColorCache.set(url, color); | |
| 126 } | |
| 127 return color; | |
| 128 } | |
| 129 } | 103 } |
| 130 | 104 |
| 131 /** | 105 /** |
| 106 * @param {!SDK.TracingModel.Event} event |
| 107 * @return {string} |
| 108 */ |
| 109 _colorByProductForEvent(event) { |
| 110 return Timeline.TimelineUIUtils.eventColorByProduct( |
| 111 this._productRegistry, this._model.timelineModel(), this._urlToColorCach
e, event); |
| 112 } |
| 113 |
| 114 /** |
| 132 * @override | 115 * @override |
| 133 * @return {?Element} | 116 * @return {?Element} |
| 134 */ | 117 */ |
| 135 resizerElement() { | 118 resizerElement() { |
| 136 return null; | 119 return null; |
| 137 } | 120 } |
| 138 | 121 |
| 139 /** | 122 /** |
| 140 * @override | 123 * @override |
| 141 * @param {number} windowStartTime | 124 * @param {number} windowStartTime |
| (...skipping 20 matching lines...) Expand all Loading... |
| 162 var extensionDataAdded = Timeline.PerformanceModel.Events.ExtensionDataAdded
; | 145 var extensionDataAdded = Timeline.PerformanceModel.Events.ExtensionDataAdded
; |
| 163 if (this._model) | 146 if (this._model) |
| 164 this._model.removeEventListener(extensionDataAdded, this._appendExtensionD
ata, this); | 147 this._model.removeEventListener(extensionDataAdded, this._appendExtensionD
ata, this); |
| 165 this._model = model; | 148 this._model = model; |
| 166 if (this._model) | 149 if (this._model) |
| 167 this._model.addEventListener(extensionDataAdded, this._appendExtensionData
, this); | 150 this._model.addEventListener(extensionDataAdded, this._appendExtensionData
, this); |
| 168 this._mainDataProvider.setModel(this._model); | 151 this._mainDataProvider.setModel(this._model); |
| 169 this._networkDataProvider.setModel(this._model); | 152 this._networkDataProvider.setModel(this._model); |
| 170 this._countersView.setModel(this._model); | 153 this._countersView.setModel(this._model); |
| 171 this._detailsView.setModel(this._model); | 154 this._detailsView.setModel(this._model); |
| 155 this._updateColorMapper(); |
| 172 | 156 |
| 173 this._nextExtensionIndex = 0; | 157 this._nextExtensionIndex = 0; |
| 174 this._appendExtensionData(); | 158 this._appendExtensionData(); |
| 175 | 159 |
| 176 this._updateSearchHighlight(false, true); | 160 this._updateSearchHighlight(false, true); |
| 177 this._refresh(); | 161 this._refresh(); |
| 178 } | 162 } |
| 179 | 163 |
| 180 _refresh() { | 164 _refresh() { |
| 181 if (this._networkDataProvider.isEmpty()) { | 165 if (this._networkDataProvider.isEmpty()) { |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 } | 553 } |
| 570 context.restore(); | 554 context.restore(); |
| 571 } | 555 } |
| 572 }; | 556 }; |
| 573 | 557 |
| 574 /** @enum {string} */ | 558 /** @enum {string} */ |
| 575 Timeline.TimelineFlameChartView._ColorBy = { | 559 Timeline.TimelineFlameChartView._ColorBy = { |
| 576 URL: 'URL', | 560 URL: 'URL', |
| 577 Product: 'Product' | 561 Product: 'Product' |
| 578 }; | 562 }; |
| OLD | NEW |