• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 OHOS_FILEMGMT_DOWNGRADE_PROGRESS_NAPI_H
17 #define OHOS_FILEMGMT_DOWNGRADE_PROGRESS_NAPI_H
18 
19 #include <memory>
20 #include <unordered_map>
21 #include <unordered_set>
22 
23 #include "cloud_sync_common.h"
24 #include "filemgmt_libn.h"
25 
26 namespace OHOS::FileManagement::CloudSync {
27 class DowngradeProgressNapi final : public LibN::NExporter {
28 public:
DowngradeProgressNapi(napi_env env,napi_value exports)29     DowngradeProgressNapi(napi_env env, napi_value exports) : NExporter(env, exports) {}
30     ~DowngradeProgressNapi() = default;
31 
32     bool Export() override;
33     std::string GetClassName() override;
34     static napi_value Constructor(napi_env env, napi_callback_info info);
35     static napi_value GetState(napi_env env, napi_callback_info info);
36     static napi_value GetSuccessfulCount(napi_env env, napi_callback_info info);
37     static napi_value GetFailedCount(napi_env env, napi_callback_info info);
38     static napi_value GetTotalCount(napi_env env, napi_callback_info info);
39     static napi_value GetDownloadedSize(napi_env env, napi_callback_info info);
40     static napi_value GetTotalSize(napi_env env, napi_callback_info info);
41     static napi_value GetStopReason(napi_env env, napi_callback_info info);
42 
43     inline static const std::string className_ = "DownloadProgress";
44 };
45 
46 struct SingleBundleProgress {
47     int32_t state{0};
48     int32_t successfulCount{0};
49     int32_t failedCount{0};
50     int64_t downloadedSize{0};
51     int64_t totalSize{0};
52     int32_t totalCount{0};
53     int32_t stopReason{0};
54 };
55 
56 struct DowngradeProgressEntity {
57     std::shared_ptr<SingleBundleProgress> progress;
58 };
59 } // namespace OHOS::FileManagement::CloudSync
60 #endif // OHOS_FILEMGMT_DOWNGRADE_PROGRESS_NAPI_H