1 /*
2 * Copyright (C) 2024 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/test/proxy_producer_endpoint.h"
18
19 #include "perfetto/ext/tracing/core/trace_writer.h"
20
21 namespace perfetto {
22
23 ProxyProducerEndpoint::~ProxyProducerEndpoint() = default;
24
Disconnect()25 void ProxyProducerEndpoint::Disconnect() {
26 if (!backend_) {
27 return;
28 }
29 backend_->Disconnect();
30 }
RegisterDataSource(const DataSourceDescriptor & dsd)31 void ProxyProducerEndpoint::RegisterDataSource(
32 const DataSourceDescriptor& dsd) {
33 if (!backend_) {
34 return;
35 }
36 backend_->RegisterDataSource(dsd);
37 }
UpdateDataSource(const DataSourceDescriptor & dsd)38 void ProxyProducerEndpoint::UpdateDataSource(const DataSourceDescriptor& dsd) {
39 if (!backend_) {
40 return;
41 }
42 backend_->UpdateDataSource(dsd);
43 }
UnregisterDataSource(const std::string & name)44 void ProxyProducerEndpoint::UnregisterDataSource(const std::string& name) {
45 if (!backend_) {
46 return;
47 }
48 backend_->UnregisterDataSource(name);
49 }
RegisterTraceWriter(uint32_t writer_id,uint32_t target_buffer)50 void ProxyProducerEndpoint::RegisterTraceWriter(uint32_t writer_id,
51 uint32_t target_buffer) {
52 if (!backend_) {
53 return;
54 }
55 backend_->RegisterTraceWriter(writer_id, target_buffer);
56 }
UnregisterTraceWriter(uint32_t writer_id)57 void ProxyProducerEndpoint::UnregisterTraceWriter(uint32_t writer_id) {
58 if (!backend_) {
59 return;
60 }
61 backend_->UnregisterTraceWriter(writer_id);
62 }
CommitData(const CommitDataRequest & req,CommitDataCallback callback)63 void ProxyProducerEndpoint::CommitData(const CommitDataRequest& req,
64 CommitDataCallback callback) {
65 if (!backend_) {
66 return;
67 }
68 backend_->CommitData(req, callback);
69 }
shared_memory() const70 SharedMemory* ProxyProducerEndpoint::shared_memory() const {
71 if (!backend_) {
72 return nullptr;
73 }
74 return backend_->shared_memory();
75 }
shared_buffer_page_size_kb() const76 size_t ProxyProducerEndpoint::shared_buffer_page_size_kb() const {
77 if (!backend_) {
78 return 0;
79 }
80 return backend_->shared_buffer_page_size_kb();
81 }
CreateTraceWriter(BufferID target_buffer,BufferExhaustedPolicy buffer_exhausted_policy)82 std::unique_ptr<TraceWriter> ProxyProducerEndpoint::CreateTraceWriter(
83 BufferID target_buffer,
84 BufferExhaustedPolicy buffer_exhausted_policy) {
85 if (!backend_) {
86 return nullptr;
87 }
88 return backend_->CreateTraceWriter(target_buffer, buffer_exhausted_policy);
89 }
MaybeSharedMemoryArbiter()90 SharedMemoryArbiter* ProxyProducerEndpoint::MaybeSharedMemoryArbiter() {
91 if (!backend_) {
92 return nullptr;
93 }
94 return backend_->MaybeSharedMemoryArbiter();
95 }
IsShmemProvidedByProducer() const96 bool ProxyProducerEndpoint::IsShmemProvidedByProducer() const {
97 if (!backend_) {
98 return false;
99 }
100 return backend_->IsShmemProvidedByProducer();
101 }
NotifyFlushComplete(FlushRequestID id)102 void ProxyProducerEndpoint::NotifyFlushComplete(FlushRequestID id) {
103 if (!backend_) {
104 return;
105 }
106 backend_->NotifyFlushComplete(id);
107 }
NotifyDataSourceStarted(DataSourceInstanceID id)108 void ProxyProducerEndpoint::NotifyDataSourceStarted(DataSourceInstanceID id) {
109 if (!backend_) {
110 return;
111 }
112 backend_->NotifyDataSourceStarted(id);
113 }
NotifyDataSourceStopped(DataSourceInstanceID id)114 void ProxyProducerEndpoint::NotifyDataSourceStopped(DataSourceInstanceID id) {
115 if (!backend_) {
116 return;
117 }
118 backend_->NotifyDataSourceStopped(id);
119 }
ActivateTriggers(const std::vector<std::string> & triggers)120 void ProxyProducerEndpoint::ActivateTriggers(
121 const std::vector<std::string>& triggers) {
122 if (!backend_) {
123 return;
124 }
125 backend_->ActivateTriggers(triggers);
126 }
Sync(std::function<void ()> callback)127 void ProxyProducerEndpoint::Sync(std::function<void()> callback) {
128 if (!backend_) {
129 return;
130 }
131 backend_->Sync(callback);
132 }
133
134 } // namespace perfetto
135