1 /* 2 * Copyright (c) 2021 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 FREEZE_DETECTOR_PLUGIN_H 17 #define FREEZE_DETECTOR_PLUGIN_H 18 19 #include <memory> 20 21 #include "event.h" 22 #include "event_loop.h" 23 #include "freeze_common.h" 24 #include "plugin.h" 25 #include "watch_point.h" 26 #include "resolver.h" 27 28 namespace OHOS { 29 namespace HiviewDFX { 30 class FreezeDetectorPlugin : public Plugin { 31 public: 32 FreezeDetectorPlugin(); 33 ~FreezeDetectorPlugin(); 34 bool ReadyToLoad() override; 35 bool OnEvent(std::shared_ptr<Event> &event) override; 36 void OnLoad() override; 37 void OnUnload() override; 38 bool CanProcessEvent(std::shared_ptr<Event> event) override; 39 void OnEventListeningCallback(const Event& msg) override; 40 41 private: 42 std::string RemoveRedundantNewline(const std::string& content) const; 43 WatchPoint MakeWatchPoint(const Event& event); 44 void ProcessEvent(WatchPoint watchPoint); 45 std::shared_ptr<EventLoop> threadLoop_ = nullptr; 46 std::shared_ptr<FreezeCommon> freezeCommon_ = nullptr; 47 std::unique_ptr<FreezeResolver> freezeResolver_ = nullptr; 48 }; 49 } // namespace HiviewDFX 50 } // namespace OHOS 51 #endif // HIVIEW_PLUGIN_FREEZE_DETECTOR_H 52