Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: components/offline_pages/core/downloads/download_ui_item.cc

Issue 2631933002: Adding status info to DownloadUIItem and piping it through. (Closed)
Patch Set: fix comment Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/offline_pages/core/downloads/download_ui_item.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/offline_pages/core/downloads/download_ui_item.h" 5 #include "components/offline_pages/core/downloads/download_ui_item.h"
6 6
7 #include "components/offline_pages/core/background/save_page_request.h" 7 #include "components/offline_pages/core/background/save_page_request.h"
8 #include "components/offline_pages/core/offline_page_item.h" 8 #include "components/offline_pages/core/offline_page_item.h"
9 9
10 namespace offline_pages { 10 namespace offline_pages {
11 11
12 DownloadUIItem::DownloadUIItem() : total_bytes(0) {} 12 DownloadUIItem::DownloadUIItem() : download_progress_bytes(0), total_bytes(0) {}
13 13
14 DownloadUIItem::DownloadUIItem(const OfflinePageItem& page) 14 DownloadUIItem::DownloadUIItem(const OfflinePageItem& page)
15 : guid(page.client_id.id), 15 : guid(page.client_id.id),
16 url(page.url), 16 url(page.url),
17 download_state(DownloadState::COMPLETE),
18 download_progress_bytes(0),
17 title(page.title), 19 title(page.title),
18 target_path(page.file_path), 20 target_path(page.file_path),
19 start_time(page.creation_time), 21 start_time(page.creation_time),
20 total_bytes(page.file_size) {} 22 total_bytes(page.file_size) {}
21 23
22 DownloadUIItem::DownloadUIItem(const SavePageRequest& request) 24 DownloadUIItem::DownloadUIItem(const SavePageRequest& request)
23 : guid(request.client_id().id), 25 : guid(request.client_id().id),
24 url(request.url()), 26 url(request.url()),
27 download_progress_bytes(0), // TODO(dimich) Get this from Request.
25 start_time(request.creation_time()), 28 start_time(request.creation_time()),
26 total_bytes(-1L) {} 29 total_bytes(-1L) {
30 switch (request.request_state()) {
31 case SavePageRequest::RequestState::AVAILABLE:
32 download_state = DownloadState::PENDING;
33 break;
34 case SavePageRequest::RequestState::OFFLINING:
35 download_state = DownloadState::IN_PROGRESS;
36 break;
37 case SavePageRequest::RequestState::PAUSED:
38 download_state = DownloadState::PAUSED;
39 break;
40 }
41 // TODO(dimich): Fill in download_progress, add change notifications for it.
42 }
27 43
28 DownloadUIItem::DownloadUIItem(const DownloadUIItem& other) 44 DownloadUIItem::DownloadUIItem(const DownloadUIItem& other)
29 : guid(other.guid), 45 : guid(other.guid),
30 url(other.url), 46 url(other.url),
47 download_state(other.download_state),
48 download_progress_bytes(other.download_progress_bytes),
31 title(other.title), 49 title(other.title),
32 target_path(other.target_path), 50 target_path(other.target_path),
33 start_time(other.start_time), 51 start_time(other.start_time),
34 total_bytes(other.total_bytes) {} 52 total_bytes(other.total_bytes) {}
35 53
36 DownloadUIItem::~DownloadUIItem() {} 54 DownloadUIItem::~DownloadUIItem() {}
37 55
38 } // namespace offline_pages 56 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/core/downloads/download_ui_item.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698