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 ASYNC_CONTEXT_H 17#define ASYNC_CONTEXT_H 18 19#include "constant_definition.h" 20#include "napi/native_api.h" 21 22namespace OHOS { 23namespace Location { 24class AsyncContext { 25public: 26 napi_env env; 27 napi_async_work work; 28 napi_deferred deferred; 29 napi_ref callback[MAX_CALLBACK_NUM] = { 0 }; 30 std::function<void(void*)> executeFunc; 31 std::function<void(void*)> completeFunc; 32 napi_value resourceName; 33 napi_value result[RESULT_SIZE]; 34 int errCode; 35 36 explicit AsyncContext(napi_env e, napi_async_work w = nullptr, napi_deferred d = nullptr) 37 { 38 env = e; 39 work = w; 40 deferred = d; 41 executeFunc = nullptr; 42 completeFunc = nullptr; 43 resourceName = nullptr; 44 result[PARAM0] = nullptr; 45 result[PARAM1] = nullptr; 46 errCode = 0; 47 } 48 49 AsyncContext() = delete; 50 51 virtual ~AsyncContext() 52 { 53 } 54}; 55} // namespace Location 56} // namespace OHOS 57#endif // ASYNC_CONTEXT_H