Skip to content

Commit 34c0f8c

Browse files
paulirishDevtools-frontend LUCI CQ
authored andcommitted
RPP: Resolve Chrome extension names for entities and TreeViews
Chrome extension name resolving was already available to AggregatedTimelineTreeView, but now, we'll update the associated Entity. This shifts the source of truth (of origins) towards our entity names. Bug: 395745032 Change-Id: Ie7738d2e81c9acbc0aef8f29306309e248902e8c Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6292329 Commit-Queue: Paul Irish <[email protected]> Reviewed-by: Adriana Ixba <[email protected]> Auto-Submit: Paul Irish <[email protected]>
1 parent 3173332 commit 34c0f8c

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

front_end/models/trace/handlers/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function makeUpChromeExtensionEntity(entityCache: Map<string, Entity>, url: stri
133133
category: 'Chrome Extension',
134134
homepage: 'https://chromewebstore.google.com/detail/' + host,
135135
categories: [],
136-
domains: [],
136+
domains: [origin],
137137
averageExecutionTime: 0,
138138
totalExecutionTime: 0,
139139
totalOccurrences: 0,

front_end/panels/timeline/TimelineDetailsView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export class TimelineDetailsPane extends
294294
}
295295
this.tabbedPane.closeTabs([Tab.PaintProfiler, Tab.LayerViewer], false);
296296
for (const view of this.rangeDetailViews.values()) {
297-
view.setModelWithEvents(data.selectedEvents, data.parsedTrace);
297+
view.setModelWithEvents(data.selectedEvents, data.parsedTrace, data.entityMapper);
298298
}
299299
// Set the 3p tree model.
300300
this.#thirdPartyTree.setModelWithEvents(data.selectedEvents, data.parsedTrace, data.entityMapper);

