Index: third_party/WebKit/Source/devtools/front_end/network/NetworkFrameGrouper.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/network/NetworkFrameGrouper.js b/third_party/WebKit/Source/devtools/front_end/network/NetworkFrameGrouper.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5a5fa29ec99780c1d7ac9d45658031c63f4d448a |
--- /dev/null |
+++ b/third_party/WebKit/Source/devtools/front_end/network/NetworkFrameGrouper.js |
@@ -0,0 +1,119 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * @implements {Network.GroupLookupInterface} |
+ */ |
+Network.FrameGrouper = class { |
+ /** |
+ * @param {!Network.NetworkLogView} parentView |
+ */ |
+ constructor(parentView) { |
+ this._parentView = parentView; |
+ /** @type {?ProductRegistry.Registry} */ |
+ this._productRegistry = null; |
+ /** @type {!Map<!SDK.ResourceTreeFrame, !Network.FrameGroupNode>} */ |
+ this._activeGroups = new Map(); |
+ } |
+ |
+ /** |
+ * @override |
+ * @return {!Promise} |
+ */ |
+ initialize() { |
+ return ProductRegistry.instance().then(productRegistry => { |
+ this._productRegistry = productRegistry; |
+ this._activeGroups.forEach(node => node.refresh()); |
+ }); |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {!SDK.NetworkRequest} request |
+ * @return {?Network.NetworkGroupNode} |
+ */ |
+ groupNodeForRequest(request) { |
+ var frame = request.resourceTreeFrame(); |
+ if (!frame || frame.isMainFrame()) |
+ return null; |
+ var groupNode = this._activeGroups.get(frame); |
+ if (groupNode) |
+ return groupNode; |
+ groupNode = new Network.FrameGroupNode(this._parentView, frame, this); |
+ this._activeGroups.set(frame, groupNode); |
+ return groupNode; |
+ } |
+ |
+ /** |
+ * @override |
+ */ |
+ reset() { |
+ this._activeGroups.clear(); |
+ } |
+}; |
+ |
+Network.FrameGroupNode = class extends Network.NetworkGroupNode { |
+ /** |
+ * @param {!Network.NetworkLogView} parentView |
+ * @param {!SDK.ResourceTreeFrame} frame |
+ * @param {!Network.FrameGrouper} grouper |
+ */ |
+ constructor(parentView, frame, grouper) { |
+ super(parentView); |
+ this._frame = frame; |
+ this._grouper = grouper; |
+ /** @type {?ProductRegistry.Registry.ProductEntry|undefined} */ |
+ this._productEntryCache; |
+ } |
+ |
+ /** |
+ * @override |
+ * @return {boolean} |
+ */ |
+ isFromFrame() { |
+ return true; |
+ } |
+ |
+ /** |
+ * @override |
+ */ |
+ displayName() { |
+ var entry = this._getEntry(); |
+ return entry ? entry.name : (new Common.ParsedURL(this._frame.url)).host || this._frame.name || '<iframe>'; |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {!Element} cell |
+ * @param {string} columnId |
+ */ |
+ renderCell(cell, columnId) { |
+ super.renderCell(cell, columnId); |
+ if (columnId === 'name') { |
+ var name = this.displayName(); |
+ cell.textContent = name; |
+ cell.title = name; |
+ } |
+ if (columnId === 'product') { |
+ var entry = this._getEntry(); |
+ if (!entry) |
+ return; |
+ cell.textContent = entry.name; |
+ cell.title = entry.name; |
+ } |
+ } |
+ |
+ /** |
+ * @return {?ProductRegistry.Registry.ProductEntry} |
+ */ |
+ _getEntry() { |
pfeldman
2017/05/04 22:54:08
_entry
allada
2017/05/05 00:43:13
Done.
|
+ if (this._productEntryCache !== undefined) |
+ return this._productEntryCache; |
+ var productRegistry = this._grouper._productRegistry; |
+ if (!productRegistry) |
+ return null; |
+ this._productEntryCache = productRegistry.entryForFrame(this._frame); |
+ return this._productEntryCache; |
+ } |
+}; |