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 /** @return current download progress while the item is downloaded. | |
gone
2017/02/09 23:56:57
If it doesn't fit on one line, /** sits on a line
Dmitry Titov
2017/02/10 02:04:39
Done.
| |
49 Returns 0 if the item is not currently downloading. */ | |
50 public long getDownloadProgressBytes() { | |
51 if (mDownloadState != DownloadState.IN_PROGRESS) return 0; | |
52 return mDownloadProgressBytes; | |
53 } | |
54 | |
37 /** @return Title of the page. */ | 55 /** @return Title of the page. */ |
38 public String getTitle() { | 56 public String getTitle() { |
39 return mTitle; | 57 return mTitle; |
40 } | 58 } |
41 | 59 |
42 /** @return Path to the offline item on the disk. */ | 60 /** @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 | 61 // TODO(fgorski): Title would be more meaningful to show in the Download UI, where the local |
44 // path is shown right now. | 62 // path is shown right now. |
45 public String getTargetPath() { | 63 public String getTargetPath() { |
46 return mTargetPath; | 64 return mTargetPath; |
47 } | 65 } |
48 | 66 |
49 /** @return Start time of the item, corresponding to when the offline page w as saved. */ | 67 /** @return Start time of the item, corresponding to when the offline page w as saved. */ |
50 public long getStartTimeMs() { | 68 public long getStartTimeMs() { |
51 return mStartTimeMs; | 69 return mStartTimeMs; |
52 } | 70 } |
53 | 71 |
54 /** @return Size of the offline archive in bytes. */ | 72 /** @return Size of the offline archive in bytes. */ |
55 public long getTotalBytes() { | 73 public long getTotalBytes() { |
56 return mTotalBytes; | 74 return mTotalBytes; |
57 } | 75 } |
58 } | 76 } |
OLD | NEW |