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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChartView.js

Issue 2892333002: DevTools: Render third-party badges in timeline tree view (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
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
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 ? Timeline.TimelineUIUtils.eventColorByProduct.bind(
102 null, this._productRegistry, this._model.timelineMo del(), this._urlToColorCache) :
caseq 2017/05/22 18:43:49 Let's avoid keeping the model here, as this mapper
alph 2017/05/22 22:53:26 Done.
103 Timeline.TimelineUIUtils.eventColor);
100 this._mainFlameChart.update(); 104 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 } 105 }
130 106
131 /** 107 /**
132 * @override 108 * @override
133 * @return {?Element} 109 * @return {?Element}
134 */ 110 */
135 resizerElement() { 111 resizerElement() {
136 return null; 112 return null;
137 } 113 }
138 114
(...skipping 23 matching lines...) Expand all
162 var extensionDataAdded = Timeline.PerformanceModel.Events.ExtensionDataAdded ; 138 var extensionDataAdded = Timeline.PerformanceModel.Events.ExtensionDataAdded ;
163 if (this._model) 139 if (this._model)
164 this._model.removeEventListener(extensionDataAdded, this._appendExtensionD ata, this); 140 this._model.removeEventListener(extensionDataAdded, this._appendExtensionD ata, this);
165 this._model = model; 141 this._model = model;
166 if (this._model) 142 if (this._model)
167 this._model.addEventListener(extensionDataAdded, this._appendExtensionData , this); 143 this._model.addEventListener(extensionDataAdded, this._appendExtensionData , this);
168 this._mainDataProvider.setModel(this._model); 144 this._mainDataProvider.setModel(this._model);
169 this._networkDataProvider.setModel(this._model); 145 this._networkDataProvider.setModel(this._model);
170 this._countersView.setModel(this._model); 146 this._countersView.setModel(this._model);
171 this._detailsView.setModel(this._model); 147 this._detailsView.setModel(this._model);
148 this._updateColorMapper();
172 149
173 this._nextExtensionIndex = 0; 150 this._nextExtensionIndex = 0;
174 this._appendExtensionData(); 151 this._appendExtensionData();
175 152
176 this._updateSearchHighlight(false, true); 153 this._updateSearchHighlight(false, true);
177 this._refresh(); 154 this._refresh();
178 } 155 }
179 156
180 _refresh() { 157 _refresh() {
181 if (this._networkDataProvider.isEmpty()) { 158 if (this._networkDataProvider.isEmpty()) {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 546 }
570 context.restore(); 547 context.restore();
571 } 548 }
572 }; 549 };
573 550
574 /** @enum {string} */ 551 /** @enum {string} */
575 Timeline.TimelineFlameChartView._ColorBy = { 552 Timeline.TimelineFlameChartView._ColorBy = {
576 URL: 'URL', 553 URL: 'URL',
577 Product: 'Product' 554 Product: 'Product'
578 }; 555 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698