• 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 #ifndef OHOS_ANI_ACE_PLUGIN_CALLBACK_MGR_H
16 #define OHOS_ANI_ACE_PLUGIN_CALLBACK_MGR_H
17 
18 #include <map>
19 #include <mutex>
20 #include <string>
21 
22 #include "ani_plugin_callback.h"
23 #include "ani_plugin_component_data.h"
24 
25 namespace OHOS::Ace::Ani {
26 using namespace OHOS::Ace;
27 
28 class ANIPluginCallbackMgr final {
29 public:
30     ANIPluginCallbackMgr();
31     ~ANIPluginCallbackMgr();
32 
33     static ANIPluginCallbackMgr& Instance(void);
34     bool RegisterOnEvent(ani_env* env, CallBackType eventType, const AAFwk::Want& want, ACECallbackInfo& cbInfo);
35     bool RegisterRequestEvent(ani_env* env, const AAFwk::Want& want, ACECallbackInfo& cbInfo,
36         const std::shared_ptr<AceJSPluginRequestParam>& param);
37     void UnRegisterEvent(size_t key);
38 
39 private:
40     std::mutex mutex_;
41     ACEAsyncJSCallbackInfo* asyncJSCallbackInfo_ = nullptr;
42     std::map<size_t, std::shared_ptr<ANIPluginCallback>> eventList_;
43 };
44 } // namespace OHOS::Ace::Ani
45 #endif // OHOS_ANI_ACE_PLUGIN_CALLBACK_MGR_H