OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.components.offline_items_collection.bridges; | 5 package org.chromium.components.offline_items_collection.bridges; |
6 | 6 |
7 import org.chromium.base.annotations.CalledByNative; | 7 import org.chromium.base.annotations.CalledByNative; |
8 import org.chromium.base.annotations.JNINamespace; | 8 import org.chromium.base.annotations.JNINamespace; |
9 import org.chromium.components.offline_items_collection.OfflineItem; | 9 import org.chromium.components.offline_items_collection.OfflineItem; |
10 import org.chromium.components.offline_items_collection.OfflineItemFilter; | 10 import org.chromium.components.offline_items_collection.OfflineItemFilter; |
| 11 import org.chromium.components.offline_items_collection.OfflineItemProgressUnit; |
11 import org.chromium.components.offline_items_collection.OfflineItemState; | 12 import org.chromium.components.offline_items_collection.OfflineItemState; |
12 | 13 |
13 import java.util.ArrayList; | 14 import java.util.ArrayList; |
14 | 15 |
15 /** | 16 /** |
16 * The Java counterpart to the C++ class OfflineItemBridge | 17 * The Java counterpart to the C++ class OfflineItemBridge |
17 * (components/offline_items_collection/core/android/offline_item_bridge.h). Th
is class has no | 18 * (components/offline_items_collection/core/android/offline_item_bridge.h). Th
is class has no |
18 * public members or methods and is meant as a private factory to build {@link O
fflineItem} | 19 * public members or methods and is meant as a private factory to build {@link O
fflineItem} |
19 * instances. | 20 * instances. |
20 */ | 21 */ |
(...skipping 18 matching lines...) Expand all Loading... |
39 * @param list An {@link ArrayList} to optionally add the newly created {@li
nk OfflineItem} to. | 40 * @param list An {@link ArrayList} to optionally add the newly created {@li
nk OfflineItem} to. |
40 * @return The newly created {@link OfflineItem} based on the passed in para
meters. | 41 * @return The newly created {@link OfflineItem} based on the passed in para
meters. |
41 */ | 42 */ |
42 @CalledByNative | 43 @CalledByNative |
43 private static OfflineItem createOfflineItemAndMaybeAddToList(ArrayList<Offl
ineItem> list, | 44 private static OfflineItem createOfflineItemAndMaybeAddToList(ArrayList<Offl
ineItem> list, |
44 String nameSpace, String id, String title, String description, | 45 String nameSpace, String id, String title, String description, |
45 @OfflineItemFilter int filter, boolean isTransient, long totalSizeBy
tes, | 46 @OfflineItemFilter int filter, boolean isTransient, long totalSizeBy
tes, |
46 boolean externallyRemoved, long creationTimeMs, long lastAccessedTim
eMs, | 47 boolean externallyRemoved, long creationTimeMs, long lastAccessedTim
eMs, |
47 boolean isOpenable, String pageUrl, String originalUrl, boolean isOf
fTheRecord, | 48 boolean isOpenable, String pageUrl, String originalUrl, boolean isOf
fTheRecord, |
48 @OfflineItemState int state, boolean isResumable, boolean allowMeter
ed, | 49 @OfflineItemState int state, boolean isResumable, boolean allowMeter
ed, |
49 long receivedBytes, int percentCompleted, long timeRemainingMs) { | 50 long receivedBytes, long progressValue, long progressMax, |
| 51 @OfflineItemProgressUnit int progressUnit, long timeRemainingMs) { |
50 OfflineItem item = new OfflineItem(); | 52 OfflineItem item = new OfflineItem(); |
51 item.id.namespace = nameSpace; | 53 item.id.namespace = nameSpace; |
52 item.id.id = id; | 54 item.id.id = id; |
53 item.title = title; | 55 item.title = title; |
54 item.description = description; | 56 item.description = description; |
55 item.filter = filter; | 57 item.filter = filter; |
56 item.isTransient = isTransient; | 58 item.isTransient = isTransient; |
57 item.totalSizeBytes = totalSizeBytes; | 59 item.totalSizeBytes = totalSizeBytes; |
58 item.externallyRemoved = externallyRemoved; | 60 item.externallyRemoved = externallyRemoved; |
59 item.creationTimeMs = creationTimeMs; | 61 item.creationTimeMs = creationTimeMs; |
60 item.lastAccessedTimeMs = lastAccessedTimeMs; | 62 item.lastAccessedTimeMs = lastAccessedTimeMs; |
61 item.isOpenable = isOpenable; | 63 item.isOpenable = isOpenable; |
62 item.pageUrl = pageUrl; | 64 item.pageUrl = pageUrl; |
63 item.originalUrl = originalUrl; | 65 item.originalUrl = originalUrl; |
64 item.isOffTheRecord = isOffTheRecord; | 66 item.isOffTheRecord = isOffTheRecord; |
65 item.state = state; | 67 item.state = state; |
66 item.isResumable = isResumable; | 68 item.isResumable = isResumable; |
67 item.allowMetered = allowMetered; | 69 item.allowMetered = allowMetered; |
68 item.receivedBytes = receivedBytes; | 70 item.receivedBytes = receivedBytes; |
69 item.percentCompleted = percentCompleted; | 71 item.progress = new OfflineItem.Progress( |
| 72 progressValue, progressMax == -1 ? null : progressMax, progressU
nit); |
70 item.timeRemainingMs = timeRemainingMs; | 73 item.timeRemainingMs = timeRemainingMs; |
71 | 74 |
72 if (list != null) list.add(item); | 75 if (list != null) list.add(item); |
73 return item; | 76 return item; |
74 } | 77 } |
75 } | 78 } |
OLD | NEW |