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 /** |
| 6 * @implements {Network.GroupLookupInterface} |
| 7 */ |
| 8 Network.ProductGrouper = class { |
| 9 constructor() { |
| 10 /** @type {?ProductRegistry.Registry} */ |
| 11 this._productRegistry = null; |
| 12 } |
| 13 |
| 14 /** |
| 15 * @override |
| 16 * @return {!Promise} |
| 17 */ |
| 18 initialize() { |
| 19 return ProductRegistry.instance().then(productRegistry => this._productRegis
try = productRegistry); |
| 20 } |
| 21 |
| 22 /** |
| 23 * @override |
| 24 * @param {!SDK.NetworkRequest} request |
| 25 * @return {?*} |
| 26 */ |
| 27 groupForRequest(request) { |
| 28 if (!this._productRegistry) |
| 29 return null; |
| 30 var productName = this._productRegistry.nameForUrl(request.parsedURL); |
| 31 if (!productName) |
| 32 return null; |
| 33 return productName; |
| 34 } |
| 35 |
| 36 /** |
| 37 * @override |
| 38 * @param {!*} key |
| 39 * @return {string} |
| 40 */ |
| 41 groupName(key) { |
| 42 return /** @type {string} */ (key); |
| 43 } |
| 44 }; |
| 45 |
| 46 /** |
| 47 * @implements {Network.GroupLookupInterface} |
| 48 */ |
| 49 Network.FrameGrouper = class { |
| 50 constructor() { |
| 51 /** @type {?ProductRegistry.Registry} */ |
| 52 this._productRegistry = null; |
| 53 } |
| 54 |
| 55 /** |
| 56 * @override |
| 57 * @return {!Promise} |
| 58 */ |
| 59 initialize() { |
| 60 return ProductRegistry.instance().then(productRegistry => this._productRegis
try = productRegistry); |
| 61 } |
| 62 |
| 63 /** |
| 64 * @override |
| 65 * @param {!SDK.NetworkRequest} request |
| 66 * @return {?*} |
| 67 */ |
| 68 groupForRequest(request) { |
| 69 var resourceTreeModel = request.networkManager().target().model(SDK.Resource
TreeModel); |
| 70 if (!resourceTreeModel) |
| 71 return null; |
| 72 var frame = resourceTreeModel.frameForId(request.frameId); |
| 73 if (!frame || frame.isMainFrame()) |
| 74 return null; |
| 75 return frame; |
| 76 } |
| 77 |
| 78 /** |
| 79 * @override |
| 80 * @param {!*} frameArg |
| 81 * @return {string} |
| 82 */ |
| 83 groupName(frameArg) { |
| 84 var frame = /** @type {!SDK.ResourceTreeFrame} */ (frameArg); |
| 85 var entry = this._productRegistry ? this._productRegistry.entryForFrame(fram
e) : null; |
| 86 if (entry) |
| 87 return entry.name; |
| 88 return (new Common.ParsedURL(frame.url)).host || frame.name || '<iframe>'; |
| 89 } |
| 90 }; |
OLD | NEW |