summaryrefslogtreecommitdiff
path: root/deps/v8/src/libplatform/tracing/trace-event-listener.h
blob: 6a535c79c52bbadadd32e455b96ff413b65d3879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_LIBPLATFORM_TRACING_TRACE_EVENT_LISTENER_H_
#define V8_LIBPLATFORM_TRACING_TRACE_EVENT_LISTENER_H_

#include <vector>

namespace perfetto {
namespace protos {
class TracePacket;
}  // namespace protos
}  // namespace perfetto

namespace v8 {
namespace platform {
namespace tracing {

// A TraceEventListener is a simple interface that allows subclasses to listen
// to trace events. This interface is to hide the more complex interactions that
// the PerfettoConsumer class has to perform. Clients override ProcessPacket()
// to respond to trace events, e.g. to write them to a file as JSON or for
// testing purposes.
class TraceEventListener {
 public:
  virtual ~TraceEventListener() = default;
  virtual void ProcessPacket(const ::perfetto::protos::TracePacket& packet) = 0;

  void ParseFromArray(const std::vector<char>& array);
};

}  // namespace tracing
}  // namespace platform
}  // namespace v8

#endif  // V8_LIBPLATFORM_TRACING_TRACE_EVENT_LISTENER_H_