1 /*
2  * Copyright (c) 2024 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 FILEMANAGEMENT_FILE_API_TASK_SIGNAL_H
17 #define FILEMANAGEMENT_FILE_API_TASK_SIGNAL_H
18 
19 #include <unistd.h>
20 #include <memory>
21 #include <string>
22 
23 #include "task_signal_listener.h"
24 
25 namespace OHOS {
26 namespace DistributedFS {
27 namespace ModuleTaskSignal {
28 class TaskSignal {
29 public:
30     TaskSignal() = default;
31     ~TaskSignal() = default;
32     int32_t Cancel();
33     bool IsCanceled();
34     bool CheckCancelIfNeed(const std::string &path);
35     void OnCancel();
36     void SetTaskSignalListener(TaskSignalListener *signalListener);
37     void MarkRemoteTask();
38     void SetFileInfoOfRemoteTask(const std::string &sessionName, const std::string &filePath);
39     std::atomic_bool needCancel_{ false };
40     std::atomic_bool remoteTask_{ false };
41     std::string sessionName_ = std::string("");
42     std::string filePath_ = std::string("");
43 private:
44     TaskSignalListener *signalListener_;
45 };
46 } // namespace ModuleTaskSignal
47 } // namespace DistributedFS
48 } // namespace OHOS
49 #endif // FILEMANAGEMENT_FILE_API_TASK_SIGNAL_H