1 /*
2 * Copyright (C) 2021 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 #include "src/tracing/internal/tracing_muxer_fake.h"
18
19 namespace perfetto {
20 namespace internal {
21 namespace {
22
FailUninitialized()23 PERFETTO_NORETURN void FailUninitialized() {
24 PERFETTO_FATAL(
25 "Tracing not initialized. Call perfetto::Tracing::Initialize() first.");
26 }
27
28 } // namespace
29
30 #if PERFETTO_HAS_NO_DESTROY()
31 // static
32 PERFETTO_NO_DESTROY TracingMuxerFake::FakePlatform
33 TracingMuxerFake::FakePlatform::instance{};
34 // static
35 PERFETTO_NO_DESTROY TracingMuxerFake TracingMuxerFake::instance{};
36 #endif // PERFETTO_HAS_NO_DESTROY()
37
38 TracingMuxerFake::~TracingMuxerFake() = default;
39
40 TracingMuxerFake::FakePlatform::~FakePlatform() = default;
41
42 Platform::ThreadLocalObject*
GetOrCreateThreadLocalObject()43 TracingMuxerFake::FakePlatform::GetOrCreateThreadLocalObject() {
44 FailUninitialized();
45 }
46
47 std::unique_ptr<base::TaskRunner>
CreateTaskRunner(const CreateTaskRunnerArgs &)48 TracingMuxerFake::FakePlatform::CreateTaskRunner(const CreateTaskRunnerArgs&) {
49 FailUninitialized();
50 }
51
GetCurrentProcessName()52 std::string TracingMuxerFake::FakePlatform::GetCurrentProcessName() {
53 FailUninitialized();
54 }
55
RegisterDataSource(const DataSourceDescriptor &,DataSourceFactory,DataSourceParams,bool,DataSourceStaticState *)56 bool TracingMuxerFake::RegisterDataSource(const DataSourceDescriptor&,
57 DataSourceFactory,
58 DataSourceParams,
59 bool,
60 DataSourceStaticState*) {
61 FailUninitialized();
62 }
63
UpdateDataSourceDescriptor(const DataSourceDescriptor &,const DataSourceStaticState *)64 void TracingMuxerFake::UpdateDataSourceDescriptor(
65 const DataSourceDescriptor&,
66 const DataSourceStaticState*) {
67 FailUninitialized();
68 }
69
CreateTraceWriter(DataSourceStaticState *,uint32_t,DataSourceState *,BufferExhaustedPolicy)70 std::unique_ptr<TraceWriterBase> TracingMuxerFake::CreateTraceWriter(
71 DataSourceStaticState*,
72 uint32_t,
73 DataSourceState*,
74 BufferExhaustedPolicy) {
75 FailUninitialized();
76 }
77
DestroyStoppedTraceWritersForCurrentThread()78 void TracingMuxerFake::DestroyStoppedTraceWritersForCurrentThread() {
79 FailUninitialized();
80 }
81
RegisterInterceptor(const InterceptorDescriptor &,InterceptorFactory,InterceptorBase::TLSFactory,InterceptorBase::TracePacketCallback)82 void TracingMuxerFake::RegisterInterceptor(
83 const InterceptorDescriptor&,
84 InterceptorFactory,
85 InterceptorBase::TLSFactory,
86 InterceptorBase::TracePacketCallback) {
87 FailUninitialized();
88 }
89
ActivateTriggers(const std::vector<std::string> &,uint32_t)90 void TracingMuxerFake::ActivateTriggers(const std::vector<std::string>&,
91 uint32_t) {
92 FailUninitialized();
93 }
94
95 } // namespace internal
96 } // namespace perfetto
97