1 /* 2 * Copyright (c) 2025 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 #ifndef HITRACE_CHAIN_ANI_H 17 #define HITRACE_CHAIN_ANI_H 18 19 #include <ani.h> 20 #include <unordered_map> 21 #include "hitrace_chain_ani_util.h" 22 23 namespace OHOS { 24 namespace HiviewDFX { 25 class HiTraceChainAni { 26 public: 27 static ani_object Begin(ani_env* env, ani_string nameAni, ani_object flagAni); 28 static ani_object Result(ani_env* env, HiTraceId& traceId); 29 static void End(ani_env* env, ani_object HiTraceId); 30 static ani_object GetId(ani_env* env); 31 static void SetId(ani_env* env, ani_object HiTraceId); 32 static void ClearId(ani_env* env); 33 static ani_object CreateSpan(ani_env* env); 34 static void Tracepoint(ani_env* env, ani_enum_item modeAni, 35 ani_enum_item typeAni, ani_object HiTraceIdAni, ani_string msgAni); 36 static ani_boolean IsValid(ani_env* env, ani_object HiTraceIdAni); 37 static ani_boolean IsFlagEnabled(ani_env* env, ani_object HiTraceIdAni, 38 ani_enum_item flagAni); 39 static void EnableFlag(ani_env* env, ani_object HiTraceIdAni, ani_enum_item flagAni); 40 }; 41 } // namespace HiviewDFX 42 } // namespace OHOS 43 44 #endif // HITRACE_CHAIN_ANI_H 45