1 /*
2  * Copyright (C) 2019 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_FUCHSIA_PROVIDER_VIEW_H_
18 #define SRC_TRACE_PROCESSOR_FUCHSIA_PROVIDER_VIEW_H_
19 
20 #include "src/trace_processor/fuchsia_trace_utils.h"
21 #include "src/trace_processor/trace_storage.h"
22 
23 #include <vector>
24 
25 namespace perfetto {
26 namespace trace_processor {
27 
28 // Data from a trace provider that is necessary for interpreting a binary
29 // record. Namely, the entries of the string table and the thread table that are
30 // referenced by the record. This enables understanding the binary record after
31 // arbitrary reordering.
32 class FuchsiaProviderView {
33  public:
34   struct StringTableEntry {
35     uint32_t index;
36     StringId string_id;
37   };
38 
39   struct ThreadTableEntry {
40     uint32_t index;
41     fuchsia_trace_utils::ThreadInfo info;
42   };
43 
44   void InsertString(uint32_t, StringId);
45   StringId GetString(uint32_t);
46 
47   void InsertThread(uint32_t, fuchsia_trace_utils::ThreadInfo);
48   fuchsia_trace_utils::ThreadInfo GetThread(uint32_t);
49 
set_ticks_per_second(uint64_t ticks_per_second)50   void set_ticks_per_second(uint64_t ticks_per_second) {
51     ticks_per_second_ = ticks_per_second;
52   }
53 
get_ticks_per_second()54   uint64_t get_ticks_per_second() { return ticks_per_second_; }
55 
56  private:
57   std::vector<StringTableEntry> string_entries_;
58   std::vector<ThreadTableEntry> thread_entries_;
59 
60   uint64_t ticks_per_second_ = 1000000000;
61 };
62 
63 }  // namespace trace_processor
64 }  // namespace perfetto
65 
66 #endif  // SRC_TRACE_PROCESSOR_FUCHSIA_PROVIDER_VIEW_H_
67