// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SERVICES_TRACING_PUBLIC_CPP_PERFETTO_TRACE_PACKET_TOKENIZER_H_ #define SERVICES_TRACING_PUBLIC_CPP_PERFETTO_TRACE_PACKET_TOKENIZER_H_ #include <vector> #include "base/component_export.h" #include "third_party/abseil-cpp/absl/container/inlined_vector.h" #include "third_party/perfetto/include/perfetto/protozero/proto_utils.h" namespace perfetto { class TracePacket; } // namespace perfetto namespace tracing { // Converts between a raw stream of perfetto::TracePacket bytes and a tokenized // vector of delineated packets. // // The tracing service provides us with serialized proto bytes, while the // Perfetto consumer expects a vector of TracePackets (i.e., without the field // number and size header) without partial or truncated packets. To translate // between the two, we find the position of each TracePacket and construct a // vector pointing to the original data at the corresponding offsets. // // To make matters more complicated, mojo can split the data chunks // arbitrarily, including in the middle of trace packets. To work around // this, we tokenize as much data as we can and buffer any unprocessed bytes as // long as needed. class COMPONENT_EXPORT(TRACING_CPP) TracePacketTokenizer { … }; } // namespace tracing #endif // SERVICES_TRACING_PUBLIC_CPP_PERFETTO_TRACE_PACKET_TOKENIZER_H_