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

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

Issue 2756583002: [Devtools] Added ability to add extension columns to network (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 | third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 20 matching lines...) Expand all
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 Network.NetworkNode = class extends DataGrid.SortableDataGridNode { 34 Network.NetworkNode = class extends DataGrid.SortableDataGridNode {
35 /** 35 /**
36 * @param {!Network.NetworkLogView} parentView 36 * @param {!Network.NetworkLogView} parentView
37 */ 37 */
38 constructor(parentView) { 38 constructor(parentView) {
39 super({}); 39 super({});
40 this._parentView = parentView; 40 this._parentView = parentView;
41 /**
42 * @protected
43 * @type {!Map<string, ?Network.NetworkColumnExtensionInterface>}
44 */
45 this.columnExtensions = new Map();
41 this._isHovered = false; 46 this._isHovered = false;
42 this._showingInitiatorChain = false; 47 this._showingInitiatorChain = false;
43 /** @type {?SDK.NetworkRequest} */ 48 /** @type {?SDK.NetworkRequest} */
44 this._requestOrFirstKnownChildRequest = null; 49 this._requestOrFirstKnownChildRequest = null;
45 } 50 }
46 51
47 /** 52 /**
48 * @return {!Network.NetworkLogView} 53 * @return {!Network.NetworkLogView}
49 */ 54 */
50 parentView() { 55 parentView() {
(...skipping 16 matching lines...) Expand all
67 72
68 /** 73 /**
69 * @override 74 * @override
70 * @return {number} 75 * @return {number}
71 */ 76 */
72 nodeSelfHeight() { 77 nodeSelfHeight() {
73 return this._parentView.rowHeight(); 78 return this._parentView.rowHeight();
74 } 79 }
75 80
76 /** 81 /**
82 * @param {!Map<string, ?Network.NetworkColumnExtensionInterface>} columnExten sions
83 */
84 setColumnExtensions(columnExtensions) {
85 this.columnExtensions = columnExtensions;
86 }
87
88 /**
77 * @param {boolean} hovered 89 * @param {boolean} hovered
78 * @param {boolean} showInitiatorChain 90 * @param {boolean} showInitiatorChain
79 */ 91 */
80 setHovered(hovered, showInitiatorChain) { 92 setHovered(hovered, showInitiatorChain) {
81 if (this._isHovered === hovered && this._showingInitiatorChain === showIniti atorChain) 93 if (this._isHovered === hovered && this._showingInitiatorChain === showIniti atorChain)
82 return; 94 return;
83 if (this._isHovered !== hovered) { 95 if (this._isHovered !== hovered) {
84 this._isHovered = hovered; 96 this._isHovered = hovered;
85 if (this.attached()) 97 if (this.attached())
86 this.element().classList.toggle('hover', hovered); 98 this.element().classList.toggle('hover', hovered);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 var aHeader = aRequest.responseHeaderValue(propertyName); 469 var aHeader = aRequest.responseHeaderValue(propertyName);
458 var bHeader = bRequest.responseHeaderValue(propertyName); 470 var bHeader = bRequest.responseHeaderValue(propertyName);
459 var aValue = aHeader ? new Date(aHeader).getTime() : -Infinity; 471 var aValue = aHeader ? new Date(aHeader).getTime() : -Infinity;
460 var bValue = bHeader ? new Date(bHeader).getTime() : -Infinity; 472 var bValue = bHeader ? new Date(bHeader).getTime() : -Infinity;
461 if (aValue === bValue) 473 if (aValue === bValue)
462 return aRequest.indentityCompare(bRequest); 474 return aRequest.indentityCompare(bRequest);
463 return aValue > bValue ? 1 : -1; 475 return aValue > bValue ? 1 : -1;
464 } 476 }
465 477
466 /** 478 /**
479 * @param {!Map<string, ?Network.NetworkColumnExtensionInterface>} extensionsM ap
480 * @param {string} extensionId
481 * @param {!Network.NetworkNode} a
482 * @param {!Network.NetworkNode} b
483 * @return {number}
484 */
485 static ExtensionColumnComparator(extensionsMap, extensionId, a, b) {
486 var aRequest = a.requestOrFirstKnownChildRequest();
487 var bRequest = b.requestOrFirstKnownChildRequest();
488 if (!aRequest || !bRequest)
489 return !aRequest ? -1 : 1;
490 var instance = extensionsMap.get(extensionId);
491 if (!instance)
492 return aRequest.indentityCompare(bRequest);
493 var aValue = instance.lookup(aRequest) || '';
494 var bValue = instance.lookup(bRequest) || '';
495 if (aValue === bValue)
496 return aRequest.indentityCompare(bRequest);
497 return aValue > bValue ? 1 : -1;
498 }
499
500 /**
467 * @override 501 * @override
468 */ 502 */
469 showingInitiatorChainChanged() { 503 showingInitiatorChainChanged() {
470 var showInitiatorChain = this.showingInitiatorChain(); 504 var showInitiatorChain = this.showingInitiatorChain();
471 505
472 var initiatorGraph = SDK.NetworkLog.initiatorGraphForRequest(this._request); 506 var initiatorGraph = SDK.NetworkLog.initiatorGraphForRequest(this._request);
473 for (var request of initiatorGraph.initiators) { 507 for (var request of initiatorGraph.initiators) {
474 if (request === this._request) 508 if (request === this._request)
475 continue; 509 continue;
476 var node = this.parentView().nodeForRequest(request); 510 var node = this.parentView().nodeForRequest(request);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 element.title = text; 631 element.title = text;
598 } 632 }
599 633
600 /** 634 /**
601 * @override 635 * @override
602 * @param {string} columnIdentifier 636 * @param {string} columnIdentifier
603 * @return {!Element} 637 * @return {!Element}
604 */ 638 */
605 createCell(columnIdentifier) { 639 createCell(columnIdentifier) {
606 var cell = this.createTD(columnIdentifier); 640 var cell = this.createTD(columnIdentifier);
641 // If the key exists but the value is null it means the extension instance h as not resolved yet.
642 // The view controller will force all rows to update when extension is resol ved.
643 if (this.columnExtensions.has(columnIdentifier)) {
644 var instance = this.columnExtensions.get(columnIdentifier);
645 if (instance)
646 this._setTextAndTitle(cell, instance.lookup(this._request) || '');
647 return cell;
648 }
607 switch (columnIdentifier) { 649 switch (columnIdentifier) {
608 case 'name': 650 case 'name':
609 this._renderNameCell(cell); 651 this._renderNameCell(cell);
610 break; 652 break;
611 case 'method': 653 case 'method':
612 this._setTextAndTitle(cell, this._request.requestMethod); 654 this._setTextAndTitle(cell, this._request.requestMethod);
613 break; 655 break;
614 case 'status': 656 case 'status':
615 this._renderStatusCell(cell); 657 this._renderStatusCell(cell);
616 break; 658 break;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 element.title = text; 989 element.title = text;
948 } 990 }
949 991
950 /** 992 /**
951 * @override 993 * @override
952 * @param {string} columnIdentifier 994 * @param {string} columnIdentifier
953 * @return {!Element} 995 * @return {!Element}
954 */ 996 */
955 createCell(columnIdentifier) { 997 createCell(columnIdentifier) {
956 var cell = this.createTD(columnIdentifier); 998 var cell = this.createTD(columnIdentifier);
999 if (this.columnExtensions.has(columnIdentifier))
allada 2017/03/15 21:42:02 This is the createCell for group nodes which we cu
1000 return cell;
957 if (columnIdentifier === 'name') { 1001 if (columnIdentifier === 'name') {
958 var leftPadding = this.leftPadding ? this.leftPadding + 'px' : ''; 1002 var leftPadding = this.leftPadding ? this.leftPadding + 'px' : '';
959 cell.style.setProperty('padding-left', leftPadding); 1003 cell.style.setProperty('padding-left', leftPadding);
960 cell.classList.add('disclosure'); 1004 cell.classList.add('disclosure');
961 this._setTextAndTitle(cell, this._displayName); 1005 this._setTextAndTitle(cell, this._displayName);
962 } 1006 }
963 return cell; 1007 return cell;
964 } 1008 }
965 1009
966 /** 1010 /**
967 * @override 1011 * @override
968 * @param {boolean=} supressSelectedEvent 1012 * @param {boolean=} supressSelectedEvent
969 */ 1013 */
970 select(supressSelectedEvent) { 1014 select(supressSelectedEvent) {
971 if (this.expanded) { 1015 if (this.expanded) {
972 this.collapse(); 1016 this.collapse();
973 return; 1017 return;
974 } 1018 }
975 this.expand(); 1019 this.expand();
976 } 1020 }
977 }; 1021 };
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698