1 /*
2 * Copyright (c) 2023 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 "xcollie_helper.h"
17
18 #include "xcollie/xcollie_define.h"
19 #include "utils_log.h"
20 #include "dfs_error.h"
21
22 namespace OHOS::FileManagement {
23 using namespace std;
SetTimer(const std::string & name,uint32_t timeout,XCollieCallback func,void * arg,bool recovery)24 int XCollieHelper::SetTimer(const std::string &name, uint32_t timeout, XCollieCallback func, void *arg, bool recovery)
25 {
26 #ifdef HICOLLIE_ENABLE
27 unsigned int flag = HiviewDFX::XCOLLIE_FLAG_LOG | HiviewDFX::XCOLLIE_FLAG_NOOP;
28 if (recovery) {
29 flag |= HiviewDFX::XCOLLIE_FLAG_RECOVERY;
30 }
31 return HiviewDFX::XCollie::GetInstance().SetTimer(name, timeout, func, arg, flag);
32 #else
33 LOGI("XCollie not supported");
34 return HiviewDFX::INVALID_ID;
35 #endif
36 }
CancelTimer(int id)37 void XCollieHelper::CancelTimer(int id)
38 {
39 #ifdef HICOLLIE_ENABLE
40 HiviewDFX::XCollie::GetInstance().CancelTimer(id);
41 #endif
42 }
43 } // namespace OHOS::FileManagement::CloudSync