• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef ASSET_NAPI_CONTEXT_H
17 #define ASSET_NAPI_CONTEXT_H
18 
19 #include "napi/native_api.h"
20 #include "napi/native_node_api.h"
21 
22 #include "asset_system_type.h"
23 
24 namespace OHOS {
25 namespace Security {
26 namespace Asset {
27 
28 class BaseContext {
29 public:
30     virtual ~BaseContext();
31 
32     napi_env env = nullptr;
33     napi_async_work work = nullptr;
34     napi_deferred deferred = nullptr;
35     std::vector<AssetAttr> attrs;
36     int32_t result = SEC_ASSET_INVALID_ARGUMENT;
37 
38     std::function<napi_status(const napi_env, napi_callback_info, BaseContext *)> parse;
39     napi_async_execute_callback execute;
40     std::function<napi_value(napi_env, BaseContext *)> resolve;
41     std::function<napi_value(napi_env, BaseContext *)> check;
42 };
43 
44 class PreQueryContext : public BaseContext {
45 public:
46     ~PreQueryContext();
47     AssetBlob challenge = { 0 };
48 };
49 
50 class QueryContext : public BaseContext {
51 public:
52     ~QueryContext();
53     AssetResultSet resultSet = { 0 };
54 };
55 
56 class UpdateContext : public BaseContext {
57 public:
58     ~UpdateContext();
59     std::vector<AssetAttr> updateAttrs;
60 };
61 
62 class QuerySyncResultContext : public BaseContext {
63 public:
64     // output
65     AssetSyncResult syncResult;
66 };
67 
68 } // Asset
69 } // Security
70 } // OHOS
71 #endif // ASSET_NAPI_CONTEXT_H
72