Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/network/NetworkLogViewColumns.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/network/NetworkLogViewColumns.js b/third_party/WebKit/Source/devtools/front_end/network/NetworkLogViewColumns.js |
| index 2001eb2936f9424d3b3c932ba5effabb8408f2c6..24f9d431e13f68ab2fe0e3e15f79c9dc0c9672f0 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/network/NetworkLogViewColumns.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/network/NetworkLogViewColumns.js |
| @@ -29,6 +29,9 @@ Network.NetworkLogViewColumns = class { |
| /** @type {!Array.<!Network.NetworkLogViewColumns.Descriptor>} */ |
| this._columns = []; |
| + /** @type {!Map<string, ?Network.NetworkColumnExtensionInterface>} */ |
| + this._columnExtensions = new Map(); |
| + |
| this._waterfallRequestsAreStale = false; |
| this._waterfallScrollerWidthIsStale = true; |
| @@ -86,6 +89,7 @@ Network.NetworkLogViewColumns = class { |
| columnConfig.titleDOMFragment = this._makeHeaderFragment(columnConfig.title, columnConfig.subtitle); |
| this._columns.push(columnConfig); |
| } |
| + this._loadColumnExtensions(); |
| this._loadCustomColumnsAndSettings(); |
| this._popoverHelper = new UI.PopoverHelper(this._networkLogView.element); |
| @@ -327,6 +331,13 @@ Network.NetworkLogViewColumns = class { |
| } |
| /** |
| + * @return {!Map<string, ?Network.NetworkColumnExtensionInterface>} |
| + */ |
| + columnExtensions() { |
| + return this._columnExtensions; |
| + } |
| + |
| + /** |
| * @param {!Network.NetworkLogViewColumns.Descriptor} columnConfig |
| */ |
| _toggleColumnVisibility(columnConfig) { |
| @@ -344,6 +355,43 @@ Network.NetworkLogViewColumns = class { |
| this._persistantSettings.set(saveableSettings); |
| } |
| + _loadColumnExtensions() { |
| + var extensions = self.runtime.extensions(Network.NetworkColumnExtensionInterface); |
| + for (var i = 0; i < extensions.length; i++) { |
| + var extension = extensions[i]; |
| + var title = extension.title(); |
| + var columnId = title.toLowerCase() + '-extension'; |
| + |
| + this._columnExtensions.set(columnId, null); |
| + extension.instance().then(extensionInstanceResolved.bind(this, columnId)); |
| + |
| + var columnConfig = /** @type {!Network.NetworkLogViewColumns.Descriptor} */ ( |
| + Object.assign(/** @type {!Object} */ ({}), Network.NetworkLogViewColumns._defaultColumnConfig, { |
|
caseq
2017/03/17 00:16:29
I think this cast should not be required.
allada
2017/03/17 01:16:09
Done.
|
| + id: columnId, |
| + title: title, |
| + isResponseHeader: false, |
| + isCustomHeader: false, |
| + visible: true, |
| + sortingFunction: |
| + Network.NetworkRequestNode.ExtensionColumnComparator.bind(null, this._columnExtensions, columnId) |
| + })); |
| + const columnIndex = i + 1; |
| + this._columns.splice(columnIndex, 0, columnConfig); |
| + if (this._dataGrid) |
| + this._dataGrid.addColumn(Network.NetworkLogViewColumns._convertToDataGridDescriptor(columnConfig), columnIndex); |
| + } |
| + |
| + /** |
| + * @param {string} columnId |
| + * @param {!Network.NetworkColumnExtensionInterface} instance |
| + * @this {Network.NetworkLogViewColumns} |
| + */ |
| + function extensionInstanceResolved(columnId, instance) { |
| + this._columnExtensions.set(columnId, instance); |
| + this._networkLogView.columnExtensionResolved(); |
| + } |
| + } |
| + |
| _loadCustomColumnsAndSettings() { |
| var savedSettings = this._persistantSettings.get(); |
| var columnIds = Object.keys(savedSettings); |
| @@ -814,3 +862,16 @@ Network.NetworkLogViewColumns.WaterfallSortIds = { |
| Duration: 'duration', |
| Latency: 'latency' |
| }; |
| + |
| +/** |
| + * @interface |
| + */ |
| +Network.NetworkColumnExtensionInterface = function() {}; |
| + |
| +Network.NetworkColumnExtensionInterface.prototype = { |
| + /** |
| + * @param {!SDK.NetworkRequest} request |
| + * @return {string} |
| + */ |
| + lookupColumnValue(request) {} |
| +}; |