• 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 FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_TRACE_BEHAVIOR_DB_HELPER_H
17 #define FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_TRACE_BEHAVIOR_DB_HELPER_H
18 
19 #include "rdb_store.h"
20 
21 namespace OHOS::HiviewDFX {
22 enum BEHAVOIR_ID {
23     CACHE_LOW_MEM = 0,
24 };
25 
26 struct BehaviorRecord {
27     int32_t behaviorId = 0;
28     std::string dateNum;
29     int32_t usedQuota = 0;
30 };
31 
32 class TraceBehaviorStorage {
33 public:
TraceBehaviorStorage(std::shared_ptr<NativeRdb::RdbStore> dbStore)34     explicit TraceBehaviorStorage(std::shared_ptr<NativeRdb::RdbStore> dbStore) : dbStore_(dbStore) {}
35     ~TraceBehaviorStorage() = default;
36 
37 public:
38     bool GetRecord(BehaviorRecord &behaviorRecord);
39     bool InsertRecord(BehaviorRecord &behaviorRecord);
40     bool UpdateRecord(BehaviorRecord &behaviorRecord);
41 private:
42     std::shared_ptr<NativeRdb::RdbStore> dbStore_;
43 };
44 } // namespace OHOS::HiviewDFX
45 
46 #endif // FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_TRACE_BEHAVIOR_DB_HELPER_H
47