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 OHOS_MEDIA_BACKUP_UPGRADE_RESTORE_TASK_REPORT_H
16 #define OHOS_MEDIA_BACKUP_UPGRADE_RESTORE_TASK_REPORT_H
17 
18 #include <string>
19 #include <vector>
20 
21 #include "media_backup_report_data_type.h"
22 
23 namespace OHOS::Media {
24 class UpgradeRestoreTaskReport {
25 public:
SetSceneCode(int32_t sceneCode)26     UpgradeRestoreTaskReport &SetSceneCode(int32_t sceneCode)
27     {
28         this->sceneCode_ = sceneCode;
29         return *this;
30     }
SetTaskId(const std::string & taskId)31     UpgradeRestoreTaskReport &SetTaskId(const std::string &taskId)
32     {
33         this->taskId_ = taskId;
34         return *this;
35     }
36     UpgradeRestoreTaskReport &ReportTask(const std::string &taskInfo);
37     UpgradeRestoreTaskReport &Report(const std::string &type, const std::string &errorCode,
38         const std::string &errorInfo);
39     UpgradeRestoreTaskReport &ReportError(const ErrorInfo &info);
40     UpgradeRestoreTaskReport &ReportProgress(const std::string &status, const std::string &progressInfo);
41     UpgradeRestoreTaskReport &ReportProgress(const std::string &status, const std::string &progressInfo,
42         uint64_t ongoingTotalNumber);
43     UpgradeRestoreTaskReport &ReportTimeout(uint64_t ongoingTotalNumber);
44     UpgradeRestoreTaskReport &ReportTotal(const std::string &errorCode, const std::string &totalInfo);
45     UpgradeRestoreTaskReport &ReportTimeCost();
46 
47 private:
48     int32_t PostInfoDfx(const MediaRestoreResultInfo &info);
49     int32_t PostInfoAuditLog(const MediaRestoreResultInfo &info);
50     int32_t PostErrorInfoAuditLog(const ErrorInfo &info);
51     int32_t PostProgressInfoAuditLog(const std::string &status, const std::string &progressInfo);
52 
53 private:
54     int32_t sceneCode_;
55     std::string taskId_;
56 };
57 }  // namespace OHOS::Media
58 #endif  // OHOS_MEDIA_BACKUP_UPGRADE_RESTORE_TASK_REPORT_H