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

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: fix compile error 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 bandHeight = this.height() / 2;
161 const numBands = categoryBand(Timeline.TimelineUIUtils.NetworkCategory.Other ) + 1; 161 var timeOffset = this._model.minimumRecordTime();
162 const devicePixelRatio = window.devicePixelRatio; 162 var timeSpan = this._model.maximumRecordTime() - timeOffset;
163 const bandHeight = height - (numBands + 1) * devicePixelRatio; 163 var canvasWidth = this.width();
164 const timeOffset = this._model.minimumRecordTime(); 164 var scale = canvasWidth / timeSpan;
165 const timeSpan = this._model.maximumRecordTime() - timeOffset; 165 var highPath = new Path2D();
166 const canvasWidth = this.width(); 166 var lowPath = new Path2D();
167 const scale = canvasWidth / timeSpan; 167 var priorities = Protocol.Network.ResourcePriority;
168 const ctx = this.context(); 168 var highPrioritySet = new Set([priorities.VeryHigh, priorities.High, priorit ies.Medium]);
169 const paths = []; 169 for (var request of this._model.networkRequests()) {
170 for (const categoryName in Timeline.TimelineUIUtils.NetworkCategory) { 170 var path = highPrioritySet.has(request.priority) ? highPath : lowPath;
171 const category = Timeline.TimelineUIUtils.NetworkCategory[categoryName]; 171 var s = Math.max(Math.floor((request.startTime - timeOffset) * scale), 0);
172 paths[categoryBand(category)] = { 172 var e = Math.min(Math.ceil((request.endTime - timeOffset) * scale + 1), ca nvasWidth);
173 style: Timeline.TimelineUIUtils.networkCategoryColor(category), 173 path.rect(s, 0, e - s, bandHeight - 1);
174 path: new Path2D()
175 };
176 } 174 }
177 for (const request of this._model.networkRequests()) { 175 var ctx = this.context();
178 const category = Timeline.TimelineUIUtils.networkRequestCategory(request); 176 ctx.save();
179 const band = categoryBand(category); 177 ctx.fillStyle = 'hsl(214, 60%, 60%)';
180 const y = (numBands - band - 1) * devicePixelRatio; 178 ctx.fill(/** @type {?} */ (highPath));
181 const s = Math.max(Math.floor((request.startTime - timeOffset) * scale), 0 ); 179 ctx.translate(0, bandHeight);
182 const e = Math.min(Math.ceil((request.endTime - timeOffset) * scale + 1), canvasWidth); 180 ctx.fillStyle = 'hsl(214, 80%, 80%)';
183 paths[band].path.rect(s, y, e - s, bandHeight); 181 ctx.fill(/** @type {?} */ (lowPath));
184 } 182 ctx.restore();
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 } 183 }
214 }; 184 };
215 185
216 /** 186 /**
217 * @unrestricted 187 * @unrestricted
218 */ 188 */
219 Timeline.TimelineEventOverviewCPUActivity = class extends Timeline.TimelineEvent Overview { 189 Timeline.TimelineEventOverviewCPUActivity = class extends Timeline.TimelineEvent Overview {
220 /** 190 /**
221 * @param {!TimelineModel.TimelineModel} model 191 * @param {!TimelineModel.TimelineModel} model
222 */ 192 */
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 counters[group] = this._quantDuration; 737 counters[group] = this._quantDuration;
768 this._callback(counters); 738 this._callback(counters);
769 interval -= this._quantDuration; 739 interval -= this._quantDuration;
770 } 740 }
771 this._counters = []; 741 this._counters = [];
772 this._counters[group] = interval; 742 this._counters[group] = interval;
773 this._lastTime = time; 743 this._lastTime = time;
774 this._remainder = this._quantDuration - interval; 744 this._remainder = this._quantDuration - interval;
775 } 745 }
776 }; 746 };
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