• 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_NWEB_ANI_WEB_DOWNLOAD_ITEM_H
17 #define OHOS_NWEB_ANI_WEB_DOWNLOAD_ITEM_H
18 
19 #include <string>
20 #include <ani.h>
21 
22 #include "nweb_c_api.h"
23 
24 namespace OHOS {
25 namespace NWeb {
26 class WebDownloadItem {
27 public:
28     explicit WebDownloadItem(ani_env* env);
29     WebDownloadItem(ani_env* env, NWebDownloadItem *downloadItem);
30     ~WebDownloadItem();
31 
32     long webDownloadId;
33     int32_t currentSpeed;
34     int32_t percentComplete;
35     int64_t totalBytes;
36     int64_t receivedBytes;
37     int32_t lastErrorCode;
38 
39     std::string guid;
40     std::string fullPath;
41     std::string url;
42     std::string etag;
43     std::string originalUrl;
44     std::string suggestedFileName;
45     std::string contentDisposition;
46     std::string mimeType;
47     std::string lastModified;
48 
49     NWebDownloadItemState state = NWebDownloadItemState::MAX_DOWNLOAD_STATE;
50     std::string method;
51     std::string receivedSlices;
52 
53     std::string downloadPath;
54     WebBeforeDownloadCallbackWrapper *before_download_callback;
55     WebDownloadItemCallbackWrapper *download_item_callback;
56 
57     int32_t nwebId;
58     bool hasStarted{false};
59 
60 private:
61     ani_env* env_;
62 };
63 } // namespace NWeb
64 } // namespace OHOS
65 
66 #endif // OHOS_NWEB_ANI_WEB_DOWNLOAD_ITEM_H
67