• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef HI_APP_EVENT_CONFIG_H
16 #define HI_APP_EVENT_CONFIG_H
17 
18 #include <string>
19 
20 #include "nocopyable.h"
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 class HiAppEventConfig : public NoCopyable {
25 public:
26     static HiAppEventConfig& GetInstance();
27     void SetStorageDir(const std::string& dir);
28     bool SetConfigurationItem(std::string name, std::string value);
29     bool GetDisable();
30     uint64_t GetMaxStorageSize();
31     std::string GetStorageDir();
32     std::string GetRunningId();
33     bool IsFreeSizeOverLimit();
34     void RefreshFreeSize();
35 
36 private:
HiAppEventConfig()37     HiAppEventConfig() {}
~HiAppEventConfig()38     ~HiAppEventConfig() {}
39     HiAppEventConfig(const HiAppEventConfig&);
40     HiAppEventConfig& operator=(const HiAppEventConfig&);
41     bool SetDisableItem(const std::string& value);
42     bool SetMaxStorageSizeItem(const std::string& value);
43     void SetDisable(bool disable);
44     void SetMaxStorageSize(uint64_t size);
45 
46 private:
47     bool disable_ = false;
48     int64_t freeSize_ = -1;
49     bool isInitFreeSize_ = false;
50     uint64_t maxStorageSize_ = 10 * 1024 * 1024; // max storage size is 10M, 10 * 1024 * 1024 Byte
51     std::string storageDir_ = "";
52     std::string runningId_ = "";
53 };
54 } // namespace HiviewDFX
55 } // namespace OHOS
56 #endif // HI_APP_EVENT_CONFIG_H
57