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 package org.chromium.chrome.browser.offlinepages.downloads; | 5 package org.chromium.chrome.browser.offlinepages.downloads; |
6 | 6 |
| 7 import org.chromium.components.offlinepages.downloads.DownloadState; |
| 8 |
7 /** Class representing offline page or save page request to downloads UI. */ | 9 /** Class representing offline page or save page request to downloads UI. */ |
8 public class OfflinePageDownloadItem { | 10 public class OfflinePageDownloadItem { |
9 private final String mUrl; | 11 private final String mUrl; |
| 12 private final int mDownloadState; |
| 13 private final long mDownloadProgressBytes; |
10 private final String mTitle; | 14 private final String mTitle; |
11 private final String mGuid; | 15 private final String mGuid; |
12 private final String mTargetPath; | 16 private final String mTargetPath; |
13 private final long mStartTimeMs; | 17 private final long mStartTimeMs; |
14 private final long mTotalBytes; | 18 private final long mTotalBytes; |
15 | 19 |
16 public OfflinePageDownloadItem( | 20 public OfflinePageDownloadItem(String guid, String url, int downloadState, |
17 String guid, String url, String title, String targetPath, | 21 long downloadProgressBytes, String title, String targetPath, |
18 long startTimeMs, long totalBytes) { | 22 long startTimeMs, long totalBytes) { |
19 mGuid = guid; | 23 mGuid = guid; |
20 mUrl = url; | 24 mUrl = url; |
| 25 mDownloadState = downloadState; |
| 26 mDownloadProgressBytes = downloadProgressBytes; |
21 mTitle = title; | 27 mTitle = title; |
22 mTargetPath = targetPath; | 28 mTargetPath = targetPath; |
23 mStartTimeMs = startTimeMs; | 29 mStartTimeMs = startTimeMs; |
24 mTotalBytes = totalBytes; | 30 mTotalBytes = totalBytes; |
25 } | 31 } |
26 | 32 |
27 /** @return GUID identifying the item. */ | 33 /** @return GUID identifying the item. */ |
28 public String getGuid() { | 34 public String getGuid() { |
29 return mGuid; | 35 return mGuid; |
30 } | 36 } |
31 | 37 |
32 /** @return URL related to the item. */ | 38 /** @return URL related to the item. */ |
33 public String getUrl() { | 39 public String getUrl() { |
34 return mUrl; | 40 return mUrl; |
35 } | 41 } |
36 | 42 |
| 43 /** @return DownloadState value. */ |
| 44 public int getDownloadState() { |
| 45 return mDownloadState; |
| 46 } |
| 47 |
| 48 /** |
| 49 * @return current download progress while the item is downloaded. |
| 50 * Returns 0 if the item is not currently downloading. |
| 51 */ |
| 52 public long getDownloadProgressBytes() { |
| 53 if (mDownloadState != DownloadState.IN_PROGRESS) return 0; |
| 54 return mDownloadProgressBytes; |
| 55 } |
| 56 |
37 /** @return Title of the page. */ | 57 /** @return Title of the page. */ |
38 public String getTitle() { | 58 public String getTitle() { |
39 return mTitle; | 59 return mTitle; |
40 } | 60 } |
41 | 61 |
42 /** @return Path to the offline item on the disk. */ | 62 /** @return Path to the offline item on the disk. */ |
43 // TODO(fgorski): Title would be more meaningful to show in the Download UI,
where the local | 63 // TODO(fgorski): Title would be more meaningful to show in the Download UI,
where the local |
44 // path is shown right now. | 64 // path is shown right now. |
45 public String getTargetPath() { | 65 public String getTargetPath() { |
46 return mTargetPath; | 66 return mTargetPath; |
47 } | 67 } |
48 | 68 |
49 /** @return Start time of the item, corresponding to when the offline page w
as saved. */ | 69 /** @return Start time of the item, corresponding to when the offline page w
as saved. */ |
50 public long getStartTimeMs() { | 70 public long getStartTimeMs() { |
51 return mStartTimeMs; | 71 return mStartTimeMs; |
52 } | 72 } |
53 | 73 |
54 /** @return Size of the offline archive in bytes. */ | 74 /** @return Size of the offline archive in bytes. */ |
55 public long getTotalBytes() { | 75 public long getTotalBytes() { |
56 return mTotalBytes; | 76 return mTotalBytes; |
57 } | 77 } |
58 } | 78 } |
OLD | NEW |