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 SQLLITE_PREPAR_CACHE_DATA_H 17 #define SQLLITE_PREPAR_CACHE_DATA_H 18 19 #include <functional> 20 #include <map> 21 #include "sqlite3.h" 22 23 namespace SysTuning { 24 namespace TraceStreamer { 25 constexpr int32_t SEND_CONTINUE = 0; 26 constexpr int32_t SEND_FINISH = 1; 27 class SqllitePreparCacheData { 28 public: 29 using TLVResultCallBack = std::function<void(const char* data, uint32_t len, uint32_t type, int32_t finish)>; 30 using SphQueryCallBack = std::function<void(sqlite3_stmt*, uint32_t, TLVResultCallBack)>; 31 32 public: 33 SqllitePreparCacheData(); 34 SqllitePreparCacheData(const SqllitePreparCacheData&) = delete; 35 SqllitePreparCacheData& operator=(const SqllitePreparCacheData&) = delete; 36 std::map<uint32_t /* type */, SphQueryCallBack> sphQueryFuncMap_; 37 static const uint8_t TYPE_SIZE = sizeof(uint32_t); 38 39 private: 40 void FillAndSendCpuDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 41 void FillAndSendCpuFreqDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 42 void FillAndSendProcessDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 43 void FillAndSendCpuFreqLimitDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 44 void FillAndSendCpuStateDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 45 void FillAndSendProcessMemDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 46 void FillAndSendProcessSoInitDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 47 void FillAndSendProcessStartupDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 48 void FillAndSendClockDataDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 49 void FillAndSendIrqDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 50 void FillAndSendHiSysEventDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 51 void FillAndSendLogDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 52 void FillAndSendVirtualMemDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 53 void FillAndSendFrameDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 54 void FillAndSendFrameAnimationDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 55 void FillAndSendFrameDynamicDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 56 void FillAndSendTrackerDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 57 void FillAndSendAbilityDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 58 void FillAndSendFrameSpacingDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 59 void FillAndSendEnergyDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 60 void FillAndSendEbpfDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 61 void FillAndSendProcessThreadDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 62 void FillAndSendProcessFuncDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 63 void FillAndSendHiperfDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 64 void FillAndSendHiperfCallChartDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 65 void FillAndSendHiperfCallStackDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 66 void FillAndSendProcessJanksFramesDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 67 void FillAndSendProcessJanksActualDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 68 void FillAndSendProcessInputEventDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 69 void FillAndSendHeapFilesDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 70 void FillAndSendCpuProfilerDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 71 void FillAndSendNativeMemoryNormalProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 72 void FillAndSendNativeMemoryStatisticProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 73 void FillAndSendCpuAbilityDataProto(sqlite3_stmt* stmt, uint32_t type, TLVResultCallBack TLVResultCallBack); 74 void FillSphQueryFuncMapPartOne(); 75 void FillSphQueryFuncMapPartTow(); 76 void FillSphQueryFuncMapPartThree(); 77 void FillSphQueryFuncMapPartFour(); 78 void FillSphQueryFuncMapPartFive(); 79 }; 80 } // namespace TraceStreamer 81 } // namespace SysTuning 82 #endif 83