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

Unified Diff: tracing/tracing/extras/importer/trace_event_importer.html

Issue 2008073002: Refactor how TraceEventImporter identifies metadata fields (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Fixes comment Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/extras/importer/trace_event_importer.html
diff --git a/tracing/tracing/extras/importer/trace_event_importer.html b/tracing/tracing/extras/importer/trace_event_importer.html
index a73dc467e73fc6abee756af952fa0ea252a01c2e..6fa58b30364440bf00c2804e493e421f1b5ed7e6 100644
--- a/tracing/tracing/extras/importer/trace_event_importer.html
+++ b/tracing/tracing/extras/importer/trace_event_importer.html
@@ -102,6 +102,25 @@ tr.exportTo('tr.e.importer', function() {
}
];
+ // The list of fields on the trace that are known to contain subtraces.
+ var SUBTRACE_FIELDS = new Set([
+ 'powerTraceAsString',
+ 'systemTraceEvents',
+ ]);
+
+ // The complete list of fields on the trace that should not be treated as
+ // trace metadata.
+ var NON_METADATA_FIELDS = new Set([
+ 'samples',
+ 'stackFrames',
+ 'traceAnnotations',
+ 'traceEvents'
+ ]);
+ // TODO(charliea): Replace this with the spread (...) operator in literal
+ // above once v8 is updated to a sufficiently recent version (>M45).
+ for (var subtraceField in SUBTRACE_FIELDS)
+ NON_METADATA_FIELDS.add(subtraceField);
+
function TraceEventImporter(model, eventData) {
this.importPriority = 1;
this.model_ = model;
@@ -163,10 +182,9 @@ tr.exportTo('tr.e.importer', function() {
this.events_ = this.events_.traceEvents;
// Some trace authors store subtraces as specific properties of the trace.
- if (container.powerTraceAsString)
- this.subtraces_.push(container.powerTraceAsString);
- if (container.systemTraceEvents)
- this.subtraces_.push(container.systemTraceEvents);
+ for (var subtraceField of SUBTRACE_FIELDS)
+ if (container[subtraceField])
+ this.subtraces_.push(container[subtraceField]);
// Sampling data.
this.sampleEvents_ = container.samples;
@@ -182,20 +200,13 @@ tr.exportTo('tr.e.importer', function() {
this.model_.intrinsicTimeUnit = unit;
}
- var knownFieldNames = {
- powerTraceAsString: true,
- samples: true,
- stackFrames: true,
- systemTraceEvents: true,
- traceAnnotations: true,
- traceEvents: true
- };
// Any other fields in the container should be treated as metadata.
for (var fieldName in container) {
- if (fieldName in knownFieldNames)
+ if (NON_METADATA_FIELDS.has(fieldName))
continue;
- this.model_.metadata.push({name: fieldName,
- value: container[fieldName]});
+
+ this.model_.metadata.push(
+ { name: fieldName, value: container[fieldName] });
if (fieldName === 'metadata') {
var metadata = container[fieldName];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698