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 * @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 Loading... | |
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 |
38 /** @type {!Components.Linkifier} */ | 35 /** @type {!Components.Linkifier} */ |
39 this._popupLinkifier = new Components.Linkifier(); | 36 this._popupLinkifier = new Components.Linkifier(); |
40 | 37 |
41 /** @type {!Map<string, !Network.NetworkTimeCalculator>} */ | 38 /** @type {!Map<string, !Network.NetworkTimeCalculator>} */ |
42 this._calculatorsMap = new Map(); | 39 this._calculatorsMap = new Map(); |
43 this._calculatorsMap.set(Network.NetworkLogViewColumns._calculatorTypes.Time , timeCalculator); | 40 this._calculatorsMap.set(Network.NetworkLogViewColumns._calculatorTypes.Time , timeCalculator); |
44 this._calculatorsMap.set(Network.NetworkLogViewColumns._calculatorTypes.Dura tion, durationCalculator); | 41 this._calculatorsMap.set(Network.NetworkLogViewColumns._calculatorTypes.Dura tion, durationCalculator); |
(...skipping 26 matching lines...) Expand all Loading... | |
71 } | 68 } |
72 | 69 |
73 reset() { | 70 reset() { |
74 if (this._popoverHelper) | 71 if (this._popoverHelper) |
75 this._popoverHelper.hidePopover(); | 72 this._popoverHelper.hidePopover(); |
76 this._eventDividers.clear(); | 73 this._eventDividers.clear(); |
77 } | 74 } |
78 | 75 |
79 _setupDataGrid() { | 76 _setupDataGrid() { |
80 var defaultColumns = Network.NetworkLogViewColumns._defaultColumns; | 77 var defaultColumns = Network.NetworkLogViewColumns._defaultColumns; |
78 | |
79 if (Runtime.experiments.isEnabled('networkGroupingRequests')) { | |
80 defaultColumns.splice(1, 0, /** @type {!Network.NetworkLogViewColumns.Desc riptor} */ ({ | |
81 id: 'product', | |
82 title: Common.UIString('Product'), | |
83 visible: true, | |
84 sortingFunction: Network.NetworkRequestNode.Produc tComparitor | |
pfeldman
2017/04/27 22:20:49
You need to either make sorting async or create th
allada
2017/04/28 01:20:07
Sorting is a pain point of network grid as it is.
| |
85 })); | |
86 } | |
87 | |
81 var defaultColumnConfig = Network.NetworkLogViewColumns._defaultColumnConfig ; | 88 var defaultColumnConfig = Network.NetworkLogViewColumns._defaultColumnConfig ; |
82 | 89 |
83 this._columns = /** @type {!Array<!Network.NetworkLogViewColumns.Descriptor> } */ ([]); | 90 this._columns = /** @type {!Array<!Network.NetworkLogViewColumns.Descriptor> } */ ([]); |
84 for (var currentConfigColumn of defaultColumns) { | 91 for (var currentConfigColumn of defaultColumns) { |
85 var columnConfig = /** @type {!Network.NetworkLogViewColumns.Descriptor} * / ( | 92 var columnConfig = /** @type {!Network.NetworkLogViewColumns.Descriptor} * / ( |
86 Object.assign({}, defaultColumnConfig, currentConfigColumn)); | 93 Object.assign({}, defaultColumnConfig, currentConfigColumn)); |
87 columnConfig.id = columnConfig.id; | 94 columnConfig.id = columnConfig.id; |
88 if (columnConfig.subtitle) | 95 if (columnConfig.subtitle) |
89 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnConfig.ti tle, columnConfig.subtitle); | 96 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnConfig.ti tle, columnConfig.subtitle); |
90 this._columns.push(columnConfig); | 97 this._columns.push(columnConfig); |
91 } | 98 } |
92 this._loadColumnExtensions(); | |
93 this._loadCustomColumnsAndSettings(); | 99 this._loadCustomColumnsAndSettings(); |
94 | 100 |
95 this._popoverHelper = new UI.PopoverHelper(this._networkLogView.element, thi s._getPopoverRequest.bind(this)); | 101 this._popoverHelper = new UI.PopoverHelper(this._networkLogView.element, thi s._getPopoverRequest.bind(this)); |
96 this._popoverHelper.setHasPadding(true); | 102 this._popoverHelper.setHasPadding(true); |
97 | 103 |
98 /** @type {!DataGrid.SortableDataGrid<!Network.NetworkNode>} */ | 104 /** @type {!DataGrid.SortableDataGrid<!Network.NetworkNode>} */ |
99 this._dataGrid = | 105 this._dataGrid = |
100 new DataGrid.SortableDataGrid(this._columns.map(Network.NetworkLogViewCo lumns._convertToDataGridDescriptor)); | 106 new DataGrid.SortableDataGrid(this._columns.map(Network.NetworkLogViewCo lumns._convertToDataGridDescriptor)); |
101 this._dataGrid.element.addEventListener('mousedown', event => { | 107 this._dataGrid.element.addEventListener('mousedown', event => { |
102 if (!this._dataGrid.selectedNode && event.button) | 108 if (!this._dataGrid.selectedNode && event.button) |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 this._networkLogView.removeAllNodeHighlights(); | 328 this._networkLogView.removeAllNodeHighlights(); |
323 this._splitWidget.hideSidebar(); | 329 this._splitWidget.hideSidebar(); |
324 this._activeScroller = this._dataGridScroller; | 330 this._activeScroller = this._dataGridScroller; |
325 this._dataGrid.setScrollContainer(this._dataGridScroller); | 331 this._dataGrid.setScrollContainer(this._dataGridScroller); |
326 } | 332 } |
327 this._networkLogView.element.classList.toggle('brief-mode', !gridMode); | 333 this._networkLogView.element.classList.toggle('brief-mode', !gridMode); |
328 this._updateColumns(); | 334 this._updateColumns(); |
329 } | 335 } |
330 | 336 |
331 /** | 337 /** |
332 * @return {!Map<string, ?Network.NetworkColumnExtensionInterface>} | |
333 */ | |
334 columnExtensions() { | |
335 return this._columnExtensions; | |
336 } | |
337 | |
338 /** | |
339 * @param {!Network.NetworkLogViewColumns.Descriptor} columnConfig | 338 * @param {!Network.NetworkLogViewColumns.Descriptor} columnConfig |
340 */ | 339 */ |
341 _toggleColumnVisibility(columnConfig) { | 340 _toggleColumnVisibility(columnConfig) { |
342 this._loadCustomColumnsAndSettings(); | 341 this._loadCustomColumnsAndSettings(); |
343 columnConfig.visible = !columnConfig.visible; | 342 columnConfig.visible = !columnConfig.visible; |
344 this._saveColumnsSettings(); | 343 this._saveColumnsSettings(); |
345 this._updateColumns(); | 344 this._updateColumns(); |
346 } | 345 } |
347 | 346 |
348 _saveColumnsSettings() { | 347 _saveColumnsSettings() { |
349 var saveableSettings = {}; | 348 var saveableSettings = {}; |
350 for (var columnConfig of this._columns) | 349 for (var columnConfig of this._columns) |
351 saveableSettings[columnConfig.id] = {visible: columnConfig.visible, title: columnConfig.title}; | 350 saveableSettings[columnConfig.id] = {visible: columnConfig.visible, title: columnConfig.title}; |
352 | 351 |
353 this._persistantSettings.set(saveableSettings); | 352 this._persistantSettings.set(saveableSettings); |
354 } | 353 } |
355 | 354 |
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() { | 355 _loadCustomColumnsAndSettings() { |
394 var savedSettings = this._persistantSettings.get(); | 356 var savedSettings = this._persistantSettings.get(); |
395 var columnIds = Object.keys(savedSettings); | 357 var columnIds = Object.keys(savedSettings); |
396 for (var columnId of columnIds) { | 358 for (var columnId of columnIds) { |
397 var setting = savedSettings[columnId]; | 359 var setting = savedSettings[columnId]; |
398 var columnConfig = this._columns.find(columnConfig => columnConfig.id === columnId); | 360 var columnConfig = this._columns.find(columnConfig => columnConfig.id === columnId); |
399 if (!columnConfig) | 361 if (!columnConfig) |
400 columnConfig = this._addCustomHeader(setting.title, columnId); | 362 columnConfig = this._addCustomHeader(setting.title, columnId); |
401 if (columnConfig.hideable && typeof setting.visible === 'boolean') | 363 if (columnConfig.hideable && typeof setting.visible === 'boolean') |
402 columnConfig.visible = !!setting.visible; | 364 columnConfig.visible = !!setting.visible; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
847 /** | 809 /** |
848 * @enum {string} | 810 * @enum {string} |
849 */ | 811 */ |
850 Network.NetworkLogViewColumns.WaterfallSortIds = { | 812 Network.NetworkLogViewColumns.WaterfallSortIds = { |
851 StartTime: 'startTime', | 813 StartTime: 'startTime', |
852 ResponseTime: 'responseReceivedTime', | 814 ResponseTime: 'responseReceivedTime', |
853 EndTime: 'endTime', | 815 EndTime: 'endTime', |
854 Duration: 'duration', | 816 Duration: 'duration', |
855 Latency: 'latency' | 817 Latency: 'latency' |
856 }; | 818 }; |
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 }; | |
OLD | NEW |