1 /* 2 * Copyright (c) 2025 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 #ifndef EDIT_ASYN_CALL_H 16 #define EDIT_ASYN_CALL_H 17 18 #include "async_call.h" 19 namespace OHOS { 20 namespace MiscServices { 21 class EditAsyncCall : public AsyncCall { 22 public: EditAsyncCall(napi_env env,napi_callback_info info,std::shared_ptr<Context> context,size_t maxParamCount)23 EditAsyncCall(napi_env env, napi_callback_info info, std::shared_ptr<Context> context, size_t maxParamCount) 24 : AsyncCall(env, info, context, maxParamCount){}; ~EditAsyncCall()25 virtual ~EditAsyncCall(){}; 26 27 private: CallImpl(napi_env env,AsyncContext * context,const std::string & resourceName)28 void CallImpl(napi_env env, AsyncContext *context, const std::string &resourceName) override 29 { 30 if (context == nullptr || context->ctx == nullptr) { 31 IMSA_HILOGE("context is nullptr!"); 32 return; 33 } 34 auto cb = [env, context, resourceName]() -> void { 35 auto task = [env, context]() -> void { AsyncCall::OnComplete(env, context->ctx->GetState(), context); }; 36 auto handler = context->ctx->GetHandler(); 37 if (handler != nullptr) { 38 handler->PostTask(task, "IMF_" + resourceName + "_EDIT", 0, AppExecFwk::EventQueue::Priority::VIP); 39 } 40 }; 41 AsyncCall::OnExecuteAsync(env, context, cb); 42 } 43 }; 44 } // namespace MiscServices 45 } // namespace OHOS 46 #endif // EDIT_ASYN_CALL_H 47