• 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 #ifndef INCLUDE_PERFETTO_EXT_CLOUD_TRACE_PROCESSOR_ENVIRONMENT_H_
18 #define INCLUDE_PERFETTO_EXT_CLOUD_TRACE_PROCESSOR_ENVIRONMENT_H_
19 
20 #include <functional>
21 #include <memory>
22 #include <vector>
23 
24 #include "perfetto/base/status.h"
25 #include "perfetto/base/task_runner.h"
26 #include "perfetto/ext/base/status_or.h"
27 #include "perfetto/ext/base/threading/stream.h"
28 
29 namespace perfetto {
30 namespace cloud_trace_processor {
31 
32 // Shim interface allowing embedders to change how operations which interact
33 // with the OS operate (e.g. IO, networking etc).
34 class CtpEnvironment {
35  public:
36   virtual ~CtpEnvironment();
37 
38   // Opens the file at |path| and reads the contents in chunks, returning the
39   // the chunks as a Stream. The size of the chunks is implementation defined
40   // but should be sized to balance memory use and syscall count.
41   virtual base::StatusOrStream<std::vector<uint8_t>> ReadFile(
42       const std::string& path) = 0;
43 };
44 
45 }  // namespace cloud_trace_processor
46 }  // namespace perfetto
47 
48 #endif  // INCLUDE_PERFETTO_EXT_CLOUD_TRACE_PROCESSOR_ENVIRONMENT_H_
49