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

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

Issue 2662453004: DevTools: Update network overview with two level bars. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/timeline/TimelineNetworkFlameChart.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 */ 150 */
151 constructor(model) { 151 constructor(model) {
152 super('network', Common.UIString('NET'), model); 152 super('network', Common.UIString('NET'), model);
153 } 153 }
154 154
155 /** 155 /**
156 * @override 156 * @override
157 */ 157 */
158 update() { 158 update() {
159 super.update(); 159 super.update();
160 const height = this.height(); 160 var height = this.height();
caseq 2017/01/27 00:55:19 inline below.
161 const numBands = categoryBand(Timeline.TimelineUIUtils.NetworkCategory.Other ) + 1; 161 var devicePixelRatio = window.devicePixelRatio;
caseq 2017/01/27 00:55:19 remove.
162 const devicePixelRatio = window.devicePixelRatio; 162 var bandHeight = height / 2;
163 const bandHeight = height - (numBands + 1) * devicePixelRatio; 163 var timeOffset = this._model.minimumRecordTime();
164 const timeOffset = this._model.minimumRecordTime(); 164 var timeSpan = this._model.maximumRecordTime() - timeOffset;
165 const timeSpan = this._model.maximumRecordTime() - timeOffset; 165 var canvasWidth = this.width();
166 const canvasWidth = this.width(); 166 var scale = canvasWidth / timeSpan;
167 const scale = canvasWidth / timeSpan; 167 var ctx = this.context();
caseq 2017/01/27 00:55:19 move down to actual usage.
168 const ctx = this.context(); 168 var highPath = new Path2D();
169 const paths = []; 169 var lowPath = new Path2D();
170 for (const categoryName in Timeline.TimelineUIUtils.NetworkCategory) { 170 var priorities = Protocol.Network.ResourcePriority;
171 const category = Timeline.TimelineUIUtils.NetworkCategory[categoryName]; 171 var highPrioritySet = new Set([priorities.VeryHigh, priorities.High, priorit ies.Medium])
172 paths[categoryBand(category)] = { 172 for (var request of this._model.networkRequests()) {
173 style: Timeline.TimelineUIUtils.networkCategoryColor(category), 173 var path = highPrioritySet.has(request.priority) ? highPath : lowPath;
174 path: new Path2D() 174 var s = Math.max(Math.floor((request.startTime - timeOffset) * scale), 0);
175 }; 175 var e = Math.min(Math.ceil((request.endTime - timeOffset) * scale + 1), ca nvasWidth);
176 path.rect(s, 0, e - s, bandHeight - 1);
176 } 177 }
177 for (const request of this._model.networkRequests()) { 178 ctx.save();
178 const category = Timeline.TimelineUIUtils.networkRequestCategory(request); 179 ctx.fillStyle = 'hsl(214, 60%, 60%)';
179 const band = categoryBand(category); 180 ctx.fill(highPath);
180 const y = (numBands - band - 1) * devicePixelRatio; 181 ctx.translate(0, bandHeight);
181 const s = Math.max(Math.floor((request.startTime - timeOffset) * scale), 0 ); 182 ctx.fillStyle = 'hsl(214, 80%, 80%)';
182 const e = Math.min(Math.ceil((request.endTime - timeOffset) * scale + 1), canvasWidth); 183 ctx.fill(lowPath);
183 paths[band].path.rect(s, y, e - s, bandHeight); 184 ctx.restore();
184 }
185 for (const path of paths.reverse()) {
186 ctx.globalAlpha = 1;
187 ctx.fillStyle = path.style;
188 ctx.fill(path.path);
189 ctx.globalAlpha = 0.4;
190 ctx.fillStyle = 'white';
191 ctx.fill(path.path);
192 }
193
194 /**
195 * @param {!Timeline.TimelineUIUtils.NetworkCategory} category
196 * @return {number}
197 */
198 function categoryBand(category) {
199 const categories = Timeline.TimelineUIUtils.NetworkCategory;
200 switch (category) {
201 case categories.HTML:
202 return 0;
203 case categories.Script:
204 return 1;
205 case categories.Style:
206 return 2;
207 case categories.Media:
208 return 3;
209 default:
210 return 4;
211 }
212 }
213 } 185 }
214 }; 186 };
215 187
216 /** 188 /**
217 * @unrestricted 189 * @unrestricted
218 */ 190 */
219 Timeline.TimelineEventOverviewCPUActivity = class extends Timeline.TimelineEvent Overview { 191 Timeline.TimelineEventOverviewCPUActivity = class extends Timeline.TimelineEvent Overview {
220 /** 192 /**
221 * @param {!TimelineModel.TimelineModel} model 193 * @param {!TimelineModel.TimelineModel} model
222 */ 194 */
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 counters[group] = this._quantDuration; 739 counters[group] = this._quantDuration;
768 this._callback(counters); 740 this._callback(counters);
769 interval -= this._quantDuration; 741 interval -= this._quantDuration;
770 } 742 }
771 this._counters = []; 743 this._counters = [];
772 this._counters[group] = interval; 744 this._counters[group] = interval;
773 this._lastTime = time; 745 this._lastTime = time;
774 this._remainder = this._quantDuration - interval; 746 this._remainder = this._quantDuration - interval;
775 } 747 }
776 }; 748 };
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/timeline/TimelineNetworkFlameChart.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698