• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_WATCHER_APP_EVENT_WATCHER_H
16 #define HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_WATCHER_APP_EVENT_WATCHER_H
17 
18 #include <map>
19 #include <mutex>
20 #include <string>
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 struct TriggerCondition {
25     int row;
26     int size;
27     int timeOut;
28 };
29 
30 class AppEventWatcher {
31 public:
32     AppEventWatcher(const std::string& name, const std::map<std::string, unsigned int>& filters,
33         TriggerCondition cond);
~AppEventWatcher()34     virtual ~AppEventWatcher() {}
35     virtual void OnTrigger(int row, int size);
36     std::string GetName() const;
37     TriggerCondition GetCond() const;
38     void ProcessEvent(const std::string& domain, int type, const std::string& event);
39     void ProcessTimeOut();
40 
41 private:
42     bool IsInterestedEvent(const std::string& domain, int type);
43     void ResetStatus();
44 
45 private:
46     std::string name_;
47     std::map<std::string, unsigned int> filters_;
48     TriggerCondition cond_;
49     TriggerCondition status_;
50     std::mutex mutex_;
51 };
52 } // namespace HiviewDFX
53 } // namespace OHOS
54 #endif // HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_WATCHER_APP_EVENT_WATCHER_H
55