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#ifndef APP_LAUNCH_MONITOR_H 16#define APP_LAUNCH_MONITOR_H 17 18#include "DefaultMonitor.h" 19#include "IAppThrExecutor.h" 20#include "IAppLaunchSceneDataProcessor.h" 21#include "MonitorConfig.h" 22#include "IAppStartReporter.h" 23#include "IMonitorRegistry.h" 24 25namespace OHOS { 26namespace HiviewDFX { 27using AppStartMetrics = IAppLaunchSceneDataProcessor::AppStartMetrics; 28 29class AppLaunchMonitor : 30 public DefaultMonitor, 31 public IAppLaunchSceneDataProcessor::MetricReporter, 32 public IAppThrExecutor::IProcessAppEvtTask { 33public: 34 AppLaunchMonitor(IMonitorRegistry* registry, IAppThrExecutor* exec, IAppStartReporter* reporter, 35 IAppLaunchSceneDataProcessor* scene); 36 void HandleEvt(std::shared_ptr<XperfEvt> evt) override; 37 void ReportMetrics(const AppStartMetrics& metrics) override; 38 void ExecuteProcessAppEvtTaskInMainThr(const IAppThrExecutor::AppEvtData& data) override; 39 40private: 41 IAppThrExecutor* exec{nullptr}; 42 IAppLaunchSceneDataProcessor* scene{nullptr}; 43 IAppStartReporter* reporter{nullptr}; 44 IMonitorRegistry* registry{nullptr}; 45 int actionId{0}; 46 AppStartReportEvent ConstructReportEvent(const AppStartMetrics& metrics); 47 void ReportNormal(const AppStartMetrics& metrics); 48}; 49} // HiviewDFX 50} // OHOS 51#endif