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

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: 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/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..3152c5166d682392fde658cb1b99d58258ac5362
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/front_end/network/NetworkGroupers.js
@@ -0,0 +1,89 @@
+// 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.
+/**
pfeldman 2017/04/28 21:08:35 Where is my line? :)
allada 2017/04/28 22:21:09 Done.
+ * @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