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_ENTITY_H
17 #define FILEMANAGEMENT_FILE_API_TASK_SIGNAL_ENTITY_H
18 
19 #include "filemgmt_libn.h"
20 #include "task_signal.h"
21 #include "task_signal_listener.h"
22 
23 namespace OHOS::FileManagement::ModuleFileIO {
24 using namespace DistributedFS::ModuleTaskSignal;
25 class JSCallbackContext {
26 public:
JSCallbackContext(LibN::NVal jsVal)27     explicit JSCallbackContext(LibN::NVal jsVal) : ref_(jsVal) {}
28     ~JSCallbackContext() = default;
29 
30     napi_env env_ = nullptr;
31     LibN::NRef ref_;
32     std::string filePath_;
33 };
34 
35 class TaskSignalEntity : public TaskSignalListener {
36 public:
37     TaskSignalEntity() = default;
38     ~TaskSignalEntity() override;
39     void OnCancel() override;
40 
41     std::shared_ptr<TaskSignal> taskSignal_ = nullptr;
42     std::shared_ptr<JSCallbackContext> callbackContext_ = nullptr;
43 };
44 } // namespace OHOS::FileManagement::ModuleFileIO
45 
46 #endif // FILEMANAGEMENT_FILE_API_TASK_SIGNAL_ENTITY_H