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

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

Issue 2839273003: [Devtools] New structure and colorize rows for network products (Closed)
Patch Set: Merge remote-tracking branch 'origin/master' into NEW_DEPENDENCY_PRODUCTS 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 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org>
4 * Copyright (C) 2011 Google Inc. All rights reserved. 4 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 this._progressBarContainer = progressBarContainer; 50 this._progressBarContainer = progressBarContainer;
51 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; 51 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting;
52 this._networkLogLargeRowsSetting.addChangeListener(updateRowHeight.bind(this ), this); 52 this._networkLogLargeRowsSetting.addChangeListener(updateRowHeight.bind(this ), this);
53 53
54 /** @type {!Network.NetworkTransferTimeCalculator} */ 54 /** @type {!Network.NetworkTransferTimeCalculator} */
55 this._timeCalculator = new Network.NetworkTransferTimeCalculator(); 55 this._timeCalculator = new Network.NetworkTransferTimeCalculator();
56 /** @type {!Network.NetworkTransferDurationCalculator} */ 56 /** @type {!Network.NetworkTransferDurationCalculator} */
57 this._durationCalculator = new Network.NetworkTransferDurationCalculator(); 57 this._durationCalculator = new Network.NetworkTransferDurationCalculator();
58 this._calculator = this._timeCalculator; 58 this._calculator = this._timeCalculator;
59 59
60 /** @type {?Network.NetworkGroupLookupInterface} */
61 this._activeGroupLookup = null;
62
63 /** 60 /**
64 * @this {Network.NetworkLogView} 61 * @this {Network.NetworkLogView}
65 */ 62 */
66 function updateRowHeight() { 63 function updateRowHeight() {
67 /** @type {number} */ 64 /** @type {number} */
68 this._rowHeight = !!this._networkLogLargeRowsSetting.get() ? 41 : 21; 65 this._rowHeight = !!this._networkLogLargeRowsSetting.get() ? 41 : 21;
69 } 66 }
70 updateRowHeight.call(this); 67 updateRowHeight.call(this);
71 68
72 this._columns = new Network.NetworkLogViewColumns( 69 this._columns = new Network.NetworkLogViewColumns(
73 this, this._timeCalculator, this._durationCalculator, networkLogLargeRow sSetting); 70 this, this._timeCalculator, this._durationCalculator, networkLogLargeRow sSetting);
74 71
75 /** @type {!Map.<string, !Network.NetworkRequestNode>} */ 72 /** @type {!Map.<string, !Network.NetworkRequestNode>} */
76 this._nodesByRequestId = new Map(); 73 this._nodesByRequestId = new Map();
77 /** @type {!Map<*, !Network.NetworkGroupNode>} */ 74 /** @type {!Map<*, !Network.NetworkGroupNode>} */
78 this._nodeGroups = new Map(); 75 this._nodeGroups = new Map();
79 /** @type {!Set<!Network.NetworkRowDecorator>} */
80 this._rowDecorators = new Set();
81
82 /** @type {!Object.<string, boolean>} */ 76 /** @type {!Object.<string, boolean>} */
83 this._staleRequestIds = {}; 77 this._staleRequestIds = {};
84 /** @type {number} */ 78 /** @type {number} */
85 this._mainRequestLoadTime = -1; 79 this._mainRequestLoadTime = -1;
86 /** @type {number} */ 80 /** @type {number} */
87 this._mainRequestDOMContentLoadedTime = -1; 81 this._mainRequestDOMContentLoadedTime = -1;
88 this._matchedRequestCount = 0; 82 this._matchedRequestCount = 0;
89 this._highlightedSubstringChanges = []; 83 this._highlightedSubstringChanges = [];
90 84
91 /** @type {!Array.<!Network.NetworkLogView.Filter>} */ 85 /** @type {!Array.<!Network.NetworkLogView.Filter>} */
92 this._filters = []; 86 this._filters = [];
93 /** @type {?Network.NetworkLogView.Filter} */ 87 /** @type {?Network.NetworkLogView.Filter} */
94 this._timeFilter = null; 88 this._timeFilter = null;
95 /** @type {?Network.NetworkNode} */ 89 /** @type {?Network.NetworkNode} */
96 this._hoveredNode = null; 90 this._hoveredNode = null;
97 91
98 this._currentMatchedRequestNode = null; 92 this._currentMatchedRequestNode = null;
99 this._currentMatchedRequestIndex = -1; 93 this._currentMatchedRequestIndex = -1;
100 94
101 /** @type {!Components.Linkifier} */ 95 /** @type {!Components.Linkifier} */
102 this.linkifier = new Components.Linkifier(); 96 this.linkifier = new Components.Linkifier();
103 97
104 this._recording = false; 98 this._recording = false;
105 this._preserveLog = false; 99 this._preserveLog = false;
106 100
107 this._headerHeight = 0; 101 this._headerHeight = 0;
108 102
103 /** @type {!Map<string, !Network.GroupLookupInterface>} */
104 this._groupLookups = new Map();
105 this._groupLookups.set('Product', new Network.ProductGrouper());
106 this._groupLookups.set('Frame', new Network.FrameGrouper());
107
108 /** @type {?Network.GroupLookupInterface} */
109 this._activeGroupLookup = null;
110
109 this._addFilters(); 111 this._addFilters();
110 this._resetSuggestionBuilder(); 112 this._resetSuggestionBuilder();
111 this._initializeView(); 113 this._initializeView();
112 114
113 Common.moduleSetting('networkColorCodeResourceTypes') 115 Common.moduleSetting('networkColorCodeResourceTypes')
114 .addChangeListener(this._invalidateAllItems.bind(this, false), this); 116 .addChangeListener(this._invalidateAllItems.bind(this, false), this);
115 117
116 SDK.targetManager.observeModels(SDK.NetworkManager, this); 118 SDK.targetManager.observeModels(SDK.NetworkManager, this);
117 SDK.targetManager.addModelListener( 119 SDK.targetManager.addModelListener(
118 SDK.NetworkManager, SDK.NetworkManager.Events.RequestStarted, this._onRe questStarted, this); 120 SDK.NetworkManager, SDK.NetworkManager.Events.RequestStarted, this._onRe questStarted, this);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 */ 347 */
346 static _requestTimeFilter(windowStart, windowEnd, request) { 348 static _requestTimeFilter(windowStart, windowEnd, request) {
347 if (request.issueTime() > windowEnd) 349 if (request.issueTime() > windowEnd)
348 return false; 350 return false;
349 if (request.endTime !== -1 && request.endTime < windowStart) 351 if (request.endTime !== -1 && request.endTime < windowStart)
350 return false; 352 return false;
351 return true; 353 return true;
352 } 354 }
353 355
354 /** 356 /**
355 * @param {?Network.NetworkGroupLookupInterface} grouping 357 * @return {!Map<string, !Network.GroupLookupInterface>}
356 */ 358 */
357 setGrouping(grouping) { 359 groupLookups() {
358 this._activeGroupLookup = grouping; 360 return this._groupLookups;
359 this._nodeGroups.clear();
360 this._invalidateAllItems();
361 } 361 }
362 362
363 /** 363 /**
364 * @return {!Set<!Network.NetworkRowDecorator>} 364 * @param {string} groupKey
365 */ 365 */
366 rowDecorators() { 366 setGrouping(groupKey) {
367 return this._rowDecorators; 367 var groupLookup = this._groupLookups.get(groupKey) || null;
368 this._activeGroupLookup = groupLookup;
369 if (!groupLookup) {
370 this._nodeGroups.clear();
371 this._invalidateAllItems();
372 return;
373 }
374 groupLookup.initialize().then(() => {
375 if (this._activeGroupLookup !== groupLookup)
376 return;
377 this._nodeGroups.clear();
378 this._invalidateAllItems();
379 });
368 } 380 }
369 381
370 /** 382 /**
371 * @param {!SDK.NetworkRequest} request 383 * @param {!SDK.NetworkRequest} request
372 * @return {?Network.NetworkRequestNode} 384 * @return {?Network.NetworkRequestNode}
373 */ 385 */
374 nodeForRequest(request) { 386 nodeForRequest(request) {
375 return this._nodesByRequestId.get(request.requestId()); 387 return this._nodesByRequestId.get(request.requestId());
376 } 388 }
377 389
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 _filterChanged(event) { 503 _filterChanged(event) {
492 this.removeAllNodeHighlights(); 504 this.removeAllNodeHighlights();
493 this._parseFilterQuery(this._textFilterUI.value()); 505 this._parseFilterQuery(this._textFilterUI.value());
494 this._filterRequests(); 506 this._filterRequests();
495 } 507 }
496 508
497 _initializeView() { 509 _initializeView() {
498 this.element.id = 'network-container'; 510 this.element.id = 'network-container';
499 this._setupDataGrid(); 511 this._setupDataGrid();
500 512
501 self.runtime.allInstances(Network.NetworkRowDecorator).then(instances => {
502 for (var instance of instances)
503 this._rowDecorators.add(instance);
504 this._invalidateAllItems(true);
505 });
506
507 this._columns.show(this.element); 513 this._columns.show(this.element);
508 514
509 this._summaryBarElement = this.element.createChild('div', 'network-summary-b ar'); 515 this._summaryBarElement = this.element.createChild('div', 'network-summary-b ar');
510 516
511 this._columns.sortByCurrentColumn(); 517 this._columns.sortByCurrentColumn();
512 } 518 }
513 519
514 _showRecordingHint() { 520 _showRecordingHint() {
515 this._hideRecordingHint(); 521 this._hideRecordingHint();
516 this._recordingHint = this.element.createChild('div', 'network-status-pane f ill'); 522 this._recordingHint = this.element.createChild('div', 'network-status-pane f ill');
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 return this._dataGrid.rootNode(); 899 return this._dataGrid.rootNode();
894 900
895 var groupKey = this._activeGroupLookup.groupForRequest(node.request()); 901 var groupKey = this._activeGroupLookup.groupForRequest(node.request());
896 if (!groupKey) 902 if (!groupKey)
897 return this._dataGrid.rootNode(); 903 return this._dataGrid.rootNode();
898 904
899 var group = this._nodeGroups.get(groupKey); 905 var group = this._nodeGroups.get(groupKey);
900 if (group) 906 if (group)
901 return group; 907 return group;
902 group = new Network.NetworkGroupNode(this, this._activeGroupLookup.groupName (groupKey)); 908 group = new Network.NetworkGroupNode(this, this._activeGroupLookup.groupName (groupKey));
903 group.setColumnExtensions(this._columns.columnExtensions());
904 this._nodeGroups.set(groupKey, group); 909 this._nodeGroups.set(groupKey, group);
905 return group; 910 return group;
906 } 911 }
907 912
908 reset() { 913 reset() {
909 this._requestWithHighlightedInitiators = null; 914 this._requestWithHighlightedInitiators = null;
910 this.dispatchEventToListeners(Network.NetworkLogView.Events.RequestSelected, null); 915 this.dispatchEventToListeners(Network.NetworkLogView.Events.RequestSelected, null);
911 916
912 this._clearSearchMatchedList(); 917 this._clearSearchMatchedList();
913 918
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 return; 960 return;
956 var request = /** @type {!SDK.NetworkRequest} */ (event.data); 961 var request = /** @type {!SDK.NetworkRequest} */ (event.data);
957 this._appendRequest(request); 962 this._appendRequest(request);
958 } 963 }
959 964
960 /** 965 /**
961 * @param {!SDK.NetworkRequest} request 966 * @param {!SDK.NetworkRequest} request
962 */ 967 */
963 _appendRequest(request) { 968 _appendRequest(request) {
964 var node = new Network.NetworkRequestNode(this, request); 969 var node = new Network.NetworkRequestNode(this, request);
965 node.setColumnExtensions(this._columns.columnExtensions());
966 node[Network.NetworkLogView._isFilteredOutSymbol] = true; 970 node[Network.NetworkLogView._isFilteredOutSymbol] = true;
967 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = false; 971 node[Network.NetworkLogView._isMatchingSearchQuerySymbol] = false;
968 972
969 // In case of redirect request id is reassigned to a redirected 973 // In case of redirect request id is reassigned to a redirected
970 // request and we need to update _nodesByRequestId and search results. 974 // request and we need to update _nodesByRequestId and search results.
971 var originalRequestNode = this._nodesByRequestId.get(request.requestId()); 975 var originalRequestNode = this._nodesByRequestId.get(request.requestId());
972 if (originalRequestNode) 976 if (originalRequestNode)
973 this._nodesByRequestId.set(originalRequestNode.request().requestId(), orig inalRequestNode); 977 this._nodesByRequestId.set(originalRequestNode.request().requestId(), orig inalRequestNode);
974 this._nodesByRequestId.set(request.requestId(), node); 978 this._nodesByRequestId.set(request.requestId(), node);
975 979
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 /** @type {!Array<string>} */ 1816 /** @type {!Array<string>} */
1813 Network.NetworkLogView._searchKeys = 1817 Network.NetworkLogView._searchKeys =
1814 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog View.FilterType[key]); 1818 Object.keys(Network.NetworkLogView.FilterType).map(key => Network.NetworkLog View.FilterType[key]);
1815 1819
1816 /** @typedef {function(!SDK.NetworkRequest): boolean} */ 1820 /** @typedef {function(!SDK.NetworkRequest): boolean} */
1817 Network.NetworkLogView.Filter; 1821 Network.NetworkLogView.Filter;
1818 1822
1819 /** 1823 /**
1820 * @interface 1824 * @interface
1821 */ 1825 */
1822 Network.NetworkGroupLookupInterface = function() {}; 1826 Network.GroupLookupInterface = function() {};
1823 1827
1824 Network.NetworkGroupLookupInterface.prototype = { 1828 Network.GroupLookupInterface.prototype = {
1829 /**
1830 * @return {!Promise}
1831 */
1832 initialize: function() {},
1833
1825 /** 1834 /**
1826 * @param {!SDK.NetworkRequest} request 1835 * @param {!SDK.NetworkRequest} request
1827 * @return {?*} 1836 * @return {?*}
1828 */ 1837 */
1829 groupForRequest(request) {}, 1838 groupForRequest: function(request) {},
1830 1839
1831 /** 1840 /**
1832 * @param {!*} key 1841 * @param {!*} key
1833 * @return {string} 1842 * @return {string}
1834 */ 1843 */
1835 groupName(key) {} 1844 groupName: function(key) {}
1836 }; 1845 };
1837
1838 /**
1839 * @interface
1840 */
1841 Network.NetworkRowDecorator = function() {};
1842
1843 Network.NetworkRowDecorator.prototype = {
1844 /**
1845 * @param {!Network.NetworkNode} node
1846 */
1847 decorate(node) {}
1848 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698