// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * @fileoverview Base class for linux perf event parsers.
 *
 * The linux perf trace event importer depends on subclasses of
 * LinuxPerfParser to parse event data.  Each subclass corresponds
 * to a group of trace events; e.g. LinuxPerfSchedParser implements
 * parsing of sched:* kernel trace events.  Parser subclasses must
 * call LinuxPerfParser.registerSubtype to arrange to be instantiated
 * and their constructor must register their event handlers with the
 * importer.  For example,
 *
 * var LinuxPerfParser = tracing.LinuxPerfParser;
 *
 * function LinuxPerfWorkqueueParser(importer) {
 *   LinuxPerfParser.call(this, importer);
 *
 *   importer.registerEventHandler('workqueue_execute_start',
 *       LinuxPerfWorkqueueParser.prototype.executeStartEvent.bind(this));
 *   importer.registerEventHandler('workqueue_execute_end',
 *       LinuxPerfWorkqueueParser.prototype.executeEndEvent.bind(this));
 * }
 *
 * LinuxPerfParser.registerSubtype(LinuxPerfWorkqueueParser);
 *
 * When a registered event name is found in the data stream the associated
 * event handler is invoked:
 *
 *   executeStartEvent: function(eventName, cpuNumber, ts, eventBase)
 *
 * If the routine returns false the caller will generate an import error
 * saying there was a problem parsing it.  Handlers can also emit import
 * messages using this.importer.importError.  If this is done in lieu of
 * the generic import error it may be desirable for the handler to return
 * true.
 *
 * Trace events generated by writing to the trace_marker file are expected
 * to have a leading text marker followed by a ':'; e.g. the trace clock
 * synchronization event is:
 *
 *  tracing_mark_write: trace_event_clock_sync: parent_ts=0
 *
 * To register an event handler for these events, prepend the marker with
 * 'tracing_mark_write:'; e.g.
 *
 *    this.registerEventHandler('tracing_mark_write:trace_event_clock_sync',
 *
 * All subclasses should depend on linux_perf_parser, e.g.
 *
 * base.defineModule('linux_perf_workqueue_parser')
 *   .dependsOn('linux_perf_parser')
 *   .exportsTo('tracing', function()
 *
 * and be listed in the dependsOn of LinuxPerfImporter.  Beware that after
 * adding a new subclass you must run build/generate_about_tracing_contents.py
 * to regenerate about_tracing.*.
 */
base.exportTo('tracing', function() {

  var subtypeConstructors = [];

  /**
   * Registers a subclass that will help parse linux perf events.
   * The importer will call createParsers (below) before importing
   * data so each subclass can register its handlers.
   *
   * @param {Function} subtypeConstructor The subtype's constructor function.
   */
  LinuxPerfParser.registerSubtype = function(subtypeConstructor) {
    subtypeConstructors.push(subtypeConstructor);
  };

  LinuxPerfParser.getSubtypeConstructors = function() {
    return subtypeConstructors;
  };

  /**
   * Parses linux perf events.
   * @constructor
   */
  function LinuxPerfParser(importer) {
    this.importer = importer;
  }

  LinuxPerfParser.prototype = {
    __proto__: Object.prototype
  };

  return {
    LinuxPerfParser: LinuxPerfParser
  };

});
