1 /* 2 * Copyright (C) 2018 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_JSON_JSON_TRACE_PARSER_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_JSON_JSON_TRACE_PARSER_H_ 19 20 #include <stdint.h> 21 22 #include <memory> 23 #include <tuple> 24 25 #include "src/trace_processor/importers/common/trace_parser.h" 26 #include "src/trace_processor/importers/systrace/systrace_line_parser.h" 27 #include "src/trace_processor/timestamped_trace_piece.h" 28 29 namespace Json { 30 class Value; 31 } 32 33 namespace perfetto { 34 namespace trace_processor { 35 36 class TraceProcessorContext; 37 38 // Parses legacy chrome JSON traces. The support for now is extremely rough 39 // and supports only explicit TRACE_EVENT_BEGIN/END events. 40 class JsonTraceParser : public TraceParser { 41 public: 42 explicit JsonTraceParser(TraceProcessorContext*); 43 ~JsonTraceParser() override; 44 45 // TraceParser implementation. 46 void ParseTracePacket(int64_t timestamp, TimestampedTracePiece) override; 47 void ParseFtracePacket(uint32_t, int64_t, TimestampedTracePiece) override; 48 49 private: 50 TraceProcessorContext* const context_; 51 SystraceLineParser systrace_line_parser_; 52 53 void MaybeAddFlow(TrackId track_id, const Json::Value& event); 54 }; 55 56 } // namespace trace_processor 57 } // namespace perfetto 58 59 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_JSON_JSON_TRACE_PARSER_H_ 60