1 /*
2  * Copyright (c) 2022-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 #ifndef INTERFACES_ACCESSTOKEN_KITS_NAPI_CONTEXT_COMMON_H
16 #define INTERFACES_ACCESSTOKEN_KITS_NAPI_CONTEXT_COMMON_H
17 
18 #include <uv.h>
19 #include "accesstoken_log.h"
20 #include "access_token_error.h"
21 #include "napi_error.h"
22 #include "napi_common.h"
23 
24 namespace OHOS {
25 namespace Security {
26 namespace AccessToken {
27 class NapiContextCommon {
28 public:
29     static constexpr int32_t MAX_PARAMS_ONE = 1;
30     static constexpr int32_t MAX_PARAMS_TWO = 2;
31     static constexpr int32_t MAX_PARAMS_THREE = 3;
32     static constexpr int32_t MAX_PARAMS_FOUR = 4;
33     static constexpr int32_t MAX_LENGTH = 256;
34     static constexpr int32_t MAX_WAIT_TIME = 1000;
35     static constexpr int32_t VALUE_MAX_LEN = 32;
36 
37     static int32_t GetJsErrorCode(int32_t errCode);
38 };
39 struct AtManagerAsyncWorkData {
40     explicit AtManagerAsyncWorkData(napi_env envValue);
41     virtual ~AtManagerAsyncWorkData();
42 
43     napi_env        env = nullptr;
44     napi_async_work work = nullptr;
45     napi_deferred   deferred = nullptr;
46     napi_ref        callbackRef = nullptr;
47 };
48 
49 struct AtManagerAsyncWorkDataRel {
50     napi_env        env = nullptr;
51     napi_async_work work = nullptr;
52     napi_ref        callbackRef = nullptr;
53 };
54 } // namespace AccessToken
55 } // namespace Security
56 } // namespace OHOS
57 #endif /* INTERFACES_ACCESSTOKEN_KITS_NAPI_CONTEXT_COMMON_H */
58