1 // Copyright 2017 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <trace-provider/handler.h>
6
7 namespace trace {
8
9 const trace_handler_ops_t TraceHandler::kOps =
10 {.is_category_enabled = &TraceHandler::CallIsCategoryEnabled,
11 .trace_started = &TraceHandler::CallTraceStarted,
12 .trace_stopped = &TraceHandler::CallTraceStopped,
13 .notify_buffer_full = &TraceHandler::CallNotifyBufferFull};
14
TraceHandler()15 TraceHandler::TraceHandler()
16 : trace_handler{.ops = &kOps} {}
17
18 TraceHandler::~TraceHandler() = default;
19
CallIsCategoryEnabled(trace_handler_t * handler,const char * category)20 bool TraceHandler::CallIsCategoryEnabled(trace_handler_t* handler, const char* category) {
21 return static_cast<TraceHandler*>(handler)->IsCategoryEnabled(category);
22 }
23
CallTraceStarted(trace_handler_t * handler)24 void TraceHandler::CallTraceStarted(trace_handler_t* handler) {
25 static_cast<TraceHandler*>(handler)->TraceStarted();
26 }
27
CallTraceStopped(trace_handler_t * handler,async_dispatcher_t * dispatcher,zx_status_t disposition,size_t buffer_bytes_written)28 void TraceHandler::CallTraceStopped(trace_handler_t* handler, async_dispatcher_t* dispatcher,
29 zx_status_t disposition, size_t buffer_bytes_written) {
30 static_cast<TraceHandler*>(handler)->TraceStopped(dispatcher,
31 disposition, buffer_bytes_written);
32 }
33
CallNotifyBufferFull(trace_handler_t * handler,uint32_t wrapped_count,uint64_t durable_data_end)34 void TraceHandler::CallNotifyBufferFull(trace_handler_t* handler,
35 uint32_t wrapped_count,
36 uint64_t durable_data_end) {
37 static_cast<TraceHandler*>(handler)->NotifyBufferFull(wrapped_count,
38 durable_data_end);
39 }
40
41 } // namespace trace
42