1794c9f46Sopenharmony_ci/*
2794c9f46Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3794c9f46Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4794c9f46Sopenharmony_ci * you may not use this file except in compliance with the License.
5794c9f46Sopenharmony_ci * You may obtain a copy of the License at
6794c9f46Sopenharmony_ci *
7794c9f46Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8794c9f46Sopenharmony_ci *
9794c9f46Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10794c9f46Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11794c9f46Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12794c9f46Sopenharmony_ci * See the License for the specific language governing permissions and
13794c9f46Sopenharmony_ci * limitations under the License.
14794c9f46Sopenharmony_ci */
15794c9f46Sopenharmony_ci#include "dh_utils_hitrace.h"
16794c9f46Sopenharmony_ci
17794c9f46Sopenharmony_ci#include <unordered_map>
18794c9f46Sopenharmony_ci
19794c9f46Sopenharmony_cinamespace OHOS {
20794c9f46Sopenharmony_cinamespace DistributedHardware {
21794c9f46Sopenharmony_civoid DHCompMgrTraceStart(const std::string &anonyNetworkId, const std::string &anonyDHId, const std::string &msg)
22794c9f46Sopenharmony_ci{
23794c9f46Sopenharmony_ci    StartTrace(DHFWK_HITRACE_LABEL, anonyNetworkId + "_" + anonyDHId + "_" + msg);
24794c9f46Sopenharmony_ci}
25794c9f46Sopenharmony_ci
26794c9f46Sopenharmony_civoid DHQueryTraceStart(const DHType dhType)
27794c9f46Sopenharmony_ci{
28794c9f46Sopenharmony_ci    std::string dhTypeStr = "UNKNOWN";
29794c9f46Sopenharmony_ci    auto it = DHTypeStrMap.find(dhType);
30794c9f46Sopenharmony_ci    if (it != DHTypeStrMap.end()) {
31794c9f46Sopenharmony_ci        dhTypeStr = it->second;
32794c9f46Sopenharmony_ci    }
33794c9f46Sopenharmony_ci    StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_" + DH_QUERY_START);
34794c9f46Sopenharmony_ci}
35794c9f46Sopenharmony_ci
36794c9f46Sopenharmony_civoid DHTraceStart(const std::string &msg)
37794c9f46Sopenharmony_ci{
38794c9f46Sopenharmony_ci    StartTrace(DHFWK_HITRACE_LABEL, msg);
39794c9f46Sopenharmony_ci}
40794c9f46Sopenharmony_ci
41794c9f46Sopenharmony_civoid DHTraceEnd()
42794c9f46Sopenharmony_ci{
43794c9f46Sopenharmony_ci    FinishTrace(DHFWK_HITRACE_LABEL);
44794c9f46Sopenharmony_ci}
45794c9f46Sopenharmony_ci} // namespace DistributedHardware
46794c9f46Sopenharmony_ci} // namespace OHOS