blob: d13332871fa63386fb71b4890872c6d6d67b2e77 [file] [log] [blame]
// 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.
#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 {
explicit JSONTraceEventListener(std::ostream* stream);
~JSONTraceEventListener() override;
void ProcessPacket(const ::perfetto::protos::TracePacket& 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