1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "hitracechain_impl.h"
17 #include <string>
18
19 using namespace OHOS::HiviewDFX;
20
21 namespace OHOS {
22 namespace CJSystemapi {
23
Begin(const char * name,int flags)24 HiTraceId HiTraceChainImpl::Begin(const char* name, int flags)
25 {
26 return HiTraceChain::Begin(std::string(name), flags);
27 }
28
End(const HiTraceId & id)29 void HiTraceChainImpl::End(const HiTraceId& id)
30 {
31 return HiTraceChain::End(id);
32 }
33
GetId()34 HiTraceId HiTraceChainImpl::GetId()
35 {
36 return HiTraceChain::GetId();
37 }
38
SetId(const HiTraceId & id)39 void HiTraceChainImpl::SetId(const HiTraceId& id)
40 {
41 return HiTraceChain::SetId(id);
42 }
43
ClearId()44 void HiTraceChainImpl::ClearId()
45 {
46 return HiTraceChain::ClearId();
47 }
48
CreateSpan()49 HiTraceId HiTraceChainImpl::CreateSpan()
50 {
51 return HiTraceChain::CreateSpan();
52 }
53
Tracepoint(uint32_t mode,uint32_t type,HiTraceId id,const char * fmt)54 void HiTraceChainImpl::Tracepoint(uint32_t mode, uint32_t type, HiTraceId id, const char* fmt)
55 {
56 HiTraceCommunicationMode communicationMode = HiTraceCommunicationMode(mode);
57 HiTraceTracepointType tracePointType = HiTraceTracepointType(type);
58 return HiTraceChain::Tracepoint(communicationMode, tracePointType, id, "%s", fmt);
59 }
60
IsValid(const HiTraceId & id)61 bool HiTraceChainImpl::IsValid(const HiTraceId& id)
62 {
63 return id.IsValid();
64 }
65
IsFlagEnabled(const HiTraceId & traceId,int32_t flag)66 bool HiTraceChainImpl::IsFlagEnabled(const HiTraceId& traceId, int32_t flag)
67 {
68 HiTraceFlag traceFlag = HiTraceFlag(flag);
69 bool isFalgEnabled = traceId.IsFlagEnabled(traceFlag);
70 return isFalgEnabled;
71 }
72
EnableFlag(HiTraceId & traceId,int32_t flag)73 void HiTraceChainImpl::EnableFlag(HiTraceId& traceId, int32_t flag)
74 {
75 HiTraceFlag traceFlag = HiTraceFlag(flag);
76 traceId.EnableFlag(traceFlag);
77 }
78
79 } // CJSystemapi
80 } // OHOS
81
82