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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkLogViewColumns.js

Issue 2839273003: [Devtools] New structure and colorize rows for network products (Closed)
Patch Set: changes 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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 Network.NetworkLogViewColumns = class { 7 Network.NetworkLogViewColumns = class {
8 /** 8 /**
9 * @param {!Network.NetworkLogView} networkLogView 9 * @param {!Network.NetworkLogView} networkLogView
10 * @param {!Network.NetworkTransferTimeCalculator} timeCalculator 10 * @param {!Network.NetworkTransferTimeCalculator} timeCalculator
(...skipping 11 matching lines...) Expand all
22 22
23 /** @type {!Map<string, !Array<number>>} */ 23 /** @type {!Map<string, !Array<number>>} */
24 this._eventDividers = new Map(); 24 this._eventDividers = new Map();
25 this._eventDividersShown = false; 25 this._eventDividersShown = false;
26 26
27 this._gridMode = true; 27 this._gridMode = true;
28 28
29 /** @type {!Array.<!Network.NetworkLogViewColumns.Descriptor>} */ 29 /** @type {!Array.<!Network.NetworkLogViewColumns.Descriptor>} */
30 this._columns = []; 30 this._columns = [];
31 31
32 /** @type {!Map<string, ?Network.NetworkColumnExtensionInterface>} */
33 this._columnExtensions = new Map();
34
35 this._waterfallRequestsAreStale = false; 32 this._waterfallRequestsAreStale = false;
36 this._waterfallScrollerWidthIsStale = true; 33 this._waterfallScrollerWidthIsStale = true;
37 34
35 /** @type {?ProductRegistry.Registry} */
36 this._productRegistryInstance = null;
37
38 /** @type {!Components.Linkifier} */ 38 /** @type {!Components.Linkifier} */
39 this._popupLinkifier = new Components.Linkifier(); 39 this._popupLinkifier = new Components.Linkifier();
40 40
41 /** @type {!Map<string, !Network.NetworkTimeCalculator>} */ 41 /** @type {!Map<string, !Network.NetworkTimeCalculator>} */
42 this._calculatorsMap = new Map(); 42 this._calculatorsMap = new Map();
43 this._calculatorsMap.set(Network.NetworkLogViewColumns._calculatorTypes.Time , timeCalculator); 43 this._calculatorsMap.set(Network.NetworkLogViewColumns._calculatorTypes.Time , timeCalculator);
44 this._calculatorsMap.set(Network.NetworkLogViewColumns._calculatorTypes.Dura tion, durationCalculator); 44 this._calculatorsMap.set(Network.NetworkLogViewColumns._calculatorTypes.Dura tion, durationCalculator);
45 45
46 this._setupDataGrid(); 46 this._setupDataGrid();
47 this._setupWaterfall(); 47 this._setupWaterfall();
(...skipping 23 matching lines...) Expand all
71 } 71 }
72 72
73 reset() { 73 reset() {
74 if (this._popoverHelper) 74 if (this._popoverHelper)
75 this._popoverHelper.hidePopover(); 75 this._popoverHelper.hidePopover();
76 this._eventDividers.clear(); 76 this._eventDividers.clear();
77 } 77 }
78 78
79 _setupDataGrid() { 79 _setupDataGrid() {
80 var defaultColumns = Network.NetworkLogViewColumns._defaultColumns; 80 var defaultColumns = Network.NetworkLogViewColumns._defaultColumns;
81
82 if (Runtime.experiments.isEnabled('networkGroupingRequests')) {
83 defaultColumns.splice(1, 0, /** @type {!Network.NetworkLogViewColumns.Desc riptor} */ ({
84 id: 'product',
85 title: Common.UIString('Product'),
86 visible: true
87 }));
88 }
89
81 var defaultColumnConfig = Network.NetworkLogViewColumns._defaultColumnConfig ; 90 var defaultColumnConfig = Network.NetworkLogViewColumns._defaultColumnConfig ;
82 91
83 this._columns = /** @type {!Array<!Network.NetworkLogViewColumns.Descriptor> } */ ([]); 92 this._columns = /** @type {!Array<!Network.NetworkLogViewColumns.Descriptor> } */ ([]);
84 for (var currentConfigColumn of defaultColumns) { 93 for (var currentConfigColumn of defaultColumns) {
85 var columnConfig = /** @type {!Network.NetworkLogViewColumns.Descriptor} * / ( 94 var columnConfig = /** @type {!Network.NetworkLogViewColumns.Descriptor} * / (
86 Object.assign({}, defaultColumnConfig, currentConfigColumn)); 95 Object.assign({}, defaultColumnConfig, currentConfigColumn));
87 columnConfig.id = columnConfig.id; 96 columnConfig.id = columnConfig.id;
88 if (columnConfig.subtitle) 97 if (columnConfig.subtitle)
89 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnConfig.ti tle, columnConfig.subtitle); 98 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnConfig.ti tle, columnConfig.subtitle);
90 this._columns.push(columnConfig); 99 this._columns.push(columnConfig);
91 } 100 }
92 this._loadColumnExtensions();
93 this._loadCustomColumnsAndSettings(); 101 this._loadCustomColumnsAndSettings();
94 102
95 this._popoverHelper = new UI.PopoverHelper(this._networkLogView.element, thi s._getPopoverRequest.bind(this)); 103 this._popoverHelper = new UI.PopoverHelper(this._networkLogView.element, thi s._getPopoverRequest.bind(this));
96 this._popoverHelper.setHasPadding(true); 104 this._popoverHelper.setHasPadding(true);
97 105
98 /** @type {!DataGrid.SortableDataGrid<!Network.NetworkNode>} */ 106 /** @type {!DataGrid.SortableDataGrid<!Network.NetworkNode>} */
99 this._dataGrid = 107 this._dataGrid =
100 new DataGrid.SortableDataGrid(this._columns.map(Network.NetworkLogViewCo lumns._convertToDataGridDescriptor)); 108 new DataGrid.SortableDataGrid(this._columns.map(Network.NetworkLogViewCo lumns._convertToDataGridDescriptor));
101 this._dataGrid.element.addEventListener('mousedown', event => { 109 this._dataGrid.element.addEventListener('mousedown', event => {
102 if (!this._dataGrid.selectedNode && event.button) 110 if (!this._dataGrid.selectedNode && event.button)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 if (columnId === 'waterfall') { 280 if (columnId === 'waterfall') {
273 if (this._dataGrid.sortOrder() === DataGrid.DataGrid.Order.Ascending) 281 if (this._dataGrid.sortOrder() === DataGrid.DataGrid.Order.Ascending)
274 this._waterfallColumnSortIcon.setIconType('smallicon-triangle-up'); 282 this._waterfallColumnSortIcon.setIconType('smallicon-triangle-up');
275 else 283 else
276 this._waterfallColumnSortIcon.setIconType('smallicon-triangle-down'); 284 this._waterfallColumnSortIcon.setIconType('smallicon-triangle-down');
277 285
278 var sortFunction = Network.NetworkRequestNode.RequestPropertyComparator.bi nd(null, this._activeWaterfallSortId); 286 var sortFunction = Network.NetworkRequestNode.RequestPropertyComparator.bi nd(null, this._activeWaterfallSortId);
279 this._dataGrid.sortNodes(sortFunction, !this._dataGrid.isSortOrderAscendin g()); 287 this._dataGrid.sortNodes(sortFunction, !this._dataGrid.isSortOrderAscendin g());
280 this._networkLogView.dataGridSorted(); 288 this._networkLogView.dataGridSorted();
281 return; 289 return;
290 } else if (columnId === 'product' && !this._productRegistryInstance) {
291 ProductRegistry.instance().then(productRegistry => {
292 this._productRegistryInstance = productRegistry;
293 var columnConfig = this._columns.find(columnConfig => columnConfig.id == = columnId);
294 if (!columnConfig)
295 return;
296 columnConfig.sortingFunction = Network.NetworkRequestNode.ProductCompara tor.bind(null, productRegistry);
297 if (this._dataGrid.sortColumnId() === 'product')
298 this._sortHandler();
299 });
300 return;
282 } 301 }
283 this._waterfallColumnSortIcon.setIconType(''); 302 this._waterfallColumnSortIcon.setIconType('');
284 303
285 var columnConfig = this._columns.find(columnConfig => columnConfig.id === co lumnId); 304 var columnConfig = this._columns.find(columnConfig => columnConfig.id === co lumnId);
286 if (!columnConfig || !columnConfig.sortingFunction) 305 if (!columnConfig || !columnConfig.sortingFunction)
287 return; 306 return;
288 307
289 this._dataGrid.sortNodes(columnConfig.sortingFunction, !this._dataGrid.isSor tOrderAscending()); 308 this._dataGrid.sortNodes(columnConfig.sortingFunction, !this._dataGrid.isSor tOrderAscending());
290 this._networkLogView.dataGridSorted(); 309 this._networkLogView.dataGridSorted();
291 } 310 }
(...skipping 30 matching lines...) Expand all
322 this._networkLogView.removeAllNodeHighlights(); 341 this._networkLogView.removeAllNodeHighlights();
323 this._splitWidget.hideSidebar(); 342 this._splitWidget.hideSidebar();
324 this._activeScroller = this._dataGridScroller; 343 this._activeScroller = this._dataGridScroller;
325 this._dataGrid.setScrollContainer(this._dataGridScroller); 344 this._dataGrid.setScrollContainer(this._dataGridScroller);
326 } 345 }
327 this._networkLogView.element.classList.toggle('brief-mode', !gridMode); 346 this._networkLogView.element.classList.toggle('brief-mode', !gridMode);
328 this._updateColumns(); 347 this._updateColumns();
329 } 348 }
330 349
331 /** 350 /**
332 * @return {!Map<string, ?Network.NetworkColumnExtensionInterface>}
333 */
334 columnExtensions() {
335 return this._columnExtensions;
336 }
337
338 /**
339 * @param {!Network.NetworkLogViewColumns.Descriptor} columnConfig 351 * @param {!Network.NetworkLogViewColumns.Descriptor} columnConfig
340 */ 352 */
341 _toggleColumnVisibility(columnConfig) { 353 _toggleColumnVisibility(columnConfig) {
342 this._loadCustomColumnsAndSettings(); 354 this._loadCustomColumnsAndSettings();
343 columnConfig.visible = !columnConfig.visible; 355 columnConfig.visible = !columnConfig.visible;
344 this._saveColumnsSettings(); 356 this._saveColumnsSettings();
345 this._updateColumns(); 357 this._updateColumns();
346 } 358 }
347 359
348 _saveColumnsSettings() { 360 _saveColumnsSettings() {
349 var saveableSettings = {}; 361 var saveableSettings = {};
350 for (var columnConfig of this._columns) 362 for (var columnConfig of this._columns)
351 saveableSettings[columnConfig.id] = {visible: columnConfig.visible, title: columnConfig.title}; 363 saveableSettings[columnConfig.id] = {visible: columnConfig.visible, title: columnConfig.title};
352 364
353 this._persistantSettings.set(saveableSettings); 365 this._persistantSettings.set(saveableSettings);
354 } 366 }
355 367
356 _loadColumnExtensions() {
357 var extensions = self.runtime.extensions(Network.NetworkColumnExtensionInter face);
358 for (var i = 0; i < extensions.length; i++) {
359 var extension = extensions[i];
360 var title = extension.title();
361 var columnId = title.toLowerCase() + '-extension';
362
363 this._columnExtensions.set(columnId, null);
364 extension.instance().then(extensionInstanceResolved.bind(this, columnId));
365
366 var columnConfig = /** @type {!Network.NetworkLogViewColumns.Descriptor} * / (
367 Object.assign({}, Network.NetworkLogViewColumns._defaultColumnConfig, {
368 id: columnId,
369 title: title,
370 isResponseHeader: false,
371 isCustomHeader: false,
372 visible: true,
373 sortingFunction:
374 Network.NetworkRequestNode.ExtensionColumnComparator.bind(null, this._columnExtensions, columnId)
375 }));
376 const columnIndex = i + 1;
377 this._columns.splice(columnIndex, 0, columnConfig);
378 if (this._dataGrid)
379 this._dataGrid.addColumn(Network.NetworkLogViewColumns._convertToDataGri dDescriptor(columnConfig), columnIndex);
380 }
381
382 /**
383 * @param {string} columnId
384 * @param {!Network.NetworkColumnExtensionInterface} instance
385 * @this {Network.NetworkLogViewColumns}
386 */
387 function extensionInstanceResolved(columnId, instance) {
388 this._columnExtensions.set(columnId, instance);
389 this._networkLogView.columnExtensionResolved();
390 }
391 }
392
393 _loadCustomColumnsAndSettings() { 368 _loadCustomColumnsAndSettings() {
394 var savedSettings = this._persistantSettings.get(); 369 var savedSettings = this._persistantSettings.get();
395 var columnIds = Object.keys(savedSettings); 370 var columnIds = Object.keys(savedSettings);
396 for (var columnId of columnIds) { 371 for (var columnId of columnIds) {
397 var setting = savedSettings[columnId]; 372 var setting = savedSettings[columnId];
398 var columnConfig = this._columns.find(columnConfig => columnConfig.id === columnId); 373 var columnConfig = this._columns.find(columnConfig => columnConfig.id === columnId);
399 if (!columnConfig) 374 if (!columnConfig)
400 columnConfig = this._addCustomHeader(setting.title, columnId); 375 columnConfig = this._addCustomHeader(setting.title, columnId);
401 if (columnConfig.hideable && typeof setting.visible === 'boolean') 376 if (columnConfig.hideable && typeof setting.visible === 'boolean')
402 columnConfig.visible = !!setting.visible; 377 columnConfig.visible = !!setting.visible;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 this._redrawWaterfallColumn(); 610 this._redrawWaterfallColumn();
636 } 611 }
637 612
638 clearFilmStripFrame() { 613 clearFilmStripFrame() {
639 this._eventDividers.delete(Network.NetworkLogViewColumns._filmStripDividerCo lor); 614 this._eventDividers.delete(Network.NetworkLogViewColumns._filmStripDividerCo lor);
640 this._redrawWaterfallColumn(); 615 this._redrawWaterfallColumn();
641 } 616 }
642 }; 617 };
643 618
644 Network.NetworkLogViewColumns._initialSortColumn = 'waterfall'; 619 Network.NetworkLogViewColumns._initialSortColumn = 'waterfall';
620 /** @type {?ProductRegistry.Registry} */
621 Network.NetworkRequestNode._productRegistryInstance = null;
645 622
646 /** 623 /**
647 * @typedef {{ 624 * @typedef {{
648 * id: string, 625 * id: string,
649 * title: string, 626 * title: string,
650 * titleDOMFragment: (!DocumentFragment|undefined), 627 * titleDOMFragment: (!DocumentFragment|undefined),
651 * subtitle: (string|null), 628 * subtitle: (string|null),
652 * visible: boolean, 629 * visible: boolean,
653 * weight: number, 630 * weight: number,
654 * hideable: boolean, 631 * hideable: boolean,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 /** 824 /**
848 * @enum {string} 825 * @enum {string}
849 */ 826 */
850 Network.NetworkLogViewColumns.WaterfallSortIds = { 827 Network.NetworkLogViewColumns.WaterfallSortIds = {
851 StartTime: 'startTime', 828 StartTime: 'startTime',
852 ResponseTime: 'responseReceivedTime', 829 ResponseTime: 'responseReceivedTime',
853 EndTime: 'endTime', 830 EndTime: 'endTime',
854 Duration: 'duration', 831 Duration: 'duration',
855 Latency: 'latency' 832 Latency: 'latency'
856 }; 833 };
857
858 /**
859 * @interface
860 */
861 Network.NetworkColumnExtensionInterface = function() {};
862
863 Network.NetworkColumnExtensionInterface.prototype = {
864 /**
865 * @param {!SDK.NetworkRequest} request
866 * @return {string}
867 */
868 lookupColumnValue(request) {},
869
870 /**
871 * @param {!SDK.NetworkRequest} aRequest
872 * @param {!SDK.NetworkRequest} bRequest
873 * @return {number}
874 */
875 requestComparator(aRequest, bRequest) {}
876 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698