MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / parse

Method parse

front_end/models/trace/ModelImpl.ts:80–119  ·  view source on GitHub ↗

* Parses an array of trace events into a structured object containing all the * information parsed by the trace handlers. * You can `await` this function to pause execution until parsing is complete, * or instead rely on the `ModuleUpdateEvent` that is dispatched when the * parsing is fi

(traceEvents: readonly Types.Events.Event[], config: Types.Configuration.ParseOptions = {})

Source from the content-addressed store, hash-verified

78 * void this.traceModel.parse(events);
79 **/
80 async parse(traceEvents: readonly Types.Events.Event[], config: Types.Configuration.ParseOptions = {}):
81 Promise<void> {
82 if (config.showAllEvents === undefined) {
83 config.showAllEvents = this.#config.showAllEvents;
84 }
85
86 const metadata = config.metadata || {};
87 // During parsing, periodically update any listeners on each processors'
88 // progress (if they have any updates).
89 const onTraceUpdate = (event: Event): void => {
90 const {data} = event as TraceParseProgressEvent;
91 this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.PROGRESS_UPDATE, data}));
92 };
93
94 this.#processor.addEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);
95
96 // TODO(cjamcl): this.#processor.parse needs this to work. So it should either take it as input, or create it itself.
97 const syntheticEventsManager = Helpers.SyntheticEvents.SyntheticEventsManager.createAndActivate(traceEvents);
98
99 try {
100 // Wait for all outstanding promises before finishing the async execution,
101 // but perform all tasks in parallel.
102 await this.#processor.parse(traceEvents, config);
103 if (!this.#processor.data) {
104 throw new Error('processor did not parse trace');
105 }
106 const file = this.#storeAndCreateParsedTraceFile(
107 syntheticEventsManager, traceEvents, metadata, this.#processor.data, this.#processor.insights);
108 // We only push the file onto this.#traces here once we know it's valid
109 // and there's been no errors in the parsing.
110 this.#traces.push(file);
111 } catch (e) {
112 throw e;
113 } finally {
114 // All processors have finished parsing, no more updates are expected.
115 this.#processor.removeEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);
116 // Finally, update any listeners that all processors are 'done'.
117 this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.COMPLETE, data: 'done'}));
118 }
119 }
120
121 #storeAndCreateParsedTraceFile(
122 syntheticEventsManager: Helpers.SyntheticEvents.SyntheticEventsManager,

Callers 15

makeHttpRequestFunction · 0.45
AidaClient.test.tsFile · 0.45
#parseStreamChunkMethod · 0.45
completeCodeMethod · 0.45
deserializeUIStringFunction · 0.45
sendMethod · 0.45
onMessageMethod · 0.45
constructorMethod · 0.45
fakeDevToolsFrontendFunction · 0.45
getColorChannelValueMethod · 0.45

Calls 6

createAndActivateMethod · 0.80
dispatchEventMethod · 0.80
addEventListenerMethod · 0.65
removeEventListenerMethod · 0.65
pushMethod · 0.45

Tested by 5

fakeDevToolsFrontendFunction · 0.36
parseAndAssertNotNullFunction · 0.36
getInsightOrderFunction · 0.36
loadScriptFixtureFunction · 0.36