• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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_PROBES_DATA_SOURCE_H_
18 #define SRC_TRACED_PROBES_PROBES_DATA_SOURCE_H_
19 
20 #include <functional>
21 
22 #include "perfetto/base/logging.h"
23 #include "perfetto/tracing/core/basic_types.h"
24 
25 namespace perfetto {
26 
27 // Base class for all data sources in traced_probes.
28 class ProbesDataSource {
29  public:
30   // |type_id| is a home-brewed RTTI, e.g. InodeFileDataSource::kTypeId.
31   ProbesDataSource(TracingSessionID, int type_id);
32   virtual ~ProbesDataSource();
33 
34   virtual void Start() = 0;
35   virtual void Flush(FlushRequestID, std::function<void()> callback) = 0;
36 
37   // Only data sources that opt in via DataSourceDescriptor should receive this
38   // call.
ClearIncrementalState()39   virtual void ClearIncrementalState() {
40     PERFETTO_ELOG(
41         "ClearIncrementalState received by data source that doesn't provide "
42         "its own implementation.");
43   }
44 
45   const TracingSessionID tracing_session_id;
46   const int type_id;
47   bool started = false;  // Set by probes_producer.cc.
48 
49  private:
50   ProbesDataSource(const ProbesDataSource&) = delete;
51   ProbesDataSource& operator=(const ProbesDataSource&) = delete;
52 };
53 
54 }  // namespace perfetto
55 
56 #endif  // SRC_TRACED_PROBES_PROBES_DATA_SOURCE_H_
57