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

Unified Diff: third_party/WebKit/Source/devtools/front_end/network_group_lookup/NetworkProductGroupLookup.js

Issue 2788793002: [Devtools] Added frame grouping to network panel (Closed)
Patch Set: changes Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/network_group_lookup/NetworkProductGroupLookup.js
diff --git a/third_party/WebKit/Source/devtools/front_end/network_group_lookup/NetworkProductGroupLookup.js b/third_party/WebKit/Source/devtools/front_end/network_group_lookup/NetworkProductGroupLookup.js
index c264d77c74023341d17753232b8edb1a0b8a1563..95edcda762420b483c0bc80937bcb50cb8438670 100644
--- a/third_party/WebKit/Source/devtools/front_end/network_group_lookup/NetworkProductGroupLookup.js
+++ b/third_party/WebKit/Source/devtools/front_end/network_group_lookup/NetworkProductGroupLookup.js
@@ -9,10 +9,22 @@ NetworkGroupLookup.NetworkProductGroupLookup = class {
/**
* @override
* @param {!SDK.NetworkRequest} request
- * @return {?string}
+ * @return {?*}
+ */
+ groupForRequest(request) {
+ var productName = ProductRegistry.nameForUrl(request.parsedURL);
+ if (!productName)
+ return null;
+ return productName;
+ }
+
+ /**
+ * @override
+ * @param {!*} key
+ * @return {string}
*/
- lookup(request) {
- return ProductRegistry.nameForUrl(request.parsedURL);
+ groupName(key) {
+ return /** @type {string} */ (key);
}
/**
@@ -21,7 +33,7 @@ NetworkGroupLookup.NetworkProductGroupLookup = class {
* @return {string}
*/
lookupColumnValue(request) {
- return this.lookup(request) || '';
+ return ProductRegistry.nameForUrl(request.parsedURL) || '';
}
/**
@@ -38,3 +50,67 @@ NetworkGroupLookup.NetworkProductGroupLookup = class {
return aValue > bValue ? 1 : -1;
}
};
+
+/**
+ * @implements {Network.NetworkGroupLookupInterface}
+ */
+NetworkGroupLookup.NetworkProductFrameGroupLookup = class {
+ /**
+ * @override
+ * @param {!SDK.NetworkRequest} request
+ * @return {?*}
+ */
+ groupForRequest(request) {
+ var resourceTreeModel = request.target().model(SDK.ResourceTreeModel);
+ if (!resourceTreeModel)
+ return null;
+ var frame = resourceTreeModel.frameForId(request.frameId);
+ if (!frame || frame.isMainFrame())
+ return null;
+ return frame;
+ }
+
+ /**
+ * @override
+ * @param {!*} frameArg
+ * @return {string}
+ */
+ groupName(frameArg) {
+ var frame = /** @type {!SDK.ResourceTreeFrame} */ (frameArg);
+ var name;
+ var frameParsedURL = new Common.ParsedURL(frame.url);
+ if (frame.url)
+ name = ProductRegistry.nameForUrl(frameParsedURL);
+ if (name)
+ return name;
+ // We are not caching the frame url result because it may change.
+ var symbol = NetworkGroupLookup.NetworkProductFrameGroupLookup._productFrameGroupNameSymbol;
+ if (frame[symbol])
+ return frame[symbol];
+ frame[symbol] = this._lookupFrameStacktraceName(frame) || frameParsedURL.host || frame.name || '<iframe>';
+ return frame[symbol];
+ }
+
+ /**
+ * @param {!SDK.ResourceTreeFrame} frame
+ * @return {?string}
+ */
+ _lookupFrameStacktraceName(frame) {
+ // TODO(allada) This probably belongs in another shared module with some lookup that console will use for execution
+ // context name lookup.
+ var stackTrace = frame.creationStackTrace();
+ var name;
+ while (stackTrace) {
+ for (var stack of stackTrace.callFrames) {
+ if (stack.url)
+ name = ProductRegistry.nameForUrl(new Common.ParsedURL(stack.url));
+ if (name)
+ return name;
+ }
+ stackTrace = frame.parent;
+ }
+ return null;
+ }
+};
+
+NetworkGroupLookup.NetworkProductFrameGroupLookup._productFrameGroupNameSymbol = Symbol('ProductFrameGroupName');

Powered by Google App Engine
This is Rietveld 408576698