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::FakePlatform::~FakePlatform() = default;
39 
40 Platform::ThreadLocalObject*
GetOrCreateThreadLocalObject()41 TracingMuxerFake::FakePlatform::GetOrCreateThreadLocalObject() {
42   FailUninitialized();
43 }
44 
45 std::unique_ptr<base::TaskRunner>
CreateTaskRunner(const CreateTaskRunnerArgs &)46 TracingMuxerFake::FakePlatform::CreateTaskRunner(const CreateTaskRunnerArgs&) {
47   FailUninitialized();
48 }
49 
GetCurrentProcessName()50 std::string TracingMuxerFake::FakePlatform::GetCurrentProcessName() {
51   FailUninitialized();
52 }
53 
RegisterDataSource(const DataSourceDescriptor &,DataSourceFactory,DataSourceStaticState *)54 bool TracingMuxerFake::RegisterDataSource(const DataSourceDescriptor&,
55                                           DataSourceFactory,
56                                           DataSourceStaticState*) {
57   FailUninitialized();
58 }
59 
CreateTraceWriter(DataSourceStaticState *,uint32_t,DataSourceState *,BufferExhaustedPolicy)60 std::unique_ptr<TraceWriterBase> TracingMuxerFake::CreateTraceWriter(
61     DataSourceStaticState*,
62     uint32_t,
63     DataSourceState*,
64     BufferExhaustedPolicy) {
65   FailUninitialized();
66 }
67 
DestroyStoppedTraceWritersForCurrentThread()68 void TracingMuxerFake::DestroyStoppedTraceWritersForCurrentThread() {
69   FailUninitialized();
70 }
71 
RegisterInterceptor(const InterceptorDescriptor &,InterceptorFactory,InterceptorBase::TLSFactory,InterceptorBase::TracePacketCallback)72 void TracingMuxerFake::RegisterInterceptor(
73     const InterceptorDescriptor&,
74     InterceptorFactory,
75     InterceptorBase::TLSFactory,
76     InterceptorBase::TracePacketCallback) {
77   FailUninitialized();
78 }
79 
80 }  // namespace internal
81 }  // namespace perfetto
82