| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.components.offline_items_collection; | |
| 6 | |
| 7 import org.chromium.base.annotations.CalledByNative; | |
| 8 import org.chromium.base.annotations.JNINamespace; | |
| 9 | |
| 10 import java.util.ArrayList; | |
| 11 | |
| 12 /** | |
| 13 * The Java counterpart to the C++ class OfflineItemBridge | |
| 14 * (components/offline_items_collection/core/android/offline_item_bridge.h). Th
is class has no | |
| 15 * public members or methods and is meant as a private factory to build {@link O
fflineItem} | |
| 16 * instances. | |
| 17 */ | |
| 18 @JNINamespace("offline_items_collection::android") | |
| 19 public class OfflineItemBridge { | |
| 20 private OfflineItemBridge() {} | |
| 21 | |
| 22 /** | |
| 23 * This is a helper method to allow C++ to create an {@link ArrayList} to ad
d | |
| 24 * {@link OfflineItem}s to. | |
| 25 * @return An {@link ArrayList} for {@link OfflineItem}s. | |
| 26 */ | |
| 27 @CalledByNative | |
| 28 private static ArrayList<OfflineItem> createArrayList() { | |
| 29 return new ArrayList<OfflineItem>(); | |
| 30 } | |
| 31 | |
| 32 /** | |
| 33 * Creates an {@link OfflineItem} from the passed in parameters. See {@link
OfflineItem} for a | |
| 34 * list of the members that will be populated. If {@code list} isn't {@code
null}, the newly | |
| 35 * created {@link OfflineItem} will be added to it. | |
| 36 * @param list An {@link ArrayList} to optionally add the newly created {@li
nk OfflineItem} to. | |
| 37 * @return The newly created {@link OfflineItem} based on the passed in para
meters. | |
| 38 */ | |
| 39 @CalledByNative | |
| 40 private static OfflineItem createOfflineItemAndMaybeAddToList(ArrayList<Offl
ineItem> list, | |
| 41 String nameSpace, String id, String title, String description, | |
| 42 @OfflineItemFilter int filter, boolean isTransient, long totalSizeBy
tes, | |
| 43 boolean externallyRemoved, long creationTimeMs, long lastAccessedTim
eMs, | |
| 44 boolean isOpenable, String pageUrl, String originalUrl, boolean isOf
fTheRecord, | |
| 45 @OfflineItemState int state, boolean isResumable, boolean allowMeter
ed, | |
| 46 long receivedBytes, int percentCompleted, long timeRemainingMs) { | |
| 47 OfflineItem item = new OfflineItem(); | |
| 48 item.id.namespace = nameSpace; | |
| 49 item.id.id = id; | |
| 50 item.title = title; | |
| 51 item.description = description; | |
| 52 item.filter = filter; | |
| 53 item.isTransient = isTransient; | |
| 54 item.totalSizeBytes = totalSizeBytes; | |
| 55 item.externallyRemoved = externallyRemoved; | |
| 56 item.creationTimeMs = creationTimeMs; | |
| 57 item.lastAccessedTimeMs = lastAccessedTimeMs; | |
| 58 item.isOpenable = isOpenable; | |
| 59 item.pageUrl = pageUrl; | |
| 60 item.originalUrl = originalUrl; | |
| 61 item.isOffTheRecord = isOffTheRecord; | |
| 62 item.state = state; | |
| 63 item.isResumable = isResumable; | |
| 64 item.allowMetered = allowMetered; | |
| 65 item.receivedBytes = receivedBytes; | |
| 66 item.percentCompleted = percentCompleted; | |
| 67 item.timeRemainingMs = timeRemainingMs; | |
| 68 | |
| 69 if (list != null) list.add(item); | |
| 70 return item; | |
| 71 } | |
| 72 } | |
| OLD | NEW |