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_TOKENIZER_H_
18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_TOKENIZER_H_
19 
20 #include <stdint.h>
21 
22 #include "src/trace_processor/importers/proto/proto_importer_module.h"
23 #include "src/trace_processor/storage/trace_storage.h"
24 
25 namespace perfetto {
26 
27 namespace protos {
28 namespace pbzero {
29 class ChromeThreadDescriptor_Decoder;
30 class ProcessDescriptor_Decoder;
31 class ThreadDescriptor_Decoder;
32 class TracePacket_Decoder;
33 }  // namespace pbzero
34 }  // namespace protos
35 
36 namespace trace_processor {
37 
38 class PacketSequenceState;
39 class TraceProcessorContext;
40 class TraceBlobView;
41 
42 class TrackEventTokenizer {
43  public:
44   explicit TrackEventTokenizer(TraceProcessorContext* context);
45 
46   ModuleResult TokenizeTrackDescriptorPacket(
47       PacketSequenceState* state,
48       const protos::pbzero::TracePacket_Decoder&,
49       int64_t packet_timestamp);
50   ModuleResult TokenizeThreadDescriptorPacket(
51       PacketSequenceState* state,
52       const protos::pbzero::TracePacket_Decoder&);
53   void TokenizeTrackEventPacket(PacketSequenceState* state,
54                                 const protos::pbzero::TracePacket_Decoder&,
55                                 TraceBlobView* packet,
56                                 int64_t packet_timestamp);
57 
58  private:
59   void TokenizeThreadDescriptor(
60       PacketSequenceState* state,
61       const protos::pbzero::ThreadDescriptor_Decoder&);
62 
63   TraceProcessorContext* context_;
64 };
65 
66 }  // namespace trace_processor
67 }  // namespace perfetto
68 
69 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_TOKENIZER_H_
70