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

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

Issue 2749423002: [Devtools] Renamed _loadColumns and _saveColumns to be more appropriate (Closed)
Patch Set: Created 3 years, 9 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 this._columns = /** @type {!Array<!Network.NetworkLogViewColumns.Descriptor> } */ ([]); 80 this._columns = /** @type {!Array<!Network.NetworkLogViewColumns.Descriptor> } */ ([]);
81 for (var currentConfigColumn of defaultColumns) { 81 for (var currentConfigColumn of defaultColumns) {
82 var columnConfig = /** @type {!Network.NetworkLogViewColumns.Descriptor} * / ( 82 var columnConfig = /** @type {!Network.NetworkLogViewColumns.Descriptor} * / (
83 Object.assign(/** @type {!Object} */ ({}), defaultColumnConfig, curren tConfigColumn)); 83 Object.assign(/** @type {!Object} */ ({}), defaultColumnConfig, curren tConfigColumn));
84 columnConfig.id = columnConfig.id; 84 columnConfig.id = columnConfig.id;
85 if (columnConfig.subtitle) 85 if (columnConfig.subtitle)
86 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnConfig.ti tle, columnConfig.subtitle); 86 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnConfig.ti tle, columnConfig.subtitle);
87 this._columns.push(columnConfig); 87 this._columns.push(columnConfig);
88 } 88 }
89 this._loadColumns(); 89 this._loadCustomColumnsAndSettings();
90 90
91 this._popoverHelper = new UI.PopoverHelper(this._networkLogView.element); 91 this._popoverHelper = new UI.PopoverHelper(this._networkLogView.element);
92 this._popoverHelper.initializeCallbacks( 92 this._popoverHelper.initializeCallbacks(
93 this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this._o nHidePopover.bind(this)); 93 this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this._o nHidePopover.bind(this));
94 this._popoverHelper.setHasPadding(true); 94 this._popoverHelper.setHasPadding(true);
95 95
96 /** @type {!DataGrid.SortableDataGrid<!Network.NetworkNode>} */ 96 /** @type {!DataGrid.SortableDataGrid<!Network.NetworkNode>} */
97 this._dataGrid = 97 this._dataGrid =
98 new DataGrid.SortableDataGrid(this._columns.map(Network.NetworkLogViewCo lumns._convertToDataGridDescriptor)); 98 new DataGrid.SortableDataGrid(this._columns.map(Network.NetworkLogViewCo lumns._convertToDataGridDescriptor));
99 this._dataGrid.element.addEventListener('mousedown', event => { 99 this._dataGrid.element.addEventListener('mousedown', event => {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 this._dataGrid.setScrollContainer(this._dataGridScroller); 323 this._dataGrid.setScrollContainer(this._dataGridScroller);
324 } 324 }
325 this._networkLogView.element.classList.toggle('brief-mode', !gridMode); 325 this._networkLogView.element.classList.toggle('brief-mode', !gridMode);
326 this._updateColumns(); 326 this._updateColumns();
327 } 327 }
328 328
329 /** 329 /**
330 * @param {!Network.NetworkLogViewColumns.Descriptor} columnConfig 330 * @param {!Network.NetworkLogViewColumns.Descriptor} columnConfig
331 */ 331 */
332 _toggleColumnVisibility(columnConfig) { 332 _toggleColumnVisibility(columnConfig) {
333 this._loadColumns(); 333 this._loadCustomColumnsAndSettings();
334 columnConfig.visible = !columnConfig.visible; 334 columnConfig.visible = !columnConfig.visible;
335 this._saveColumns(); 335 this._saveColumnsSettings();
336 this._updateColumns(); 336 this._updateColumns();
337 } 337 }
338 338
339 _saveColumns() { 339 _saveColumnsSettings() {
340 var saveableSettings = {}; 340 var saveableSettings = {};
341 for (var columnConfig of this._columns) 341 for (var columnConfig of this._columns)
342 saveableSettings[columnConfig.id] = {visible: columnConfig.visible, title: columnConfig.title}; 342 saveableSettings[columnConfig.id] = {visible: columnConfig.visible, title: columnConfig.title};
343 343
344 this._persistantSettings.set(saveableSettings); 344 this._persistantSettings.set(saveableSettings);
345 } 345 }
346 346
347 _loadColumns() { 347 _loadCustomColumnsAndSettings() {
348 var savedSettings = this._persistantSettings.get(); 348 var savedSettings = this._persistantSettings.get();
349 var columnIds = Object.keys(savedSettings); 349 var columnIds = Object.keys(savedSettings);
350 for (var columnId of columnIds) { 350 for (var columnId of columnIds) {
351 var setting = savedSettings[columnId]; 351 var setting = savedSettings[columnId];
352 var columnConfig = this._columns.find(columnConfig => columnConfig.id === columnId); 352 var columnConfig = this._columns.find(columnConfig => columnConfig.id === columnId);
353 if (!columnConfig) 353 if (!columnConfig)
354 columnConfig = this._addCustomHeader(setting.title, columnId); 354 columnConfig = this._addCustomHeader(setting.title, columnId);
355 if (columnConfig.hideable && typeof setting.visible === 'boolean') 355 if (columnConfig.hideable && typeof setting.visible === 'boolean')
356 columnConfig.visible = !!setting.visible; 356 columnConfig.visible = !!setting.visible;
357 if (typeof setting.title === 'string') 357 if (typeof setting.title === 'string')
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 * @param {string} headerId 454 * @param {string} headerId
455 * @return {boolean} 455 * @return {boolean}
456 */ 456 */
457 _removeCustomHeader(headerId) { 457 _removeCustomHeader(headerId) {
458 headerId = headerId.toLowerCase(); 458 headerId = headerId.toLowerCase();
459 var index = this._columns.findIndex(columnConfig => columnConfig.id === head erId); 459 var index = this._columns.findIndex(columnConfig => columnConfig.id === head erId);
460 if (index === -1) 460 if (index === -1)
461 return false; 461 return false;
462 this._columns.splice(index, 1); 462 this._columns.splice(index, 1);
463 this._dataGrid.removeColumn(headerId); 463 this._dataGrid.removeColumn(headerId);
464 this._saveColumns(); 464 this._saveColumnsSettings();
465 this._updateColumns(); 465 this._updateColumns();
466 return true; 466 return true;
467 } 467 }
468 468
469 /** 469 /**
470 * @param {string} headerTitle 470 * @param {string} headerTitle
471 * @param {string=} headerId 471 * @param {string=} headerId
472 * @param {number=} index 472 * @param {number=} index
473 * @return {?Network.NetworkLogViewColumns.Descriptor} 473 * @return {?Network.NetworkLogViewColumns.Descriptor}
474 */ 474 */
(...skipping 12 matching lines...) Expand all
487 id: headerId, 487 id: headerId,
488 title: headerTitle, 488 title: headerTitle,
489 isResponseHeader: true, 489 isResponseHeader: true,
490 isCustomHeader: true, 490 isCustomHeader: true,
491 visible: true, 491 visible: true,
492 sortingFunction: Network.NetworkRequestNode.ResponseHeaderStringCompar ator.bind(null, headerId) 492 sortingFunction: Network.NetworkRequestNode.ResponseHeaderStringCompar ator.bind(null, headerId)
493 })); 493 }));
494 this._columns.splice(index, 0, columnConfig); 494 this._columns.splice(index, 0, columnConfig);
495 if (this._dataGrid) 495 if (this._dataGrid)
496 this._dataGrid.addColumn(Network.NetworkLogViewColumns._convertToDataGridD escriptor(columnConfig), index); 496 this._dataGrid.addColumn(Network.NetworkLogViewColumns._convertToDataGridD escriptor(columnConfig), index);
497 this._saveColumns(); 497 this._saveColumnsSettings();
498 this._updateColumns(); 498 this._updateColumns();
499 return columnConfig; 499 return columnConfig;
500 } 500 }
501 501
502 /** 502 /**
503 * @param {string} oldHeaderId 503 * @param {string} oldHeaderId
504 * @param {string} newHeaderTitle 504 * @param {string} newHeaderTitle
505 * @param {string=} newHeaderId 505 * @param {string=} newHeaderId
506 * @return {boolean} 506 * @return {boolean}
507 */ 507 */
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 /** 807 /**
808 * @enum {string} 808 * @enum {string}
809 */ 809 */
810 Network.NetworkLogViewColumns.WaterfallSortIds = { 810 Network.NetworkLogViewColumns.WaterfallSortIds = {
811 StartTime: 'startTime', 811 StartTime: 'startTime',
812 ResponseTime: 'responseReceivedTime', 812 ResponseTime: 'responseReceivedTime',
813 EndTime: 'endTime', 813 EndTime: 'endTime',
814 Duration: 'duration', 814 Duration: 'duration',
815 Latency: 'latency' 815 Latency: 'latency'
816 }; 816 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698