1 // Copyright (c) 2012 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 Parses gesture events in the Linux event trace format.
10 base.require('tracing.importer.linux_perf.parser');
11 base.exportTo('tracing.importer.linux_perf', function() {
13 var Parser = tracing.importer.linux_perf.Parser;
16 * Parses trace events generated by gesture library for touchpad.
19 function GestureParser(importer) {
20 Parser.call(this, importer);
21 importer.registerEventHandler('tracing_mark_write:log',
22 GestureParser.prototype.logEvent.bind(this));
23 importer.registerEventHandler('tracing_mark_write:SyncInterpret',
24 GestureParser.prototype.syncEvent.bind(this));
25 importer.registerEventHandler('tracing_mark_write:HandleTimer',
26 GestureParser.prototype.timerEvent.bind(this));
29 GestureParser.prototype = {
30 __proto__: Parser.prototype,
33 * Parse events generate by gesture library.
34 * gestureOpenSlice and gestureCloseSlice are two common
35 * functions to store the begin time and end time for all
36 * events in gesture library
38 gestureOpenSlice: function(title, ts, opt_args) {
39 var thread = this.importer.getOrCreatePseudoThread('gesture').thread;
40 thread.sliceGroup.beginSlice(
41 'touchpad_gesture', title, ts, opt_args);
44 gestureCloseSlice: function(title, ts) {
45 var thread = this.importer.getOrCreatePseudoThread('gesture').thread;
46 if (thread.sliceGroup.openSliceCount) {
47 var slice = thread.sliceGroup.mostRecentlyOpenedPartialSlice;
48 if (slice.title != title) {
49 this.importer.model.importWarning({
50 type: 'title_match_error',
51 message: 'Titles do not match. Title is ' +
52 slice.title + ' in openSlice, and is ' +
53 title + ' in endSlice'
56 thread.sliceGroup.endSlice(ts);
62 * For log events, events will come in pairs with a tag log:
64 * tracing_mark_write: log: start: TimerLogOutputs
65 * tracing_mark_write: log: end: TimerLogOutputs
66 * which represent the start and the end time of certain log behavior
67 * Take these logs above for example, they are the start and end time
68 * of logging Output for HandleTimer function
70 logEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
72 /^\s*(\w+):\s*(\w+)$/.exec(eventBase.details);
73 switch (innerEvent[1]) {
75 this.gestureOpenSlice('GestureLog', ts, {name: innerEvent[2]});
78 this.gestureCloseSlice('GestureLog', ts);
84 * For SyncInterpret events, events will come in pairs with
85 * a tag SyncInterpret:
87 * tracing_mark_write: SyncInterpret: start: ClickWiggleFilterInterpreter
88 * tracing_mark_write: SyncInterpret: end: ClickWiggleFilterInterpreter
89 * which represent the start and the end time of SyncInterpret function
90 * inside the certain interpreter in the gesture library.
91 * Take the logs above for example, they are the start and end time
92 * of the SyncInterpret function inside ClickWiggleFilterInterpreter
94 syncEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
95 var innerEvent = /^\s*(\w+):\s*(\w+)$/.exec(eventBase.details);
96 switch (innerEvent[1]) {
98 this.gestureOpenSlice('SyncInterpret', ts,
99 {interpreter: innerEvent[2]});
102 this.gestureCloseSlice('SyncInterpret', ts);
108 * For HandleTimer events, events will come in pairs with
111 * tracing_mark_write: HandleTimer: start: LookaheadFilterInterpreter
112 * tracing_mark_write: HandleTimer: end: LookaheadFilterInterpreter
113 * which represent the start and the end time of HandleTimer function
114 * inside the certain interpreter in the gesture library.
115 * Take the logs above for example, they are the start and end time
116 * of the HandleTimer function inside LookaheadFilterInterpreter
118 timerEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
119 var innerEvent = /^\s*(\w+):\s*(\w+)$/.exec(eventBase.details);
120 switch (innerEvent[1]) {
122 this.gestureOpenSlice('HandleTimer', ts,
123 {interpreter: innerEvent[2]});
126 this.gestureCloseSlice('HandleTimer', ts);
132 Parser.registerSubtype(GestureParser);
135 GestureParser: GestureParser