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_IMPL_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_JSON_JSON_TRACE_PARSER_IMPL_H_ 19 20 #include <cstdint> 21 #include <string> 22 23 #include "src/trace_processor/importers/common/trace_parser.h" 24 #include "src/trace_processor/importers/systrace/systrace_line.h" 25 #include "src/trace_processor/importers/systrace/systrace_line_parser.h" 26 #include "src/trace_processor/storage/trace_storage.h" 27 28 namespace Json { 29 class Value; 30 } 31 32 namespace perfetto::trace_processor { 33 34 class TraceProcessorContext; 35 36 // Parses legacy chrome JSON traces. The support for now is extremely rough 37 // and supports only explicit TRACE_EVENT_BEGIN/END events. 38 class JsonTraceParserImpl : public JsonTraceParser { 39 public: 40 explicit JsonTraceParserImpl(TraceProcessorContext*); 41 ~JsonTraceParserImpl() override; 42 43 // TraceParser implementation. 44 void ParseJsonPacket(int64_t, std::string) override; 45 void ParseSystraceLine(int64_t, SystraceLine) override; 46 void ParseLegacyV8ProfileEvent(int64_t, LegacyV8CpuProfileEvent) override; 47 48 private: 49 TraceProcessorContext* const context_; 50 SystraceLineParser systrace_line_parser_; 51 52 void MaybeAddFlow(TrackId track_id, const Json::Value& event); 53 }; 54 55 } // namespace perfetto::trace_processor 56 57 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_JSON_JSON_TRACE_PARSER_IMPL_H_ 58