• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
23 namespace perfetto {
24 namespace trace_processor {
ShellTransitionsTracker(TraceProcessorContext * context)25 ShellTransitionsTracker::ShellTransitionsTracker(TraceProcessorContext* context)
26     : context_(context) {}
27 
28 ShellTransitionsTracker::~ShellTransitionsTracker() = default;
29 
30 tables::WindowManagerShellTransitionsTable::Id
InternTransition(int32_t transition_id)31 ShellTransitionsTracker::InternTransition(int32_t transition_id) {
32   auto pos = transition_id_to_row_mapping_.find(transition_id);
33   if (pos != transition_id_to_row_mapping_.end()) {
34     return pos->second;
35   }
36 
37   auto* window_manager_shell_transitions_table =
38       context_->storage->mutable_window_manager_shell_transitions_table();
39 
40   tables::WindowManagerShellTransitionsTable::Row row;
41   row.transition_id = transition_id;
42   auto row_id = window_manager_shell_transitions_table->Insert(row).id;
43 
44   transition_id_to_row_mapping_.insert({transition_id, row_id});
45 
46   return row_id;
47 }
48 }  // namespace trace_processor
49 }  // namespace perfetto
50