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_CAPABILITY_FEATURE_CONFIG_FEATURE_PARAM_MANAGER_H 17 #define FOUNDATION_ACE_ADAPTER_OHOS_CAPABILITY_FEATURE_CONFIG_FEATURE_PARAM_MANAGER_H 18 19 #include <string> 20 21 #include "base/utils/singleton.h" 22 #include "base/utils/noncopyable.h" 23 24 namespace OHOS::Ace { 25 class ConfigXMLParserBase; 26 class FeatureParamManager final : public Singleton<FeatureParamManager> { 27 DECLARE_SINGLETON(FeatureParamManager); 28 ACE_DISALLOW_MOVE(FeatureParamManager); 29 30 public: 31 void Init(const std::string& bundleName); 32 33 // SyncLoadParser 34 void SetSyncLoadEnableParam(bool enabled, uint32_t deadline); 35 bool IsSyncLoadEnabled() const; 36 uint32_t GetSyncloadResponseDeadline() const; 37 // UINodeGcParamParser 38 void SetUINodeGcEnabled(bool enabled); 39 bool IsUINodeGcEnabled() const; 40 41 private: 42 void FeatureParamParseEntry(const std::string& bundleName); 43 static const std::unordered_map<std::string, std::shared_ptr<ConfigXMLParserBase>> featureParamMap_; 44 static constexpr uint32_t MAX_TIMER_SIZE = 3; // 3 is max size for responseDeadline 45 static constexpr uint32_t DEFAULT_SYNCLOAD_DEADLINE = 50; // 50ms default time 46 static constexpr uint32_t MS_TO_NS = 1000000; // 1000000 change time form ms to ns 47 48 std::shared_ptr<ConfigXMLParserBase> featureParser_; 49 // SyncLoadParser 50 bool syncLoadEnabled_ = false; 51 uint32_t syncloadResponseDeadline_ = DEFAULT_SYNCLOAD_DEADLINE * MS_TO_NS; 52 // UINodeGcParamParser 53 bool uiNodeGcEnabled_ = false; 54 55 friend class ConfigXMLParserBase; 56 friend class SyncLoadParser; 57 }; 58 } // namespace OHOS::Ace 59 60 #endif // FOUNDATION_ACE_ADAPTER_OHOS_CAPABILITY_FEATURE_CONFIG_FEATURE_PARAM_MANAGER_H 61