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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offline_pages/OfflinePageBridge.java

Issue 1307753002: [Offline pages] Adding capability to free up space used by Offline pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Converting jlongarray to std::vector<int64> Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/offline_pages/OfflinePageBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offline_pages/OfflinePageBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/offline_pages/OfflinePageBridge.java
index 5e62bead7af8c3f6661bb030053807ed5988b7af..f14af35704717b4de9b03dc1375d7f934d62c02e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offline_pages/OfflinePageBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offline_pages/OfflinePageBridge.java
@@ -187,12 +187,39 @@ public final class OfflinePageBridge {
}
/**
+ * Deletes offline pages based on the list of provided bookamrk IDs. Calls the callback
+ * when operation is complete. Requires that the model is already loaded.
+ *
+ * @param bookmarkIds A list of bookmark IDs for which the offline pages will be deleted.
+ * @param callback A callback that will be called once operation is completed.
+ */
+ public void deletePages(List<BookmarkId> bookmarkIds, DeletePageCallback callback) {
+ assert mIsNativeOfflinePageModelLoaded;
+ long[] ids = new long[bookmarkIds.size()];
+ for (int i = 0; i < ids.length; i++) {
+ ids[i] = bookmarkIds.get(i).getId();
+ }
+ nativeDeletePages(mNativeOfflinePageBridge, callback, ids);
+ }
+
+ /**
* Whether or not the underlying offline page model is loaded.
*/
public boolean isOfflinePageModelLoaded() {
return mIsNativeOfflinePageModelLoaded;
}
+ /**
+ * @return Gets a list of pages that will be removed to clean up storage. Requires that the
+ * model is already loaded.
+ */
+ public List<OfflinePageItem> getPagesToCleanUp() {
+ assert mIsNativeOfflinePageModelLoaded;
+ List<OfflinePageItem> result = new ArrayList<OfflinePageItem>();
+ nativeGetPagesToCleanUp(mNativeOfflinePageBridge, result);
+ return result;
+ }
+
@CalledByNative
private void offlinePageModelLoaded() {
mIsNativeOfflinePageModelLoaded = true;
@@ -225,4 +252,8 @@ public final class OfflinePageBridge {
WebContents webContents, long bookmarkId);
private native void nativeDeletePage(long nativeOfflinePageBridge,
DeletePageCallback callback, long bookmarkId);
+ private native void nativeDeletePages(
+ long nativeOfflinePageBridge, DeletePageCallback callback, long[] bookmarkIds);
+ private native void nativeGetPagesToCleanUp(
+ long nativeOfflinePageBridge, List<OfflinePageItem> offlinePages);
}

Powered by Google App Engine
This is Rietveld 408576698