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 FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_APP_EVENT_TASK_STORAGE_H 17 #define FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_APP_EVENT_TASK_STORAGE_H 18 19 #include <cstdint> 20 #include <memory> 21 #include <string> 22 23 #include "rdb_store.h" 24 25 namespace OHOS { 26 namespace HiviewDFX { 27 constexpr int8_t APP_EVENT_TASK_TYPE_JANK_EVENT = 1; 28 constexpr int8_t APP_EVENT_TASK_STATE_FINISH = 2; 29 30 struct AppEventTask { 31 int64_t id_; 32 int64_t taskDate_; 33 int32_t taskType_; 34 int32_t uid_; 35 int32_t pid_; 36 std::string bundleName_; 37 std::string bundleVersion_; 38 int64_t startTime_; 39 int64_t finishTime_; 40 std::string resourePath_; 41 int32_t resourceSize_; 42 double costCpu_; 43 int32_t state_; 44 }; 45 46 class AppEventTaskStorage { 47 public: 48 AppEventTaskStorage(std::shared_ptr<NativeRdb::RdbStore> dbStore); 49 ~AppEventTaskStorage() = default; 50 51 public: 52 bool InitAppTask(); 53 bool GetAppEventTask(int32_t uid, int32_t eventDate, AppEventTask &appEventTask); 54 bool InsertAppEventTask(AppEventTask &appEventTask); 55 void RemoveAppEventTask(int32_t eventDate); 56 private: 57 std::shared_ptr<NativeRdb::RdbStore> dbStore_; 58 }; 59 } // namespace HiviewDFX 60 } // namespace OHOS 61 #endif // FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_APP_EVENT_TASK_STORAGE_H 62