• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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_DYNAMIC_CONNECTED_FLOW_GENERATOR_H_
18 #define SRC_TRACE_PROCESSOR_DYNAMIC_CONNECTED_FLOW_GENERATOR_H_
19 
20 #include "src/trace_processor/sqlite/db_sqlite_table.h"
21 
22 #include "src/trace_processor/storage/trace_storage.h"
23 
24 #include <queue>
25 #include <set>
26 
27 namespace perfetto {
28 namespace trace_processor {
29 
30 class TraceProcessorContext;
31 
32 // Implementation of tables:
33 // - DIRECTLY_CONNECTED_FLOW
34 // - PRECEDING_FLOW
35 // - FOLLOWING_FLOW
36 class ConnectedFlowGenerator : public DbSqliteTable::DynamicTableGenerator {
37  public:
38   enum class Mode {
39     // Directly connected slices through the same flow ID given by the trace
40     // writer.
41     kDirectlyConnectedFlow,
42     // Flow events which can be reached from the given slice by going over
43     // incoming flow events or to parent slices.
44     kPrecedingFlow,
45     // Flow events which can be reached from the given slice by going over
46     // outgoing flow events or to child slices.
47     kFollowingFlow,
48   };
49 
50   ConnectedFlowGenerator(Mode mode, TraceProcessorContext* context);
51   ~ConnectedFlowGenerator() override;
52 
53   Table::Schema CreateSchema() override;
54   std::string TableName() override;
55   uint32_t EstimateRowCount() override;
56   util::Status ValidateConstraints(const QueryConstraints&) override;
57   std::unique_ptr<Table> ComputeTable(const std::vector<Constraint>& cs,
58                                       const std::vector<Order>& ob) override;
59 
60  private:
61   Mode mode_;
62   TraceProcessorContext* context_ = nullptr;
63 };
64 
65 }  // namespace trace_processor
66 }  // namespace perfetto
67 
68 #endif  // SRC_TRACE_PROCESSOR_DYNAMIC_CONNECTED_FLOW_GENERATOR_H_
69