1 /*
2 * Copyright (c) 2022-2022 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 "inputmethod_trace.h"
17
18 #include "hitrace_meter.h"
19
20 namespace OHOS {
21 namespace MiscServices {
22 constexpr uint64_t HITRACE_TAG_MISC = (1ULL << 41); // Notification module tag.
23 // LCOV_EXCL_START
InitHiTrace()24 void InitHiTrace()
25 {
26 UpdateTraceLabel();
27 }
28
ValueTrace(const std::string & name,int64_t count)29 void ValueTrace(const std::string &name, int64_t count)
30 {
31 CountTrace(HITRACE_TAG_MISC, name, count);
32 }
33
StartAsync(const std::string & value,int32_t taskId)34 void StartAsync(const std::string &value, int32_t taskId)
35 {
36 StartAsyncTrace(HITRACE_TAG_MISC, value, taskId);
37 }
38
FinishAsync(const std::string & value,int32_t taskId)39 void FinishAsync(const std::string &value, int32_t taskId)
40 {
41 FinishAsyncTrace(HITRACE_TAG_MISC, value, taskId);
42 }
43 // LCOV_EXCL_STOP
InputMethodSyncTrace(const std::string & value)44 InputMethodSyncTrace::InputMethodSyncTrace(const std::string &value)
45 {
46 StartTrace(HITRACE_TAG_MISC, value);
47 }
48 // LCOV_EXCL_START
InputMethodSyncTrace(const std::string & value,const std::string & id)49 InputMethodSyncTrace::InputMethodSyncTrace(const std::string &value, const std::string &id)
50 {
51 auto info = value + "_" + id;
52 StartTrace(HITRACE_TAG_MISC, info);
53 }
54 // LCOV_EXCL_STOP
~InputMethodSyncTrace()55 InputMethodSyncTrace::~InputMethodSyncTrace()
56 {
57 FinishTrace(HITRACE_TAG_MISC);
58 }
59 } // namespace MiscServices
60 } // namespace OHOS