• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 the V8 project 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.
4 
5 #ifndef V8_LIBPLATFORM_TRACING_TRACE_EVENT_LISTENER_H_
6 #define V8_LIBPLATFORM_TRACING_TRACE_EVENT_LISTENER_H_
7 
8 #include <vector>
9 
10 #include "libplatform/libplatform-export.h"
11 
12 namespace perfetto {
13 namespace protos {
14 class TracePacket;
15 }  // namespace protos
16 }  // namespace perfetto
17 
18 namespace v8 {
19 namespace platform {
20 namespace tracing {
21 
22 // A TraceEventListener is a simple interface that allows subclasses to listen
23 // to trace events. This interface is to hide the more complex interactions that
24 // the PerfettoConsumer class has to perform. Clients override ProcessPacket()
25 // to respond to trace events, e.g. to write them to a file as JSON or for
26 // testing purposes.
27 class V8_PLATFORM_EXPORT TraceEventListener {
28  public:
29   virtual ~TraceEventListener() = default;
30   virtual void ProcessPacket(const ::perfetto::protos::TracePacket& packet) = 0;
31 
32   void ParseFromArray(const std::vector<char>& array);
33 };
34 
35 }  // namespace tracing
36 }  // namespace platform
37 }  // namespace v8
38 
39 #endif  // V8_LIBPLATFORM_TRACING_TRACE_EVENT_LISTENER_H_
40