• 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 
16 #ifndef WEB_DOWNLOAD_DELEGATE_IMPL_H
17 #define WEB_DOWNLOAD_DELEGATE_IMPL_H
18 
19 #include "ffi_remote_data.h"
20 #include "web_download_item_impl.h"
21 #include "web_errors.h"
22 
23 namespace OHOS::Webview {
24     class __attribute__((visibility("default"))) WebDownloadDelegateImpl : public OHOS::FFI::FFIData {
25         DECL_TYPE(WebDownloadDelegateImpl, OHOS::FFI::FFIData)
26     public:
27         explicit WebDownloadDelegateImpl();
28         ~WebDownloadDelegateImpl();
29 
30         void DownloadBeforeStart(WebDownloadItemImpl *webDownloadItemImpl);
31         void DownloadDidUpdate(WebDownloadItemImpl *webDownloadItemImpl);
32         void DownloadDidFail(WebDownloadItemImpl *webDownloadItemImpl);
33         void DownloadDidFinish(WebDownloadItemImpl *webDownloadItemImpl);
34 
35         void PutDownloadBeforeStart(std::function<void(int64_t)> callback);
36         void PutDownloadDidUpdate(std::function<void(int64_t)> callback);
37         void PutDownloadDidFinish(std::function<void(int64_t)> callback);
38         void PutDownloadDidFail(std::function<void(int64_t)> callback);
39 
40         int32_t GetNWebId();
41         void SetNWebId(int32_t nwebId);
42 
43     private:
44         int32_t nwebId_ = -1;
45 
46         std::function<void(int64_t)> download_before_start_callback_;
47         std::function<void(int64_t)> download_did_update_callback_;
48         std::function<void(int64_t)> download_did_finish_callback_;
49         std::function<void(int64_t)> download_did_fail_callback_;
50     };
51 }
52 #endif // WEB_DOWNLOAD_DELEGATE_IMPL_H