• 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 FOUNDATION_ACE_ADAPTER_OHOS_ENTRANCE_GLOBAL_PIPELINE_CONTEXT_MANAGER_H
17 #define FOUNDATION_ACE_ADAPTER_OHOS_ENTRANCE_GLOBAL_PIPELINE_CONTEXT_MANAGER_H
18 
19 #include <memory>
20 #include <string>
21 #include <unordered_map>
22 
23 #include "wm/window.h"
24 
25 #include "base/memory/ace_type.h"
26 #include "base/memory/referenced.h"
27 #include "core/common/thread_model_impl.h"
28 #include "core/common/window.h"
29 #include "core/pipeline_ng/pipeline_context.h"
30 
31 namespace OHOS::Ace {
32 class WindowLifeCycle : public Rosen::IWindowLifeCycle {
33 public:
WindowLifeCycle(const std::string & name)34     explicit WindowLifeCycle(const std::string& name) : name_(name) {};
35     ~WindowLifeCycle() override = default;
36 
37     void AfterDestroyed() override;
38 
39 private:
40     std::string name_;
41 };
42 
43 class GlobalPipelineContextManager final : public AceType {
44     DECLARE_ACE_TYPE(GlobalPipelineContextManager, AceType);
45 
46 public:
47     ~GlobalPipelineContextManager() override = default;
48 
49     static GlobalPipelineContextManager* GetInstance();
50 
51     RefPtr<NG::PipelineContext> GetGlobalPipelineContext(const std::string& name) const;
52 
53     RefPtr<NG::PipelineContext> CreateGlobalPipelineContext(const std::string& name,
54         const sptr<OHOS::Rosen::Window>& rsWindow, FrontendType frontendType, int32_t instanceId);
55 
56     RefPtr<NG::PipelineContext> RemoveGlobalPipelineContext(const std::string& name);
57 
58     RefPtr<NG::FrameNode> RemoveModalPageNode(const std::string& name);
59 
60     RefPtr<NG::FrameNode> GetModalPageNode(const std::string& name);
61 
62     void ProcessModalPageNode(const std::string& name, int32_t instanceId);
63 
64     void RegisterSessionId(const std::string& name, int32_t sessionId);
65 
66     int32_t GetSessionId(const std::string& name);
67 
68     void RemoveSessionId(const std::string& name);
69 
70     std::string GetUecNameBySessionId(int32_t sessionId);
71 
72 private:
73     GlobalPipelineContextManager();
74 
75     void AddGlobalPipelineContext(const std::string& name, const RefPtr<NG::PipelineContext>& pipelineContext);
76 
77     std::unordered_map<std::string, RefPtr<NG::PipelineContext>> globalContextMap_;
78     std::unordered_map<std::string, RefPtr<NG::FrameNode>> modalPageMap_;
79     std::unordered_map<std::string, int32_t> sessionIdMap_;
80 
81     std::unique_ptr<ThreadModelImpl> threadModelImpl_ = nullptr;
82 };
83 } // namespace OHOS::Ace
84 
85 #endif
86