1 /* 2 * Copyright (C) 2024 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 OHOS_MEDIA_DFX_COLLECTOR_H 17 #define OHOS_MEDIA_DFX_COLLECTOR_H 18 19 #include <map> 20 #include <mutex> 21 #include <string> 22 23 #include "dfx_const.h" 24 25 namespace OHOS { 26 namespace Media { 27 class DfxCollector { 28 public: 29 DfxCollector(); 30 ~DfxCollector(); 31 void CollectThumbnailError(const std::string &path, int32_t method, int32_t errorCode); 32 std::unordered_map<std::string, ThumbnailErrorInfo> GetThumbnailError(); 33 std::unordered_map<std::string, CommonBehavior> GetCommonBehavior(); 34 void AddCommonBahavior(std::string bundleName, int32_t type); 35 void CollectDeleteBehavior(std::string bundleName, int32_t type, int32_t size); 36 std::unordered_map<std::string, int32_t> GetDeleteBehavior(int32_t type); 37 void CollectAdaptationToMovingPhotoInfo(const std::string &appName, bool adapted); 38 AdaptationToMovingPhotoInfo GetAdaptationToMovingPhotoInfo(); 39 40 private: 41 std::mutex thumbnailErrorLock_; 42 std::mutex commonBehaviorLock_; 43 std::mutex deleteToTrashLock_; 44 std::mutex deleteFromDiskLock_; 45 std::mutex removeLock_; 46 std::mutex adaptationToMovingPhotoLock_; 47 std::unordered_map<std::string, ThumbnailErrorInfo> thumbnailErrorMap_; 48 std::unordered_map<std::string, CommonBehavior> commonBehaviorMap_; 49 std::unordered_map<std::string, int32_t> deleteToTrashMap_; 50 std::unordered_map<std::string, int32_t> deleteFromDiskMap_; 51 std::unordered_map<std::string, int32_t> removeMap_; 52 AdaptationToMovingPhotoInfo adaptationToMovingPhotoInfo_; 53 }; 54 } // namespace Media 55 } // namespace OHOS 56 57 #endif // OHOS_MEDIA_DFX_COLLECTOR_H