• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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_ANDROID_KERNEL_WAKELOCKS_STATE_H_
18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_ANDROID_KERNEL_WAKELOCKS_STATE_H_
19 
20 #include <cstdint>
21 #include <string>
22 
23 #include "perfetto/ext/base/flat_hash_map.h"
24 #include "src/trace_processor/importers/proto/packet_sequence_state_generation.h"
25 
26 #include "protos/perfetto/trace/android/kernel_wakelock_data.pbzero.h"
27 #include "protos/perfetto/trace/trace_packet.pbzero.h"
28 #include "src/trace_processor/types/trace_processor_context.h"
29 
30 namespace perfetto::trace_processor {
31 
32 struct AndroidKernelWakelockState : PacketSequenceStateGeneration::CustomState {
33   struct Metadata {
34     std::string name;
35     protos::pbzero::KernelWakelockData::Wakelock::Type type;
36   };
37 
38   struct LastValue {
39     uint64_t value;
40     protos::pbzero::KernelWakelockData::Wakelock::Type type;
41   };
42 
43   explicit AndroidKernelWakelockState(TraceProcessorContext*);
44   ~AndroidKernelWakelockState() override;
45 
46   base::FlatHashMap<uint32_t, Metadata> wakelocks;
47   base::FlatHashMap<std::string, LastValue> wakelock_last_values;
48 };
49 
50 }  // namespace perfetto::trace_processor
51 
52 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_ANDROID_KERNEL_WAKELOCKS_STATE_H_
53