• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OHOS_MEDIA_DFX_REFRESH_MANAGER_H
17 #define OHOS_MEDIA_DFX_REFRESH_MANAGER_H
18 
19 
20 #include <string>
21 #include <vector>
22 #include <mutex>
23 #include <map>
24 #include "medialibrary_command.h"
25 #include "abs_rdb_predicates.h"
26 
27 namespace OHOS {
28 namespace Media::AccurateRefresh {
29 #define EXPORT __attribute__ ((visibility ("default")))
30 
31 class EXPORT DfxRefreshManager {
32 public:
DfxRefreshManager()33     DfxRefreshManager(){};
34     DfxRefreshManager(const std::string &targetBusiness);
35 
36     EXPORT void SetOperationTotalTime(const std::string &tableName);
37     EXPORT void SetOperationStartTime();
38     EXPORT void SetOptEndTimeAndSql(std::string tableName);
39     EXPORT void SetOptEndTimeAndSql(MediaLibraryCommand &cmd);
40     EXPORT void SetOptEndTimeAndSql(const NativeRdb::AbsRdbPredicates &predicates);
41     EXPORT void SetAlbumIdAndOptTime(int32_t albumId, bool isHidden);
42     EXPORT void DfxRefreshReport();
43     EXPORT void SetEndTotalTime();
44     EXPORT void SetEndTime();
45     EXPORT static void QueryStatementReport(
46         const std::string &targetBusiness, int32_t totalCostTime, const std::string &sqlStr);
47     std::string MapToJson(const std::unordered_map<int32_t, int32_t>& map);
48     void SetStartTime();
49     void SetAlbumId(int32_t albumId);
50     void SetAlbumId(std::vector<int> albumIds);
51 
52 private:
53     int64_t startTime_ = 0;
54     std::string sqlStr_;
55     int32_t totalCostTime_ = 0;
56     int64_t OperationStartTime_ = 0;
57     int32_t photoOperationTotalTime_ = 0;
58     int32_t albumOperationTotalTime_ = 0;
59     std::unordered_set<int32_t> albumIds_;
60     std::string targetBusiness_;
61     std::unordered_map<int32_t, int32_t> albumOperationTime_;
62     std::unordered_map<int32_t, int32_t> albumHiddenInfoOperationTime_;
63     int64_t endTime_ = 0;
64     bool isReport_ = false;
65     bool isPrintLog_ = false;
66 };
67 
68 } // namespace Media
69 } // namespace OHOS
70 
71 #endif
72