• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HIVIEW_BASE_EVENT_EXPORT_ENGINE_H
17 #define HIVIEW_BASE_EVENT_EXPORT_ENGINE_H
18 
19 #include <memory>
20 #include <mutex>
21 #include <vector>
22 #include <functional>
23 
24 #include "export_base_task.h"
25 #include "export_config_manager.h"
26 #include "export_db_manager.h"
27 
28 namespace OHOS {
29 namespace HiviewDFX {
30 class EventExportEngine {
31 public:
32     static EventExportEngine& GetInstance();
33     static void InitPackId();
34 
35 public:
36     void Start();
37     void Stop();
38     void SetTaskDelayedSecond(int second);
39 
40 private:
41     EventExportEngine() = default;
42     ~EventExportEngine();
43 
44 private:
45     void InitAndRunTasks();
46     void InitAndRunTask(std::shared_ptr<ExportConfig> config);
47 
48 private:
49     bool isTaskRunning_ = false;
50     int delayedSecond_ = 180; // default is 180 seconds
51     std::mutex mgrMutex_;
52 };
53 } // namespace HiviewDFX
54 } // namespace OHOS
55 
56 #endif // HIVIEW_BASE_EVENT_EXPORT_ENGINE_H