100600bfbSopenharmony_ci/* 200600bfbSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 300600bfbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 400600bfbSopenharmony_ci * you may not use this file except in compliance with the License. 500600bfbSopenharmony_ci * You may obtain a copy of the License at 600600bfbSopenharmony_ci * 700600bfbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 800600bfbSopenharmony_ci * 900600bfbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1000600bfbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1100600bfbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1200600bfbSopenharmony_ci * See the License for the specific language governing permissions and 1300600bfbSopenharmony_ci * limitations under the License. 1400600bfbSopenharmony_ci */ 1500600bfbSopenharmony_ci#ifndef DUMP_CPU_DATA_H 1600600bfbSopenharmony_ci#define DUMP_CPU_DATA_H 1700600bfbSopenharmony_ci#include <string> 1800600bfbSopenharmony_ci#include <vector> 1900600bfbSopenharmony_ci#include "parcel.h" 2000600bfbSopenharmony_ci#include "delayed_sp_singleton.h" 2100600bfbSopenharmony_ci#include "dump_errors.h" 2200600bfbSopenharmony_cinamespace OHOS { 2300600bfbSopenharmony_cinamespace HiviewDFX { 2400600bfbSopenharmony_ci#define RETURN_PARCEL_READ_HELPER_RET(parcel, type, out, failRet) \ 2500600bfbSopenharmony_ci do { \ 2600600bfbSopenharmony_ci bool ret = (parcel).Read##type((out)); \ 2700600bfbSopenharmony_ci if (!ret) { \ 2800600bfbSopenharmony_ci return failRet; \ 2900600bfbSopenharmony_ci } \ 3000600bfbSopenharmony_ci } while (0) 3100600bfbSopenharmony_ci 3200600bfbSopenharmony_ci#define RETURN_PARCEL_WRITE_HELPER_RET(parcel, type, value, failRet) \ 3300600bfbSopenharmony_ci do { \ 3400600bfbSopenharmony_ci bool ret = (parcel).Write##type((value)); \ 3500600bfbSopenharmony_ci if (!ret) { \ 3600600bfbSopenharmony_ci return failRet; \ 3700600bfbSopenharmony_ci } \ 3800600bfbSopenharmony_ci } while (0) 3900600bfbSopenharmony_ci 4000600bfbSopenharmony_ciclass DumpCpuData : public Parcelable { 4100600bfbSopenharmony_cipublic: 4200600bfbSopenharmony_ci using StringCpuMatrix = std::vector<std::vector<std::string>>; 4300600bfbSopenharmony_ci DumpCpuData(); 4400600bfbSopenharmony_ci DumpCpuData(std::string& startTime, std::string& endTime, int cpuUsagePid, StringCpuMatrix dumpCPUDatas); 4500600bfbSopenharmony_ci ~DumpCpuData(); 4600600bfbSopenharmony_ci static DumpCpuData *Unmarshalling(Parcel& parcel); 4700600bfbSopenharmony_ci bool Marshalling(Parcel& parcel) const override; 4800600bfbSopenharmony_ci bool ReadFromParcel(Parcel &parcel); 4900600bfbSopenharmony_ci bool WriteStringMatrix(const std::vector<std::vector<std::string>> &martrixVec, Parcel &data) const; 5000600bfbSopenharmony_ci bool ReadStringMatrix(std::vector<std::vector<std::string>> &martrixVec, Parcel &data); 5100600bfbSopenharmony_cipublic: 5200600bfbSopenharmony_ci std::string startTime_; 5300600bfbSopenharmony_ci std::string endTime_; 5400600bfbSopenharmony_ci int cpuUsagePid_ = -1; 5500600bfbSopenharmony_ci StringCpuMatrix dumpCPUDatas_; 5600600bfbSopenharmony_ciprivate: 5700600bfbSopenharmony_ci friend DumpDelayedSpSingleton<DumpCpuData>; 5800600bfbSopenharmony_ci}; 5900600bfbSopenharmony_ci} // namespace HiviewDFX 6000600bfbSopenharmony_ci} // namespace OHOS 6100600bfbSopenharmony_ci#endif 62