1cb7eb8c9Sopenharmony_ci/*
2cb7eb8c9Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3cb7eb8c9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4cb7eb8c9Sopenharmony_ci * you may not use this file except in compliance with the License.
5cb7eb8c9Sopenharmony_ci * You may obtain a copy of the License at
6cb7eb8c9Sopenharmony_ci *
7cb7eb8c9Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8cb7eb8c9Sopenharmony_ci *
9cb7eb8c9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10cb7eb8c9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11cb7eb8c9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12cb7eb8c9Sopenharmony_ci * See the License for the specific language governing permissions and
13cb7eb8c9Sopenharmony_ci * limitations under the License.
14cb7eb8c9Sopenharmony_ci */
15cb7eb8c9Sopenharmony_ci
16cb7eb8c9Sopenharmony_ci#include "xcollie_helper.h"
17cb7eb8c9Sopenharmony_ci
18cb7eb8c9Sopenharmony_ci#include "xcollie/xcollie_define.h"
19cb7eb8c9Sopenharmony_ci#include "utils_log.h"
20cb7eb8c9Sopenharmony_ci#include "dfs_error.h"
21cb7eb8c9Sopenharmony_ci
22cb7eb8c9Sopenharmony_cinamespace OHOS::FileManagement {
23cb7eb8c9Sopenharmony_ciusing namespace std;
24cb7eb8c9Sopenharmony_ciint XCollieHelper::SetTimer(const std::string &name, uint32_t timeout, XCollieCallback func, void *arg, bool recovery)
25cb7eb8c9Sopenharmony_ci{
26cb7eb8c9Sopenharmony_ci#ifdef HICOLLIE_ENABLE
27cb7eb8c9Sopenharmony_ci    unsigned int flag = HiviewDFX::XCOLLIE_FLAG_LOG | HiviewDFX::XCOLLIE_FLAG_NOOP;
28cb7eb8c9Sopenharmony_ci    if (recovery) {
29cb7eb8c9Sopenharmony_ci        flag |= HiviewDFX::XCOLLIE_FLAG_RECOVERY;
30cb7eb8c9Sopenharmony_ci    }
31cb7eb8c9Sopenharmony_ci    return HiviewDFX::XCollie::GetInstance().SetTimer(name, timeout, func, arg, flag);
32cb7eb8c9Sopenharmony_ci#else
33cb7eb8c9Sopenharmony_ci    LOGI("XCollie not supported");
34cb7eb8c9Sopenharmony_ci    return HiviewDFX::INVALID_ID;
35cb7eb8c9Sopenharmony_ci#endif
36cb7eb8c9Sopenharmony_ci}
37cb7eb8c9Sopenharmony_civoid XCollieHelper::CancelTimer(int id)
38cb7eb8c9Sopenharmony_ci{
39cb7eb8c9Sopenharmony_ci#ifdef HICOLLIE_ENABLE
40cb7eb8c9Sopenharmony_ci    HiviewDFX::XCollie::GetInstance().CancelTimer(id);
41cb7eb8c9Sopenharmony_ci#endif
42cb7eb8c9Sopenharmony_ci}
43cb7eb8c9Sopenharmony_ci} // namespace OHOS::FileManagement::CloudSync