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

Unified Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkGroupers.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, 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/NetworkGroupers.js
diff --git a/third_party/WebKit/Source/devtools/front_end/network/NetworkGroupers.js b/third_party/WebKit/Source/devtools/front_end/network/NetworkGroupers.js
new file mode 100644
index 0000000000000000000000000000000000000000..3f78ea0c42b376fb2bc3d48de6509e99a1578d69
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/front_end/network/NetworkGroupers.js
@@ -0,0 +1,90 @@
+// 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.ProductGrouper = class {
+ constructor() {
+ /** @type {?ProductRegistry.Registry} */
+ this._productRegistry = null;
+ }
+
+ /**
+ * @override
+ * @return {!Promise}
+ */
+ initialize() {
+ return ProductRegistry.instance().then(productRegistry => this._productRegistry = productRegistry);
+ }
+
+ /**
+ * @override
+ * @param {!SDK.NetworkRequest} request
+ * @return {?*}
+ */
+ groupForRequest(request) {
+ if (!this._productRegistry)
+ return null;
+ var productName = this._productRegistry.nameForUrl(request.parsedURL);
+ if (!productName)
+ return null;
+ return productName;
+ }
+
+ /**
+ * @override
+ * @param {!*} key
+ * @return {string}
+ */
+ groupName(key) {
+ return /** @type {string} */ (key);
+ }
+};
+
+/**
+ * @implements {Network.GroupLookupInterface}
+ */
+Network.FrameGrouper = class {
+ constructor() {
+ /** @type {?ProductRegistry.Registry} */
+ this._productRegistry = null;
+ }
+
+ /**
+ * @override
+ * @return {!Promise}
+ */
+ initialize() {
+ return ProductRegistry.instance().then(productRegistry => this._productRegistry = productRegistry);
+ }
+
+ /**
+ * @override
+ * @param {!SDK.NetworkRequest} request
+ * @return {?*}
+ */
+ groupForRequest(request) {
+ var resourceTreeModel = request.networkManager().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 entry = this._productRegistry ? this._productRegistry.entryForFrame(frame) : null;
+ if (entry)
+ return entry.name;
+ return (new Common.ParsedURL(frame.url)).host || frame.name || '<iframe>';
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698