1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_MODULE_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_MODULE_H_ 19 20 #include <cstdint> 21 #include <memory> 22 23 #include "perfetto/trace_processor/ref_counted.h" 24 #include "src/trace_processor/importers/common/parser_types.h" 25 #include "src/trace_processor/importers/proto/packet_sequence_state_generation.h" 26 #include "src/trace_processor/importers/proto/proto_importer_module.h" 27 #include "src/trace_processor/importers/proto/track_event_parser.h" 28 #include "src/trace_processor/importers/proto/track_event_tokenizer.h" 29 30 #include "protos/perfetto/trace/trace_packet.pbzero.h" 31 32 namespace perfetto::trace_processor { 33 34 class TrackEventModule : public ProtoImporterModule { 35 public: 36 explicit TrackEventModule(TraceProcessorContext* context); 37 38 ~TrackEventModule() override; 39 40 ModuleResult TokenizePacket( 41 const protos::pbzero::TracePacket::Decoder& decoder, 42 TraceBlobView* packet, 43 int64_t packet_timestamp, 44 RefPtr<PacketSequenceStateGeneration> state, 45 uint32_t field_id) override; 46 47 void ParseTracePacketData(const protos::pbzero::TracePacket::Decoder& decoder, 48 int64_t ts, 49 const TracePacketData& data, 50 uint32_t field_id) override; 51 52 void OnIncrementalStateCleared(uint32_t) override; 53 54 void OnFirstPacketOnSequence(uint32_t) override; 55 56 void ParseTrackEventData(const protos::pbzero::TracePacket::Decoder& decoder, 57 int64_t ts, 58 const TrackEventData& data); 59 60 void NotifyEndOfFile() override; 61 62 private: 63 std::unique_ptr<TrackEventTracker> track_event_tracker_; 64 TrackEventTokenizer tokenizer_; 65 TrackEventParser parser_; 66 }; 67 68 } // namespace perfetto::trace_processor 69 70 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_MODULE_H_ 71