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 WHITE_BLOCK_MONITOR_H 17 #define WHITE_BLOCK_MONITOR_H 18 19 #include <map> 20 #include <mutex> 21 #include "perf_constants.h" 22 #include "perf_model.h" 23 24 namespace OHOS { 25 namespace HiviewDFX { 26 27 class WhiteBlockMonitor { 28 public: 29 static WhiteBlockMonitor& GetInstance(); 30 31 void StartScroll(); 32 void EndScroll(); 33 void StartRecordImageLoadStat(int64_t id); 34 void EndRecordImageLoadStat(int64_t id, std::pair<int, int> size, const std::string& type, int state); 35 36 private: 37 bool RecordExist(int64_t id); 38 ImageLoadInfo* GetRecord(int64_t id); 39 void ReportWhiteBlockStat(); 40 void CleanUpRecords(); 41 42 private: 43 mutable std::mutex mMutex; 44 uint64_t scrollStartTime{0}; 45 uint64_t scrollEndTime{0}; 46 bool scrolling{false}; 47 std::map<int64_t, ImageLoadInfo*> mRecords; 48 }; 49 50 } 51 } 52 53 #endif // WHITE_BLOCK_MONITOR_H