/* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SRC_TRACE_REDACTION_TRACE_REDACTION_FRAMEWORK_H_ #define SRC_TRACE_REDACTION_TRACE_REDACTION_FRAMEWORK_H_ #include <bitset> #include <cstdint> #include <memory> #include <optional> #include <string> #include <unordered_set> #include <vector> #include "perfetto/base/flat_set.h" #include "perfetto/base/status.h" #include "src/trace_redaction/frame_cookie.h" #include "src/trace_redaction/process_thread_timeline.h" #include "protos/perfetto/trace/trace_packet.pbzero.h" namespace perfetto::trace_redaction { // Multiple packages can share the same name. This is common when a device has // multiple users. When this happens, each instance shares the 5 least // significant digits. constexpr uint64_t NormalizeUid(uint64_t uid) { … } class SystemInfo { … }; class SyntheticProcess { … }; // Primitives should be stateless. All state should be stored in the context. // Primitives should depend on data in the context, not the origin of the data. // This allows primitives to be swapped out or work together to populate data // needed by another primitive. // // For this to work, primitives are divided into three types: // // `CollectPrimitive` : Reads data from trace packets and saves low-level data // in the context. // // `BuildPrimitive` : Reads low-level data from the context and builds // high-level (read-optimized) data structures. // // `TransformPrimitive`: Reads high-level data from the context and modifies // trace packets. class Context { … }; // Extracts low-level data from the trace and writes it into the context. The // life cycle of a collect primitive is: // // primitive.Begin(&context); // // for (auto& packet : packets) { // primitive.Collect(packet, &context); // } // // primitive.End(&context); class CollectPrimitive { … }; // Responsible for converting low-level data from the context and storing it in // the context (high-level data). class BuildPrimitive { … }; // Responsible for modifying trace packets using data from the context. class TransformPrimitive { … }; } // namespace perfetto::trace_redaction #endif // SRC_TRACE_REDACTION_TRACE_REDACTION_FRAMEWORK_H_