• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
UpgradeRestoreTaskReport()26     UpgradeRestoreTaskReport() {};
UpgradeRestoreTaskReport(int32_t sceneCode,const std::string & taskId)27     UpgradeRestoreTaskReport(int32_t sceneCode, const std::string &taskId)
28         : sceneCode_(sceneCode), taskId_(taskId)
29     {
30     }
SetSceneCode(int32_t sceneCode)31     UpgradeRestoreTaskReport &SetSceneCode(int32_t sceneCode)
32     {
33         this->sceneCode_ = sceneCode;
34         return *this;
35     }
SetTaskId(const std::string & taskId)36     UpgradeRestoreTaskReport &SetTaskId(const std::string &taskId)
37     {
38         this->taskId_ = taskId;
39         return *this;
40     }
41     UpgradeRestoreTaskReport &ReportTask(const std::string &taskInfo);
42     UpgradeRestoreTaskReport &Report(const std::string &type, const std::string &errorCode,
43         const std::string &errorInfo);
44     UpgradeRestoreTaskReport &Report(const RestoreTaskInfo &taskInfo);
45     UpgradeRestoreTaskReport &ReportInAudit(const std::string &type, const std::string &errorCode,
46         const std::string &errorInfo);
47     UpgradeRestoreTaskReport &ReportError(const ErrorInfo &info);
48     UpgradeRestoreTaskReport &ReportProgress(const std::string &status, const std::string &progressInfo);
49     UpgradeRestoreTaskReport &ReportProgress(const std::string &status, const std::string &progressInfo,
50         uint64_t ongoingTotalNumber);
51     UpgradeRestoreTaskReport &ReportTimeout(uint64_t ongoingTotalNumber);
52     UpgradeRestoreTaskReport &ReportTotal(const std::string &errorCode, const std::string &totalInfo);
53     UpgradeRestoreTaskReport &ReportTimeCost(const uint64_t successCount, const uint64_t duplicateCount,
54         const size_t failCount);
55     UpgradeRestoreTaskReport &ReportUpgradeEnh(const std::string &errorCode, const std::string &info);
56     UpgradeRestoreTaskReport &ReportRestoreMode(int32_t restoreMode, uint64_t notFoundFileNum);
57 
58 private:
59     int32_t PostInfoDfx(const MediaRestoreResultInfo &info);
60     int32_t PostInfoAuditLog(const MediaRestoreResultInfo &info);
61     int32_t PostErrorInfoAuditLog(const ErrorInfo &info);
62     int32_t PostProgressInfoAuditLog(const std::string &status, const std::string &progressInfo);
63 
64 private:
65     int32_t sceneCode_{-1};
66     std::string taskId_{};
67 };
68 }  // namespace OHOS::Media
69 #endif  // OHOS_MEDIA_BACKUP_UPGRADE_RESTORE_TASK_REPORT_H