front_end/panels/timeline/TimelineTreeView.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import '../../ui/legacy/legacy.js';
77
import * as Common from '../../core/common/common.js';
88
import * as i18n from '../../core/i18n/i18n.js';
99
import * as Platform from '../../core/platform/platform.js';
10-
import * as SDK from '../../core/sdk/sdk.js';
1110
import * as Trace from '../../models/trace/trace.js';
1211
import * as ThirdPartyWeb from '../../third_party/third-party-web/third-party-web.js';
1312
import * as Buttons from '../../ui/components/buttons/buttons.js';
@@ -889,7 +888,6 @@ const treeNodeToGridNode = new WeakMap<Trace.Extras.TraceTree.Node, TreeGridNode
889888
export class AggregatedTimelineTreeView extends TimelineTreeView {
890889
protected readonly groupBySetting: Common.Settings.Setting<AggregatedTimelineTreeView.GroupBy>;
891890
readonly stackView: TimelineStackView;
892-
private executionContextNamesByOrigin = new Map<Platform.DevToolsPath.UrlString, string>();
893891

894892
constructor() {
895893
super();
@@ -906,7 +904,6 @@ export class AggregatedTimelineTreeView extends TimelineTreeView {
906904
}
907905

908906
override updateContents(selection: TimelineSelection): void {
909-
this.updateExtensionResolver();
910907
super.updateContents(selection);
911908
const rootNode = this.dataGrid.rootNode();
912909
if (rootNode.children.length) {
@@ -915,22 +912,14 @@ export class AggregatedTimelineTreeView extends TimelineTreeView {
915912
this.updateDetailsForSelection();
916913
}
917914

918-
private updateExtensionResolver(): void {
919-
this.executionContextNamesByOrigin = new Map();
920-
for (const runtimeModel of SDK.TargetManager.TargetManager.instance().models(SDK.RuntimeModel.RuntimeModel)) {
921-
for (const context of runtimeModel.executionContexts()) {
922-
this.executionContextNamesByOrigin.set(context.origin, context.name);
923-
}
924-
}
925-
}
926-
927-
private beautifyDomainName(this: AggregatedTimelineTreeView, name: string): string {
915+
private beautifyDomainName(this: AggregatedTimelineTreeView, name: string, node: Trace.Extras.TraceTree.Node):
916+
string {
928917
if (AggregatedTimelineTreeView.isExtensionInternalURL(name as Platform.DevToolsPath.UrlString)) {
929918
name = i18nString(UIStrings.chromeExtensionsOverhead);
930919
} else if (AggregatedTimelineTreeView.isV8NativeURL(name as Platform.DevToolsPath.UrlString)) {
931920
name = i18nString(UIStrings.vRuntime);
932921
} else if (name.startsWith('chrome-extension')) {
933-
name = this.executionContextNamesByOrigin.get(name as Platform.DevToolsPath.UrlString) || name;
922+
name = this.entityMapper()?.entityForEvent(node.event)?.name || name;
934923
}
935924
return name;
936925
}
@@ -956,7 +945,7 @@ export class AggregatedTimelineTreeView extends TimelineTreeView {
956945
case AggregatedTimelineTreeView.GroupBy.Domain:
957946
case AggregatedTimelineTreeView.GroupBy.Subdomain:
958947
case AggregatedTimelineTreeView.GroupBy.ThirdParties: {
959-
const domainName = id ? this.beautifyDomainName(id) : undefined;
948+
const domainName = id ? this.beautifyDomainName(id, node) : undefined;
960949
return {name: domainName || unattributed, color, icon: undefined};
961950
}
962951

front_end/panels/timeline/utils/EntityMapper.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import type * as Platform from '../../../core/platform/platform.js';
56
import type * as Protocol from '../../../generated/protocol.js';
67
import * as Trace from '../../../models/trace/trace.js';
78

@@ -164,4 +165,16 @@ export class EntityMapper {
164165
// Update our CallFrame cache when we've got a resolved entity.
165166
this.#resolvedCallFrames.add(callFrame);
166167
}
168+
169+
// Update entities with proper Chrome Extension names.
170+
updateExtensionEntitiesWithName(executionContextNamesByOrigin: Map<Platform.DevToolsPath.UrlString, string>): void {
171+
const entities = Array.from(this.#entityMappings.eventsByEntity.keys());
172+
for (const [origin, name] of executionContextNamesByOrigin) {
173+
// In makeUpChromeExtensionEntity, the extension origin is set as the only domain for the entity.
174+
const entity = entities.find(e => e.domains[0] === origin);
175+
if (entity) {
176+
entity.name = entity.company = name;
177+
}
178+
}
179+
}
167180
}

front_end/panels/timeline/utils/SourceMapsResolver.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,16 @@ interface ResolvedCodeLocationData {
1919
}
2020
export class SourceMappingsUpdated extends Event {
2121
static readonly eventName = 'sourcemappingsupdated';
22-
2322
constructor() {
24-
super(SourceMappingsUpdated.eventName, {
25-
composed: true,
26-
bubbles: true,
27-
});
23+
super(SourceMappingsUpdated.eventName, {composed: true, bubbles: true});
2824
}
2925
}
3026

3127
// The code location key is created as a concatenation of its fields.
3228
export const resolvedCodeLocationDataNames = new Map<string, ResolvedCodeLocationData|null>();
3329

3430
export class SourceMapsResolver extends EventTarget {
31+
private executionContextNamesByOrigin = new Map<Platform.DevToolsPath.UrlString, string>();
3532
#parsedTrace: Trace.Handlers.Types.ParsedTrace;
3633
#entityMapper: EntityMapper.EntityMapper|null = null;
3734

@@ -141,6 +138,8 @@ export class SourceMapsResolver extends EventTarget {
141138
SDK.SourceMapManager.Events.SourceMapAttached, this.#onAttachedSourceMap, this);
142139
}
143140

141+
this.#updateExtensionNames();
142+
144143
// Although we have added listeners for SourceMapAttached events, we also
145144
// immediately try to resolve function names. This ensures we use any
146145
// sourcemaps that were attached before we bound our event listener.
@@ -231,4 +230,13 @@ export class SourceMapsResolver extends EventTarget {
231230
}
232231
return SDK.TargetManager.TargetManager.instance().primaryPageTarget();
233232
}
233+
234+
#updateExtensionNames(): void {
235+
for (const runtimeModel of SDK.TargetManager.TargetManager.instance().models(SDK.RuntimeModel.RuntimeModel)) {
236+
for (const context of runtimeModel.executionContexts()) {
237+
this.executionContextNamesByOrigin.set(context.origin, context.name);
238+
}
239+
}
240+
this.#entityMapper?.updateExtensionEntitiesWithName(this.executionContextNamesByOrigin);
241+
}
234242
}

0 commit comments

Comments
 (0)