3 Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
7 <link rel="import" href="/base.html">
12 * @fileoverview Base class for Windows ETW event parsers.
14 * The ETW trace event importer depends on subclasses of
15 * Parser to parse event data. Each subclass corresponds
16 * to a group of trace events; e.g. Thread and Process implements
17 * decoding of scheduling events. Parser subclasses must
18 * call Parser.registerSubtype to arrange to be instantiated
19 * and their constructor must register their event handlers with the
20 * importer. For example,
22 * var Parser = tracing.importer.etw.Parser;
24 * function ThreadParser(importer) {
25 * Parser.call(this, importer);
27 * importer.registerEventHandler(guid, kThreadStartOpcode,
28 * ThreadParser.prototype.decodeStart.bind(this));
29 * importer.registerEventHandler(guid, kThreadEndOpcode,
30 * ThreadParser.prototype.decodeEnd.bind(this));
33 * Parser.registerSubtype(ThreadParser);
35 * When a registered event is found, the associated event handler is invoked:
37 * decodeStart: function(header, decoder) {
42 * If the routine returns false the caller will generate an import error
43 * saying there was a problem parsing it. Handlers can also emit import
44 * messages using this.importer.model.importWarning. If this is done in lieu of
45 * the generic import error it may be desirable for the handler to return
49 tv.exportTo('tracing.importer.etw', function() {
50 var subtypeConstructors = [];
53 * Registers a subclass that will help parse Windows ETW events.
54 * The importer will call createParsers (below) before importing
55 * data so each subclass can register its handlers.
57 * @param {Function} subtypeConstructor The subtype's constructor function.
59 Parser.registerSubtype = function(subtypeConstructor) {
60 subtypeConstructors.push(subtypeConstructor);
63 Parser.getSubtypeConstructors = function() {
64 return subtypeConstructors;
68 * Parses Windows ETW events.
71 function Parser(importer) {
72 this.importer = importer;
73 this.model = importer.model;
77 __proto__: Object.prototype