diff options
Diffstat (limited to 'deps/v8/src/libplatform/tracing/json-trace-event-listener.h')
-rw-r--r-- | deps/v8/src/libplatform/tracing/json-trace-event-listener.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/deps/v8/src/libplatform/tracing/json-trace-event-listener.h b/deps/v8/src/libplatform/tracing/json-trace-event-listener.h new file mode 100644 index 0000000000..fc4979f14c --- /dev/null +++ b/deps/v8/src/libplatform/tracing/json-trace-event-listener.h @@ -0,0 +1,45 @@ +// 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_JSON_TRACE_EVENT_LISTENER_H_ +#define V8_LIBPLATFORM_TRACING_JSON_TRACE_EVENT_LISTENER_H_ + +#include <ostream> + +#include "src/libplatform/tracing/trace-event-listener.h" + +namespace perfetto { +namespace protos { +class ChromeTraceEvent_Arg; +} // namespace protos +} // namespace perfetto + +namespace v8 { +namespace platform { +namespace tracing { + +// A listener that converts the proto trace data to JSON and writes it to a +// file. +class JSONTraceEventListener final : public TraceEventListener { + public: + explicit JSONTraceEventListener(std::ostream* stream); + ~JSONTraceEventListener() override; + + private: + void ProcessPacket( + const ::perfetto::protos::ChromeTracePacket& packet) override; + + // Internal implementation + void AppendJSONString(const char* str); + void AppendArgValue(const ::perfetto::protos::ChromeTraceEvent_Arg& arg); + + std::ostream* stream_; + bool append_comma_ = false; +}; + +} // namespace tracing +} // namespace platform +} // namespace v8 + +#endif // V8_LIBPLATFORM_TRACING_JSON_TRACE_EVENT_LISTENER_H_ |