OLD | NEW |
(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 * @implements {Network.GroupLookupInterface} |
| 6 */ |
| 7 Network.ProductGrouper = class { |
| 8 /** |
| 9 * @override |
| 10 * @param {!SDK.NetworkRequest} request |
| 11 * @return {?*} |
| 12 */ |
| 13 groupForRequest(request) { |
| 14 var productRegistry = ProductRegistry.existingInstance(); |
| 15 if (!productRegistry) |
| 16 return null; |
| 17 var productName = productRegistry.nameForUrl(request.parsedURL); |
| 18 if (!productName) |
| 19 return null; |
| 20 return productName; |
| 21 } |
| 22 |
| 23 /** |
| 24 * @override |
| 25 * @param {!*} key |
| 26 * @return {string} |
| 27 */ |
| 28 groupName(key) { |
| 29 return /** @type {string} */ (key); |
| 30 } |
| 31 }; |
| 32 |
| 33 /** |
| 34 * @implements {Network.GroupLookupInterface} |
| 35 */ |
| 36 Network.FrameGrouper = class { |
| 37 /** |
| 38 * @override |
| 39 * @param {!SDK.NetworkRequest} request |
| 40 * @return {?*} |
| 41 */ |
| 42 groupForRequest(request) { |
| 43 var resourceTreeModel = request.networkManager().target().model(SDK.Resource
TreeModel); |
| 44 if (!resourceTreeModel) |
| 45 return null; |
| 46 var frame = resourceTreeModel.frameForId(request.frameId); |
| 47 if (!frame || frame.isMainFrame()) |
| 48 return null; |
| 49 return frame; |
| 50 } |
| 51 |
| 52 /** |
| 53 * @override |
| 54 * @param {!*} frameArg |
| 55 * @return {string} |
| 56 */ |
| 57 groupName(frameArg) { |
| 58 var frame = /** @type {!SDK.ResourceTreeFrame} */ (frameArg); |
| 59 var productRegistry = ProductRegistry.existingInstance(); |
| 60 var entry = productRegistry ? productRegistry.entryForFrame(frame) : null; |
| 61 if (entry) |
| 62 return entry.name; |
| 63 return (new Common.ParsedURL(frame.url)).host || frame.name || '<iframe>'; |
| 64 } |
| 65 }; |
OLD | NEW |