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

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

Issue 2859063003: [Devtools] Restructure network nodes for friendlier products/grouping (Closed)
Patch Set: [Devtools] Restructure network nodes for friendlier products/grouping 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @implements {Network.GroupLookupInterface}
7 */
8 Network.FrameGrouper = class {
9 /**
10 * @param {!Network.NetworkLogView} parentView
11 */
12 constructor(parentView) {
13 this._parentView = parentView;
14 /** @type {?ProductRegistry.Registry} */
15 this._productRegistry = null;
16 /** @type {!Map<!SDK.ResourceTreeFrame, !Network.FrameGroupNode>} */
17 this._activeGroups = new Map();
18 }
19
20 /**
21 * @override
22 * @return {!Promise}
23 */
24 initialize() {
25 return ProductRegistry.instance().then(productRegistry => {
26 this._productRegistry = productRegistry;
27 this._activeGroups.forEach(node => node.refresh());
28 });
29 }
30
31 /**
32 * @override
33 * @param {!SDK.NetworkRequest} request
34 * @return {?Network.NetworkGroupNode}
35 */
36 groupNodeForRequest(request) {
37 var frame = SDK.ResourceTreeModel.frameForRequest(request);
38 if (!frame || frame.isMainFrame())
39 return null;
40 var groupNode = this._activeGroups.get(frame);
41 if (groupNode)
42 return groupNode;
43 groupNode = new Network.FrameGroupNode(this._parentView, frame, this);
44 this._activeGroups.set(frame, groupNode);
45 return groupNode;
46 }
47
48 /**
49 * @override
50 */
51 reset() {
52 this._activeGroups.clear();
53 }
54 };
55
56 Network.FrameGroupNode = class extends Network.NetworkGroupNode {
57 /**
58 * @param {!Network.NetworkLogView} parentView
59 * @param {!SDK.ResourceTreeFrame} frame
60 * @param {!Network.FrameGrouper} grouper
61 */
62 constructor(parentView, frame, grouper) {
63 super(parentView);
64 this._frame = frame;
65 this._grouper = grouper;
66 /** @type {?ProductRegistry.Registry.ProductEntry|undefined} */
67 this._productEntryCache;
68 }
69
70 /**
71 * @override
72 * @return {boolean}
73 */
74 isFromFrame() {
75 return true;
76 }
77
78 /**
79 * @override
80 */
81 displayName() {
82 var entry = this._entry();
83 return entry ? entry.name : (new Common.ParsedURL(this._frame.url)).host || this._frame.name || '<iframe>';
84 }
85
86 /**
87 * @override
88 * @param {!Element} cell
89 * @param {string} columnId
90 */
91 renderCell(cell, columnId) {
92 super.renderCell(cell, columnId);
93 if (columnId === 'name') {
94 var name = this.displayName();
95 cell.textContent = name;
96 cell.title = name;
97 }
98 if (columnId === 'product') {
99 var entry = this._entry();
100 if (!entry)
101 return;
102 cell.textContent = entry.name;
103 cell.title = entry.name;
104 }
105 }
106
107 /**
108 * @return {?ProductRegistry.Registry.ProductEntry}
109 */
110 _entry() {
111 if (this._productEntryCache !== undefined)
112 return this._productEntryCache;
113 var productRegistry = this._grouper._productRegistry;
114 if (!productRegistry)
115 return null;
116 this._productEntryCache = productRegistry.entryForFrame(this._frame);
117 return this._productEntryCache;
118 }
119 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698