1 /*
2  * Copyright (C) 2021 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 #include "src/trace_processor/importers/proto/chrome_system_probes_module.h"
18 #include "perfetto/base/build_config.h"
19 #include "src/trace_processor/importers/proto/chrome_system_probes_parser.h"
20 #include "src/trace_processor/timestamped_trace_piece.h"
21 
22 #include "protos/perfetto/trace/trace_packet.pbzero.h"
23 
24 namespace perfetto {
25 namespace trace_processor {
26 
27 using perfetto::protos::pbzero::TracePacket;
28 
ChromeSystemProbesModule(TraceProcessorContext * context)29 ChromeSystemProbesModule::ChromeSystemProbesModule(
30     TraceProcessorContext* context)
31     : parser_(context) {
32   RegisterForField(TracePacket::kProcessStatsFieldNumber, context);
33 }
34 
ParsePacket(const TracePacket::Decoder & decoder,const TimestampedTracePiece & ttp,uint32_t field_id)35 void ChromeSystemProbesModule::ParsePacket(const TracePacket::Decoder& decoder,
36                                            const TimestampedTracePiece& ttp,
37                                            uint32_t field_id) {
38   switch (field_id) {
39     case TracePacket::kProcessStatsFieldNumber:
40       parser_.ParseProcessStats(ttp.timestamp, decoder.process_stats());
41       return;
42   }
43 }
44 
45 }  // namespace trace_processor
46 }  // namespace perfetto
47