1 /* 2 * Copyright (c) 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 #ifndef NAPI_NOTIFY_CALLBACK_H 17 #define NAPI_NOTIFY_CALLBACK_H 18 19 #include "file_access_framework_errno.h" 20 #include "hilog_wrapper.h" 21 #include "inotify_callback.h" 22 #include "napi/native_common.h" 23 #include "napi/native_node_api.h" 24 #include "napi/native_api.h" 25 #include "uri.h" 26 27 namespace OHOS { 28 namespace FileAccessFwk { 29 class NapiNotifyCallback : public INotifyCallback { 30 public: 31 NapiNotifyCallback(napi_env env, napi_value callback); 32 virtual ~NapiNotifyCallback(); 33 int OnNotify(const NotifyMessage &message) override; 34 35 private: 36 struct CallbackParam { 37 NapiNotifyCallback *callback_; 38 NotifyMessage message_; CallbackParamCallbackParam39 CallbackParam(NapiNotifyCallback *callback, NotifyMessage message) 40 : callback_(callback), message_(message) 41 {} 42 }; 43 napi_ref callback_ = nullptr; 44 napi_env env_; 45 uv_loop_s *loop_ = nullptr; 46 }; 47 } // namespace FileAccessFwk 48 } // namespace OHOS 49 #endif // NAPI_NOTIFY_CALLBACK_H