Index: components/offline_pages/core/downloads/download_ui_item.cc |
diff --git a/components/offline_pages/core/downloads/download_ui_item.cc b/components/offline_pages/core/downloads/download_ui_item.cc |
index c5bdef820282100d5ef0eb5204db95f76c19677e..30afd0823ea2b2f9d31c72b73d51d0cc04d86256 100644 |
--- a/components/offline_pages/core/downloads/download_ui_item.cc |
+++ b/components/offline_pages/core/downloads/download_ui_item.cc |
@@ -9,11 +9,13 @@ |
namespace offline_pages { |
-DownloadUIItem::DownloadUIItem() : total_bytes(0) {} |
+DownloadUIItem::DownloadUIItem() : download_progress_bytes(0), total_bytes(0) {} |
DownloadUIItem::DownloadUIItem(const OfflinePageItem& page) |
: guid(page.client_id.id), |
url(page.url), |
+ download_state(DownloadState::COMPLETE), |
+ download_progress_bytes(0), |
title(page.title), |
target_path(page.file_path), |
start_time(page.creation_time), |
@@ -22,12 +24,28 @@ DownloadUIItem::DownloadUIItem(const OfflinePageItem& page) |
DownloadUIItem::DownloadUIItem(const SavePageRequest& request) |
: guid(request.client_id().id), |
url(request.url()), |
+ download_progress_bytes(0), // TODO(dimich) Get this from Request. |
start_time(request.creation_time()), |
- total_bytes(-1L) {} |
+ total_bytes(-1L) { |
+ switch (request.request_state()) { |
+ case SavePageRequest::RequestState::AVAILABLE: |
+ download_state = DownloadState::PENDING; |
+ break; |
+ case SavePageRequest::RequestState::OFFLINING: |
+ download_state = DownloadState::IN_PROGRESS; |
+ break; |
+ case SavePageRequest::RequestState::PAUSED: |
+ download_state = DownloadState::PAUSED; |
+ break; |
+ } |
+ // TODO(dimich): Fill in download_progress, add change notifications for it. |
+} |
DownloadUIItem::DownloadUIItem(const DownloadUIItem& other) |
: guid(other.guid), |
url(other.url), |
+ download_state(other.download_state), |
+ download_progress_bytes(other.download_progress_bytes), |
title(other.title), |
target_path(other.target_path), |
start_time(other.start_time), |