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 HIVIEW_PLUGINS_EVENT_VALIDATOR_H 17 #define HIVIEW_PLUGINS_EVENT_VALIDATOR_H 18 19 #include "event_delayed_util.h" 20 #include "event_verify_util.h" 21 #include "i_controller.h" 22 #include "plugin.h" 23 24 namespace OHOS { 25 namespace HiviewDFX { 26 class EventValidator : public Plugin, public EventListener { 27 public: 28 bool OnEvent(std::shared_ptr<Event>& event) override; 29 void OnLoad() override; 30 void OnUnload() override; 31 void OnConfigUpdate(const std::string& localCfgPath, const std::string& cloudCfgPath) override; 32 void OnUnorderedEvent(const Event& msg) override; 33 std::string GetListenerName() override; 34 35 private: 36 void Init(); 37 void InitWorkLoop(HiviewContext* context); 38 void InitEventVerifyUtil(HiviewContext* context); 39 void InitController(HiviewContext* context); 40 bool CheckEvent(std::shared_ptr<Event> event); 41 void UpdateConfig(); 42 43 private: 44 EventDelayedUtil eventDelayedUtil_; 45 EventVerifyUtil eventVerifyUtil_; 46 std::shared_ptr<IController> controller_; 47 std::atomic<bool> isConfigUpdated_ { false }; 48 }; 49 } // namespace HiviewDFX 50 } // namespace OHOS 51 #endif // HIVIEW_PLUGINS_EVENT_VALIDATOR_H 52