3 Copyright (c) 2012 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.
8 <link rel="import" href="/tracing/importer/linux_perf/parser.html">
14 * @fileoverview Parses gesture events in the Linux event trace format.
16 tv.exportTo('tracing.importer.linux_perf', function() {
18 var Parser = tracing.importer.linux_perf.Parser;
21 * Parses trace events generated by gesture library for touchpad.
24 function GestureParser(importer) {
25 Parser.call(this, importer);
26 importer.registerEventHandler('tracing_mark_write:log',
27 GestureParser.prototype.logEvent.bind(this));
28 importer.registerEventHandler('tracing_mark_write:SyncInterpret',
29 GestureParser.prototype.syncEvent.bind(this));
30 importer.registerEventHandler('tracing_mark_write:HandleTimer',
31 GestureParser.prototype.timerEvent.bind(this));
34 GestureParser.prototype = {
35 __proto__: Parser.prototype,
38 * Parse events generate by gesture library.
39 * gestureOpenSlice and gestureCloseSlice are two common
40 * functions to store the begin time and end time for all
41 * events in gesture library
43 gestureOpenSlice: function(title, ts, opt_args) {
44 var thread = this.importer.getOrCreatePseudoThread('gesture').thread;
45 thread.sliceGroup.beginSlice(
46 'touchpad_gesture', title, ts, opt_args);
49 gestureCloseSlice: function(title, ts) {
50 var thread = this.importer.getOrCreatePseudoThread('gesture').thread;
51 if (thread.sliceGroup.openSliceCount) {
52 var slice = thread.sliceGroup.mostRecentlyOpenedPartialSlice;
53 if (slice.title != title) {
54 this.importer.model.importWarning({
55 type: 'title_match_error',
56 message: 'Titles do not match. Title is ' +
57 slice.title + ' in openSlice, and is ' +
58 title + ' in endSlice'
61 thread.sliceGroup.endSlice(ts);
67 * For log events, events will come in pairs with a tag log:
69 * tracing_mark_write: log: start: TimerLogOutputs
70 * tracing_mark_write: log: end: TimerLogOutputs
71 * which represent the start and the end time of certain log behavior
72 * Take these logs above for example, they are the start and end time
73 * of logging Output for HandleTimer function
75 logEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
77 /^\s*(\w+):\s*(\w+)$/.exec(eventBase.details);
78 switch (innerEvent[1]) {
80 this.gestureOpenSlice('GestureLog', ts, {name: innerEvent[2]});
83 this.gestureCloseSlice('GestureLog', ts);
89 * For SyncInterpret events, events will come in pairs with
90 * a tag SyncInterpret:
92 * tracing_mark_write: SyncInterpret: start: ClickWiggleFilterInterpreter
93 * tracing_mark_write: SyncInterpret: end: ClickWiggleFilterInterpreter
94 * which represent the start and the end time of SyncInterpret function
95 * inside the certain interpreter in the gesture library.
96 * Take the logs above for example, they are the start and end time
97 * of the SyncInterpret function inside ClickWiggleFilterInterpreter
99 syncEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
100 var innerEvent = /^\s*(\w+):\s*(\w+)$/.exec(eventBase.details);
101 switch (innerEvent[1]) {
103 this.gestureOpenSlice('SyncInterpret', ts,
104 {interpreter: innerEvent[2]});
107 this.gestureCloseSlice('SyncInterpret', ts);
113 * For HandleTimer events, events will come in pairs with
116 * tracing_mark_write: HandleTimer: start: LookaheadFilterInterpreter
117 * tracing_mark_write: HandleTimer: end: LookaheadFilterInterpreter
118 * which represent the start and the end time of HandleTimer function
119 * inside the certain interpreter in the gesture library.
120 * Take the logs above for example, they are the start and end time
121 * of the HandleTimer function inside LookaheadFilterInterpreter
123 timerEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
124 var innerEvent = /^\s*(\w+):\s*(\w+)$/.exec(eventBase.details);
125 switch (innerEvent[1]) {
127 this.gestureOpenSlice('HandleTimer', ts,
128 {interpreter: innerEvent[2]});
131 this.gestureCloseSlice('HandleTimer', ts);
137 Parser.registerSubtype(GestureParser);
140 GestureParser: GestureParser