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_TRACED_PROBES_SYSTEM_INFO_SYSTEM_INFO_DATA_SOURCE_H_
18 #define SRC_TRACED_PROBES_SYSTEM_INFO_SYSTEM_INFO_DATA_SOURCE_H_
19 
20 #include <memory>
21 
22 #include "perfetto/ext/tracing/core/trace_writer.h"
23 #include "src/traced/probes/common/cpu_freq_info.h"
24 #include "src/traced/probes/probes_data_source.h"
25 
26 namespace perfetto {
27 
28 class SystemInfoDataSource : public ProbesDataSource {
29  public:
30   static const ProbesDataSource::Descriptor descriptor;
31 
32   SystemInfoDataSource(TracingSessionID,
33                        std::unique_ptr<TraceWriter> writer,
34                        std::unique_ptr<CpuFreqInfo> cpu_freq_info);
35 
36   // ProbesDataSource implementation.
37   void Start() override;
38   void Flush(FlushRequestID, std::function<void()> callback) override;
39 
40   // Virtual for testing.
41   virtual std::string ReadFile(std::string path);
42 
43  private:
44   std::unique_ptr<TraceWriter> writer_;
45   std::unique_ptr<CpuFreqInfo> cpu_freq_info_;
46 };
47 
48 }  // namespace perfetto
49 
50 #endif  // SRC_TRACED_PROBES_SYSTEM_INFO_SYSTEM_INFO_DATA_SOURCE_H_
51