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