1 /* 2 * Copyright (C) 2022 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_PACKET_ANALYZER_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PACKET_ANALYZER_H_ 19 20 #include <utility> 21 #include <vector> 22 23 #include "perfetto/trace_processor/trace_blob_view.h" 24 #include "src/trace_processor/storage/trace_storage.h" 25 #include "src/trace_processor/types/destructible.h" 26 #include "src/trace_processor/types/trace_processor_context.h" 27 28 namespace perfetto { 29 namespace trace_processor { 30 31 // Interface for processing packet information. 32 class PacketAnalyzer : public Destructible { 33 public: 34 using SampleAnnotation = std::vector<std::pair<StringId, StringId>>; 35 36 PacketAnalyzer() = default; 37 ~PacketAnalyzer() override; 38 Get(TraceProcessorContext * context)39 static PacketAnalyzer* Get(TraceProcessorContext* context) { 40 if (!context->content_analyzer) 41 return nullptr; 42 return static_cast<PacketAnalyzer*>(context->content_analyzer.get()); 43 } 44 45 virtual void ProcessPacket(const TraceBlobView& packet, 46 const SampleAnnotation& packet_annotation) = 0; 47 48 virtual void NotifyEndOfFile() = 0; 49 }; 50 51 } // namespace trace_processor 52 } // namespace perfetto 53 54 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PACKET_ANALYZER_H_ 55