1 // Copyright (c) 2014 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.
8 * @fileoverview Base class for Windows ETW event parsers.
10 * The ETW trace event importer depends on subclasses of
11 * Parser to parse event data. Each subclass corresponds
12 * to a group of trace events; e.g. Thread and Process implements
13 * decoding of scheduling events. Parser subclasses must
14 * call Parser.registerSubtype to arrange to be instantiated
15 * and their constructor must register their event handlers with the
16 * importer. For example,
18 * var Parser = tracing.importer.etw.Parser;
20 * function ThreadParser(importer) {
21 * Parser.call(this, importer);
23 * importer.registerEventHandler(guid, kThreadStartOpcode,
24 * ThreadParser.prototype.decodeStart.bind(this));
25 * importer.registerEventHandler(guid, kThreadEndOpcode,
26 * ThreadParser.prototype.decodeEnd.bind(this));
29 * Parser.registerSubtype(ThreadParser);
31 * When a registered event is found, the associated event handler is invoked:
33 * decodeStart: function(header, decoder) {
38 * If the routine returns false the caller will generate an import error
39 * saying there was a problem parsing it. Handlers can also emit import
40 * messages using this.importer.model.importWarning. If this is done in lieu of
41 * the generic import error it may be desirable for the handler to return
45 tvcm.exportTo('tracing.importer.etw', function() {
47 var subtypeConstructors = [];
50 * Registers a subclass that will help parse Windows ETW events.
51 * The importer will call createParsers (below) before importing
52 * data so each subclass can register its handlers.
54 * @param {Function} subtypeConstructor The subtype's constructor function.
56 Parser.registerSubtype = function(subtypeConstructor) {
57 subtypeConstructors.push(subtypeConstructor);
60 Parser.getSubtypeConstructors = function() {
61 return subtypeConstructors;
65 * Parses Windows ETW events.
68 function Parser(importer) {
69 this.importer = importer;
70 this.model = importer.model;
74 __proto__: Object.prototype