1 /* 2 * Copyright (C) 2023 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 "shell_transitions_tracker.h" 18 #include "perfetto/ext/base/crash_keys.h" 19 #include "src/trace_processor/importers/common/process_tracker.h" 20 #include "src/trace_processor/storage/metadata.h" 21 #include "src/trace_processor/types/trace_processor_context.h" 22 #include "src/trace_processor/util/winscope_proto_mapping.h" 23 24 namespace perfetto { 25 namespace trace_processor { ShellTransitionsTracker(TraceProcessorContext * context)26ShellTransitionsTracker::ShellTransitionsTracker(TraceProcessorContext* context) 27 : context_(context) {} 28 29 ShellTransitionsTracker::~ShellTransitionsTracker() = default; 30 31 tables::WindowManagerShellTransitionsTable::Id InternTransition(int32_t transition_id)32ShellTransitionsTracker::InternTransition(int32_t transition_id) { 33 auto pos = transition_id_to_row_mapping_.find(transition_id); 34 if (pos != transition_id_to_row_mapping_.end()) { 35 return pos->second; 36 } 37 38 auto* window_manager_shell_transitions_table = 39 context_->storage->mutable_window_manager_shell_transitions_table(); 40 41 tables::WindowManagerShellTransitionsTable::Row row; 42 row.transition_id = transition_id; 43 auto row_id = window_manager_shell_transitions_table->Insert(row).id; 44 45 transition_id_to_row_mapping_.insert({transition_id, row_id}); 46 47 return row_id; 48 } 49 } // namespace trace_processor 50 } // namespace perfetto 51