OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_DOWNLOADS_DOWNLOAD_UI_ITEM_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_DOWNLOADS_DOWNLOAD_UI_ITEM_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_CORE_DOWNLOADS_DOWNLOAD_UI_ITEM_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CORE_DOWNLOADS_DOWNLOAD_UI_ITEM_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 namespace offline_pages { | 16 namespace offline_pages { |
17 | 17 |
18 struct OfflinePageItem; | 18 struct OfflinePageItem; |
19 class SavePageRequest; | 19 class SavePageRequest; |
20 | 20 |
21 // The abstract "download item" that may be a media file, a web page (together | |
22 // with all the resources) or a PWA web package. This is a data bag that exposes | |
23 // only bits potentially visible by the user, not the internal data. | |
21 struct DownloadUIItem { | 24 struct DownloadUIItem { |
22 public: | 25 public: |
26 // All Items start from PENDING and terminate at COMPLETED or are removed. | |
27 // In sync with state values in Java OfflinePageDownloadItem class. | |
28 enum DownloadState { | |
fgorski
2017/01/20 17:03:02
Please, put this line above:
// GENERATED_JAVA_ENU
Dmitry Titov
2017/01/27 04:26:24
Nice advice, thanks!
| |
29 PENDING = 0, | |
30 DOWNLOADING = 1, | |
31 PAUSED = 2, | |
32 COMPLETED = 3, | |
33 }; | |
34 | |
35 // The abstract notion of download progress. The |current| is always less | |
fgorski
2017/01/20 17:03:02
less or "less or equal" ?
Dmitry Titov
2017/01/27 04:26:25
Removed the whole concept of current/max progress,
| |
36 // than |max|, the download 'percentage' at any moment is current/max. | |
37 // Note the |max| can change over time, as more resources are discovered from | |
38 // the bytes already loaded (which is often happening when a web page is | |
39 // loaded and more resources are found in the markup). | |
40 // Typical implementation would use the byte count loaded (current) and total | |
41 // of Content-Size: headers of resources that are already known to be part of | |
42 // the page (or approximation if there is no exact data yet). | |
43 struct DownloadProgress { | |
44 DownloadProgress(int64_t current, int64_t max) | |
45 : current(current), | |
46 max(max) {} | |
47 | |
48 int64_t current; | |
dewittj
2017/01/18 19:24:07
s/current/current_bytes/ (or whatever unit it repr
Dmitry Titov
2017/01/27 04:26:24
Done. Replaced with just byte counter.
| |
49 int64_t max; | |
50 }; | |
51 | |
23 DownloadUIItem(); | 52 DownloadUIItem(); |
24 explicit DownloadUIItem(const OfflinePageItem& page); | 53 explicit DownloadUIItem(const OfflinePageItem& page); |
25 explicit DownloadUIItem(const SavePageRequest& request); | 54 explicit DownloadUIItem(const SavePageRequest& request); |
26 DownloadUIItem(const DownloadUIItem& other); | 55 DownloadUIItem(const DownloadUIItem& other); |
27 ~DownloadUIItem(); | 56 ~DownloadUIItem(); |
28 | 57 |
29 // Unique id. | 58 // Unique id. Not necesarily a GUID, may be any string unique in the Chrome |
59 // instance across all DownloadUIItem providers. | |
dewittj
2017/01/18 19:24:07
I'm not sure across all providers is a requirement
Dmitry Titov
2017/01/27 04:26:25
Right, it is not. I believe we always keep a bit "
| |
30 std::string guid; | 60 std::string guid; |
dewittj
2017/01/18 19:24:07
nit: can we rename guid?
Dmitry Titov
2017/01/27 04:26:25
Looks like a separate CL... That CL can also start
| |
31 | 61 |
32 // The URL of the captured page. | 62 // The URL of the captured page. |
33 GURL url; | 63 GURL url; |
34 | 64 |
65 DownloadState download_state; | |
66 | |
67 DownloadProgress download_progress; | |
68 | |
35 // The Title of the captured page, if any. It can be empty string either | 69 // The Title of the captured page, if any. It can be empty string either |
36 // because the page is not yet fully loaded, or because it doesn't have any. | 70 // because the page is not yet fully loaded, or because it doesn't have any. |
37 base::string16 title; | 71 base::string16 title; |
38 | 72 |
39 // The file path to the archive with a local copy of the page. | 73 // The file path to the archive with a local copy of the page. |
40 base::FilePath target_path; | 74 base::FilePath target_path; |
41 | 75 |
42 // The time when the offline archive was created. | 76 // The time when the offline archive was created. |
43 base::Time start_time; | 77 base::Time start_time; |
44 | 78 |
45 // The size of the offline copy. | 79 // The size of the offline copy. |
46 int64_t total_bytes; | 80 int64_t total_bytes; |
47 }; | 81 }; |
48 | 82 |
49 } // namespace offline_pages | 83 } // namespace offline_pages |
50 | 84 |
51 #endif // COMPONENTS_OFFLINE_PAGES_CORE_DOWNLOADS_DOWNLOAD_UI_ITEM_H_ | 85 #endif // COMPONENTS_OFFLINE_PAGES_CORE_DOWNLOADS_DOWNLOAD_UI_ITEM_H_ |
OLD | NEW |