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_RESOLVER_H 17 #define FREEZE_RESOLVER_H 18 19 #include <list> 20 #include <memory> 21 #include <set> 22 #include <vector> 23 24 #include "db_helper.h" 25 #include "freeze_common.h" 26 #include "watch_point.h" 27 #include "vendor.h" 28 29 namespace OHOS { 30 namespace HiviewDFX { 31 class FreezeResolver { 32 public: FreezeResolver(std::shared_ptr<FreezeCommon> fc)33 explicit FreezeResolver(std::shared_ptr<FreezeCommon> fc) 34 : startTime_(time(nullptr) * MILLISECOND), freezeCommon_(fc) {}; ~FreezeResolver()35 ~FreezeResolver() {}; 36 FreezeResolver& operator=(const FreezeResolver&) = delete; 37 FreezeResolver(const FreezeResolver&) = delete; 38 39 static const int MILLISECOND = 1000; 40 41 bool Init(); 42 std::string GetTimeZone() const; 43 int ProcessEvent(const WatchPoint &watchPoint) const; 44 45 private: 46 bool ResolveEvent(const WatchPoint& watchPoint, 47 std::vector<WatchPoint>& list, std::vector<FreezeResult>& result) const; 48 bool JudgmentResult(const WatchPoint& watchPoint, 49 const std::vector<WatchPoint>& list, const std::vector<FreezeResult>& result) const; 50 unsigned long startTime_; 51 std::shared_ptr<FreezeCommon> freezeCommon_ = nullptr; 52 std::shared_ptr<FreezeRuleCluster> freezeRuleCluster_ = nullptr; 53 std::unique_ptr<DBHelper> dBHelper_ = nullptr; 54 std::unique_ptr<Vendor> vendor_ = nullptr; 55 }; 56 } // namespace HiviewDFX 57 } // namespace OHOS 58 #endif // FREEZE_DETECTOR_RESOLVER_H 59