Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / importer / etw / parser.html
1 <!DOCTYPE html>
2 <!--
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.
6 -->
7 <link rel="import" href="/base.html">
8 <script>
9 'use strict';
10
11 /**
12  * @fileoverview Base class for Windows ETW event parsers.
13  *
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,
21  *
22  * var Parser = tracing.importer.etw.Parser;
23  *
24  * function ThreadParser(importer) {
25  *   Parser.call(this, importer);
26  *
27  *   importer.registerEventHandler(guid, kThreadStartOpcode,
28  *       ThreadParser.prototype.decodeStart.bind(this));
29  *   importer.registerEventHandler(guid, kThreadEndOpcode,
30  *       ThreadParser.prototype.decodeEnd.bind(this));
31  * }
32  *
33  * Parser.registerSubtype(ThreadParser);
34  *
35  * When a registered event is found, the associated event handler is invoked:
36  *
37  *   decodeStart: function(header, decoder) {
38  *     [...]
39  *     return true;
40  *   },
41  *
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
46  * true.
47  *
48  */
49 tv.exportTo('tracing.importer.etw', function() {
50   var subtypeConstructors = [];
51
52   /**
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.
56    *
57    * @param {Function} subtypeConstructor The subtype's constructor function.
58    */
59   Parser.registerSubtype = function(subtypeConstructor) {
60     subtypeConstructors.push(subtypeConstructor);
61   };
62
63   Parser.getSubtypeConstructors = function() {
64     return subtypeConstructors;
65   };
66
67   /**
68    * Parses Windows ETW events.
69    * @constructor
70    */
71   function Parser(importer) {
72     this.importer = importer;
73     this.model = importer.model;
74   }
75
76   Parser.prototype = {
77     __proto__: Object.prototype
78   };
79
80   return {
81     Parser: Parser
82   };
83 });
84 </script>