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 REQUEST_RUN_COUNT_OBSERVER_H 17 #define REQUEST_RUN_COUNT_OBSERVER_H 18 #include <cstdint> 19 #include <functional> 20 21 namespace OHOS::Request { 22 class RunCountObserver { 23 public: 24 ~RunCountObserver(); 25 using RegCallBack = std::function<void(int32_t uid, int32_t state, int32_t pid)>; 26 static RunCountObserver &GetInstance(); 27 bool RegisterRunCountChanged(RegCallBack &&callback); 28 29 public: 30 RunCountObserver(); 31 RegCallBack callback_ = nullptr; 32 }; 33 } // namespace OHOS::Request 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 typedef void (*RunCountCallback)(int32_t); 40 void RegisterRunCountCallback(RunCountCallback fun); 41 42 #ifdef __cplusplus 43 } 44 #endif 45 46 #endif // REQUEST_RUN_COUNT_OBSERVER_H