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

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: feedback, test compile Created 3 years, 11 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
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()
13 : download_progress(DownloadProgress(1,1)),
14 total_bytes(0) {}
13 15
14 DownloadUIItem::DownloadUIItem(const OfflinePageItem& page) 16 DownloadUIItem::DownloadUIItem(const OfflinePageItem& page)
15 : guid(page.client_id.id), 17 : guid(page.client_id.id),
16 url(page.url), 18 url(page.url),
19 download_state(DownloadState::COMPLETED),
20 download_progress(DownloadProgress(1,1)),
dewittj 2017/01/18 19:24:07 current is 1 byte?
Dmitry Titov 2017/01/27 04:26:24 Done.
17 title(page.title), 21 title(page.title),
18 target_path(page.file_path), 22 target_path(page.file_path),
19 start_time(page.creation_time), 23 start_time(page.creation_time),
20 total_bytes(page.file_size) {} 24 total_bytes(page.file_size) {}
21 25
22 DownloadUIItem::DownloadUIItem(const SavePageRequest& request) 26 DownloadUIItem::DownloadUIItem(const SavePageRequest& request)
23 : guid(request.client_id().id), 27 : guid(request.client_id().id),
24 url(request.url()), 28 url(request.url()),
29 download_progress(DownloadProgress(1,0)),
dewittj 2017/01/18 19:24:07 current > max?
Dmitry Titov 2017/01/27 04:26:24 Done.
25 start_time(request.creation_time()), 30 start_time(request.creation_time()),
26 total_bytes(-1L) {} 31 total_bytes(-1L) {
32 switch (request.request_state()) {
33 case SavePageRequest::RequestState::AVAILABLE:
34 download_state = DownloadState::PENDING;
35 break;
36 case SavePageRequest::RequestState::OFFLINING:
37 download_state = DownloadState::DOWNLOADING;
38 break;
39 case SavePageRequest::RequestState::PAUSED:
40 download_state = DownloadState::PAUSED;
41 break;
42 }
43 // TODO(dimich): Fill in download_progress, add change notifications for it.
44 }
27 45
28 DownloadUIItem::DownloadUIItem(const DownloadUIItem& other) 46 DownloadUIItem::DownloadUIItem(const DownloadUIItem& other)
29 : guid(other.guid), 47 : guid(other.guid),
30 url(other.url), 48 url(other.url),
49 download_state(other.download_state),
50 download_progress(other.download_progress),
31 title(other.title), 51 title(other.title),
32 target_path(other.target_path), 52 target_path(other.target_path),
33 start_time(other.start_time), 53 start_time(other.start_time),
34 total_bytes(other.total_bytes) {} 54 total_bytes(other.total_bytes) {}
35 55
36 DownloadUIItem::~DownloadUIItem() {} 56 DownloadUIItem::~DownloadUIItem() {}
37 57
38 } // namespace offline_pages 58 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698