| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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; | 5 package org.chromium.chrome.browser.offlinepages; |
| 6 | 6 |
| 7 import android.os.AsyncTask; | 7 import android.os.AsyncTask; |
| 8 | 8 |
| 9 import org.chromium.base.ObserverList; | 9 import org.chromium.base.ObserverList; |
| 10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
| 11 import org.chromium.base.annotations.CalledByNative; | 11 import org.chromium.base.annotations.CalledByNative; |
| 12 import org.chromium.base.annotations.JNINamespace; | 12 import org.chromium.base.annotations.JNINamespace; |
| 13 import org.chromium.base.metrics.RecordHistogram; | 13 import org.chromium.base.metrics.RecordHistogram; |
| 14 import org.chromium.chrome.browser.profiles.Profile; | 14 import org.chromium.chrome.browser.profiles.Profile; |
| 15 import org.chromium.components.bookmarks.BookmarkId; | 15 import org.chromium.components.bookmarks.BookmarkId; |
| 16 import org.chromium.components.bookmarks.BookmarkType; | 16 import org.chromium.components.bookmarks.BookmarkType; |
| 17 import org.chromium.components.offlinepages.DeletePageResult; | 17 import org.chromium.components.offlinepages.DeletePageResult; |
| 18 import org.chromium.components.offlinepages.FeatureMode; | 18 import org.chromium.components.offlinepages.FeatureMode; |
| 19 import org.chromium.components.offlinepages.SavePageResult; | 19 import org.chromium.components.offlinepages.SavePageResult; |
| 20 import org.chromium.content_public.browser.WebContents; | 20 import org.chromium.content_public.browser.WebContents; |
| 21 | 21 |
| 22 import java.util.ArrayList; | 22 import java.util.ArrayList; |
| 23 import java.util.HashSet; |
| 23 import java.util.List; | 24 import java.util.List; |
| 25 import java.util.Set; |
| 24 | 26 |
| 25 /** | 27 /** |
| 26 * Access gate to C++ side offline pages functionalities. | 28 * Access gate to C++ side offline pages functionalities. |
| 27 */ | 29 */ |
| 28 @JNINamespace("offline_pages::android") | 30 @JNINamespace("offline_pages::android") |
| 29 public final class OfflinePageBridge { | 31 public final class OfflinePageBridge { |
| 32 public static final String BOOKMARK_NAMESPACE = "bookmark"; |
| 33 public static final long INVALID_OFFLINE_ID = 0; |
| 30 | 34 |
| 31 private long mNativeOfflinePageBridge; | 35 private long mNativeOfflinePageBridge; |
| 32 private boolean mIsNativeOfflinePageModelLoaded; | 36 private boolean mIsNativeOfflinePageModelLoaded; |
| 33 private final ObserverList<OfflinePageModelObserver> mObservers = | 37 private final ObserverList<OfflinePageModelObserver> mObservers = |
| 34 new ObserverList<OfflinePageModelObserver>(); | 38 new ObserverList<OfflinePageModelObserver>(); |
| 35 | 39 |
| 36 /** Mode of the offline pages feature */ | 40 /** Mode of the offline pages feature */ |
| 37 private static Integer sFeatureMode; | 41 private static Integer sFeatureMode; |
| 38 | 42 |
| 39 /** | 43 /** |
| 40 * Callback used to saving an offline page. | 44 * Callback used to saving an offline page. |
| 41 */ | 45 */ |
| 42 public interface SavePageCallback { | 46 public interface SavePageCallback { |
| 43 /** | 47 /** |
| 44 * Delivers result of saving a page. | 48 * Delivers result of saving a page. |
| 45 * | 49 * |
| 46 * @param savePageResult Result of the saving. Uses | 50 * @param savePageResult Result of the saving. Uses |
| 47 * {@see org.chromium.components.offlinepages.SavePageResult} enum. | 51 * {@see org.chromium.components.offlinepages.SavePageResult} enum. |
| 48 * @param url URL of the saved page. | 52 * @param url URL of the saved page. |
| 49 * @see OfflinePageBridge#savePage() | 53 * @see OfflinePageBridge#savePage() |
| 50 */ | 54 */ |
| 51 @CalledByNative("SavePageCallback") | 55 @CalledByNative("SavePageCallback") |
| 52 void onSavePageDone(int savePageResult, String url); | 56 void onSavePageDone(int savePageResult, String url, long offlineId); |
| 53 } | 57 } |
| 54 | 58 |
| 55 /** | 59 /** |
| 56 * Callback used to deleting an offline page. | 60 * Callback used to deleting an offline page. |
| 57 */ | 61 */ |
| 58 public interface DeletePageCallback { | 62 public interface DeletePageCallback { |
| 59 /** | 63 /** |
| 60 * Delivers result of deleting a page. | 64 * Delivers result of deleting a page. |
| 61 * | 65 * |
| 62 * @param deletePageResult Result of deleting the page. Uses | 66 * @param deletePageResult Result of deleting the page. Uses |
| (...skipping 14 matching lines...) Expand all Loading... |
| 77 public void offlinePageModelLoaded() {} | 81 public void offlinePageModelLoaded() {} |
| 78 | 82 |
| 79 /** | 83 /** |
| 80 * Called when the native side of offline pages is changed due to adding
, removing or | 84 * Called when the native side of offline pages is changed due to adding
, removing or |
| 81 * update an offline page. | 85 * update an offline page. |
| 82 */ | 86 */ |
| 83 public void offlinePageModelChanged() {} | 87 public void offlinePageModelChanged() {} |
| 84 | 88 |
| 85 /** | 89 /** |
| 86 * Called when an offline page is deleted. This can be called as a resul
t of | 90 * Called when an offline page is deleted. This can be called as a resul
t of |
| 91 * TODO(bburns): Switch to offline id/client id |
| 87 * #checkOfflinePageMetadata(). | 92 * #checkOfflinePageMetadata(). |
| 88 * @param bookmarkId A bookmark ID of the deleted offline page. | 93 * @param bookmarkId A bookmark ID of the deleted offline page. |
| 89 */ | 94 */ |
| 90 public void offlinePageDeleted(BookmarkId bookmarkId) {} | 95 public void offlinePageDeleted(BookmarkId id) {} |
| 91 } | 96 } |
| 92 | 97 |
| 93 private static long getTotalSize(List<OfflinePageItem> offlinePages) { | 98 private static long getTotalSize(List<OfflinePageItem> offlinePages) { |
| 94 long totalSize = 0; | 99 long totalSize = 0; |
| 95 for (OfflinePageItem offlinePage : offlinePages) { | 100 for (OfflinePageItem offlinePage : offlinePages) { |
| 96 totalSize += offlinePage.getFileSize(); | 101 totalSize += offlinePage.getFileSize(); |
| 97 } | 102 } |
| 98 return totalSize; | 103 return totalSize; |
| 99 } | 104 } |
| 100 | 105 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 * @return Gets all available offline pages. Requires that the model is alre
ady loaded. | 219 * @return Gets all available offline pages. Requires that the model is alre
ady loaded. |
| 215 */ | 220 */ |
| 216 public List<OfflinePageItem> getAllPages() { | 221 public List<OfflinePageItem> getAllPages() { |
| 217 assert mIsNativeOfflinePageModelLoaded; | 222 assert mIsNativeOfflinePageModelLoaded; |
| 218 List<OfflinePageItem> result = new ArrayList<OfflinePageItem>(); | 223 List<OfflinePageItem> result = new ArrayList<OfflinePageItem>(); |
| 219 nativeGetAllPages(mNativeOfflinePageBridge, result); | 224 nativeGetAllPages(mNativeOfflinePageBridge, result); |
| 220 return result; | 225 return result; |
| 221 } | 226 } |
| 222 | 227 |
| 223 /** | 228 /** |
| 229 * @return A list of all offline ids that match a particular |
| 230 * (namespace, client_id) |
| 231 */ |
| 232 private Set<Long> getOfflineIdsForClientId(String clientIdNamespace, String
clientId) { |
| 233 assert mIsNativeOfflinePageModelLoaded; |
| 234 long[] offlineIds = nativeGetOfflineIdsForClientId( |
| 235 mNativeOfflinePageBridge, clientIdNamespace, clientId); |
| 236 Set<Long> result = new HashSet<>(offlineIds.length); |
| 237 for (long id : offlineIds) { |
| 238 result.add(id); |
| 239 } |
| 240 return result; |
| 241 } |
| 242 |
| 243 /** |
| 224 * Gets an offline page associated with a provided bookmark ID. | 244 * Gets an offline page associated with a provided bookmark ID. |
| 225 * | 245 * |
| 226 * @param bookmarkId Id of the bookmark associated with an offline page. | 246 * @param bookmarkId Id of the bookmark associated with an offline page. |
| 227 * @return An {@link OfflinePageItem} matching the bookmark Id or <code>null
</code> if none | 247 * @return An {@link OfflinePageItem} matching the bookmark Id or <code>null
</code> if none |
| 228 * exist. | 248 * exist. |
| 229 */ | 249 */ |
| 230 public OfflinePageItem getPageByBookmarkId(BookmarkId bookmarkId) { | 250 public OfflinePageItem getPageByBookmarkId(BookmarkId bookmarkId) { |
| 231 return nativeGetPageByBookmarkId(mNativeOfflinePageBridge, bookmarkId.ge
tId()); | 251 Set<Long> ids = |
| 252 getOfflineIdsForClientId(BOOKMARK_NAMESPACE, Long.toString(bookm
arkId.getId())); |
| 253 if (ids.size() == 0) { |
| 254 return null; |
| 255 } |
| 256 Long offlineId = ids.iterator().next(); |
| 257 // TODO(bburns): Handle multiple client ids better. |
| 258 return nativeGetPageByOfflineId(mNativeOfflinePageBridge, offlineId); |
| 232 } | 259 } |
| 233 | 260 |
| 234 /** | 261 /** |
| 235 * Gets an offline page associated with a provided online URL. | 262 * Gets an offline page associated with a provided online URL. |
| 236 * | 263 * |
| 237 * @param onlineURL URL of the page. | 264 * @param onlineURL URL of the page. |
| 238 * @return An {@link OfflinePageItem} matching the URL or <code>null</code>
if none exist. | 265 * @return An {@link OfflinePageItem} matching the URL or <code>null</code>
if none exist. |
| 239 */ | 266 */ |
| 240 public OfflinePageItem getPageByOnlineURL(String onlineURL) { | 267 public OfflinePageItem getPageByOnlineURL(String onlineURL) { |
| 241 return nativeGetPageByOnlineURL(mNativeOfflinePageBridge, onlineURL); | 268 return nativeGetPageByOnlineURL(mNativeOfflinePageBridge, onlineURL); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 259 * @param bookmarkId Id of the bookmark related to the offline page. | 286 * @param bookmarkId Id of the bookmark related to the offline page. |
| 260 * @param callback Interface that contains a callback. | 287 * @param callback Interface that contains a callback. |
| 261 * @see SavePageCallback | 288 * @see SavePageCallback |
| 262 */ | 289 */ |
| 263 public void savePage(final WebContents webContents, final BookmarkId bookmar
kId, | 290 public void savePage(final WebContents webContents, final BookmarkId bookmar
kId, |
| 264 final SavePageCallback callback) { | 291 final SavePageCallback callback) { |
| 265 assert mIsNativeOfflinePageModelLoaded; | 292 assert mIsNativeOfflinePageModelLoaded; |
| 266 assert webContents != null; | 293 assert webContents != null; |
| 267 | 294 |
| 268 if (webContents.isDestroyed()) { | 295 if (webContents.isDestroyed()) { |
| 269 callback.onSavePageDone(SavePageResult.CONTENT_UNAVAILABLE, null); | 296 callback.onSavePageDone(SavePageResult.CONTENT_UNAVAILABLE, null, IN
VALID_OFFLINE_ID); |
| 270 RecordHistogram.recordEnumeratedHistogram("OfflinePages.SavePageResu
lt", | 297 RecordHistogram.recordEnumeratedHistogram("OfflinePages.SavePageResu
lt", |
| 271 SavePageResult.CONTENT_UNAVAILABLE, SavePageResult.RESULT_CO
UNT); | 298 SavePageResult.CONTENT_UNAVAILABLE, SavePageResult.RESULT_CO
UNT); |
| 272 return; | 299 return; |
| 273 } | 300 } |
| 274 | 301 |
| 275 SavePageCallback callbackWrapper = new SavePageCallback() { | 302 SavePageCallback callbackWrapper = new SavePageCallback() { |
| 276 @Override | 303 @Override |
| 277 public void onSavePageDone(int savePageResult, String url) { | 304 public void onSavePageDone(int savePageResult, String url, long offl
ineId) { |
| 278 // TODO(fgorski): Eliminate call to getAllPages() here. | 305 // TODO(fgorski): Eliminate call to getAllPages() here. |
| 279 // See http://crbug.com/566939 | 306 // See http://crbug.com/566939 |
| 280 if (savePageResult == SavePageResult.SUCCESS && isOfflinePageMod
elLoaded()) { | 307 if (savePageResult == SavePageResult.SUCCESS && isOfflinePageMod
elLoaded()) { |
| 281 long totalPageSizeAfter = getTotalSize(getAllPages()); | 308 long totalPageSizeAfter = getTotalSize(getAllPages()); |
| 282 recordStorageHistograms(0, totalPageSizeAfter); | 309 recordStorageHistograms(0, totalPageSizeAfter); |
| 283 } | 310 } |
| 284 callback.onSavePageDone(savePageResult, url); | 311 callback.onSavePageDone(savePageResult, url, offlineId); |
| 285 } | 312 } |
| 286 }; | 313 }; |
| 287 recordFreeSpaceHistograms( | 314 recordFreeSpaceHistograms( |
| 288 "OfflinePages.SavePage.FreeSpacePercentage", "OfflinePages.SaveP
age.FreeSpaceMB"); | 315 "OfflinePages.SavePage.FreeSpacePercentage", "OfflinePages.SaveP
age.FreeSpaceMB"); |
| 289 nativeSavePage(mNativeOfflinePageBridge, callbackWrapper, webContents, b
ookmarkId.getId()); | 316 String namespace = BOOKMARK_NAMESPACE; |
| 317 String clientId = Long.toString(bookmarkId.getId()); |
| 318 |
| 319 nativeSavePage(mNativeOfflinePageBridge, callbackWrapper, webContents, n
amespace, clientId); |
| 290 } | 320 } |
| 291 | 321 |
| 292 /** | 322 /** |
| 293 * Marks that an offline page related to a specified bookmark has been acces
sed. | 323 * Marks that an offline page related to a specified bookmark has been acces
sed. |
| 294 * | 324 * |
| 295 * @param bookmarkId Bookmark ID for which the offline copy will be deleted. | 325 * @param bookmarkId Bookmark ID for which the offline copy will be deleted. |
| 296 */ | 326 */ |
| 297 private void markPageAccessed(BookmarkId bookmarkId) { | 327 private void markPageAccessed(BookmarkId bookmarkId) { |
| 298 assert mIsNativeOfflinePageModelLoaded; | 328 assert mIsNativeOfflinePageModelLoaded; |
| 299 nativeMarkPageAccessed(mNativeOfflinePageBridge, bookmarkId.getId()); | 329 Set<Long> ids = |
| 330 getOfflineIdsForClientId(BOOKMARK_NAMESPACE, Long.toString(bookm
arkId.getId())); |
| 331 if (ids.size() == 0) { |
| 332 return; |
| 333 } |
| 334 Long offlineId = ids.iterator().next(); |
| 335 nativeMarkPageAccessed(mNativeOfflinePageBridge, offlineId); |
| 300 } | 336 } |
| 301 | 337 |
| 302 /** | 338 /** |
| 303 * Deletes an offline page related to a specified bookmark. | 339 * Deletes an offline page related to a specified bookmark. |
| 304 * | 340 * |
| 305 * @param bookmarkId Bookmark ID for which the offline copy will be deleted. | 341 * @param bookmarkId Bookmark ID for which the offline copy will be deleted. |
| 306 * @param callback Interface that contains a callback. | 342 * @param callback Interface that contains a callback. |
| 307 * @see DeletePageCallback | 343 * @see DeletePageCallback |
| 308 */ | 344 */ |
| 309 public void deletePage(final BookmarkId bookmarkId, DeletePageCallback callb
ack) { | 345 public void deletePage(final BookmarkId bookmarkId, DeletePageCallback callb
ack) { |
| 310 assert mIsNativeOfflinePageModelLoaded; | 346 assert mIsNativeOfflinePageModelLoaded; |
| 311 | 347 |
| 312 recordFreeSpaceHistograms("OfflinePages.DeletePage.FreeSpacePercentage", | 348 recordFreeSpaceHistograms("OfflinePages.DeletePage.FreeSpacePercentage", |
| 313 "OfflinePages.DeletePage.FreeSpaceMB"); | 349 "OfflinePages.DeletePage.FreeSpaceMB"); |
| 314 | 350 |
| 315 DeletePageCallback callbackWrapper = wrapCallbackWithHistogramReporting(
callback); | 351 DeletePageCallback callbackWrapper = wrapCallbackWithHistogramReporting(
callback); |
| 316 nativeDeletePage(mNativeOfflinePageBridge, callbackWrapper, bookmarkId.g
etId()); | 352 Set<Long> ids = |
| 353 getOfflineIdsForClientId(BOOKMARK_NAMESPACE, Long.toString(bookm
arkId.getId())); |
| 354 if (ids.size() == 0) { |
| 355 callback.onDeletePageDone(DeletePageResult.NOT_FOUND); |
| 356 return; |
| 357 } |
| 358 Long offlineId = ids.iterator().next(); |
| 359 nativeDeletePage(mNativeOfflinePageBridge, callbackWrapper, offlineId); |
| 317 } | 360 } |
| 318 | 361 |
| 319 /** | 362 /** |
| 320 * Deletes offline pages based on the list of provided bookamrk IDs. Calls t
he callback | 363 * Deletes offline pages based on the list of provided bookamrk IDs. Calls t
he callback |
| 321 * when operation is complete. Requires that the model is already loaded. | 364 * when operation is complete. Requires that the model is already loaded. |
| 322 * | 365 * |
| 323 * @param bookmarkIds A list of bookmark IDs for which the offline pages wil
l be deleted. | 366 * @param bookmarkIds A list of bookmark IDs for which the offline pages wil
l be deleted. |
| 324 * @param callback A callback that will be called once operation is complete
d. | 367 * @param callback A callback that will be called once operation is complete
d. |
| 325 */ | 368 */ |
| 326 public void deletePages(List<BookmarkId> bookmarkIds, DeletePageCallback cal
lback) { | 369 public void deletePages(List<BookmarkId> bookmarkIds, DeletePageCallback cal
lback) { |
| 327 assert mIsNativeOfflinePageModelLoaded; | 370 assert mIsNativeOfflinePageModelLoaded; |
| 328 long[] ids = new long[bookmarkIds.size()]; | 371 List<Long> idList = new ArrayList<>(bookmarkIds.size()); |
| 329 for (int i = 0; i < ids.length; i++) { | 372 for (int i = 0; i < bookmarkIds.size(); i++) { |
| 330 ids[i] = bookmarkIds.get(i).getId(); | 373 idList.addAll(getOfflineIdsForClientId( |
| 374 BOOKMARK_NAMESPACE, Long.toString(bookmarkIds.get(i).getId()
))); |
| 331 } | 375 } |
| 332 | 376 long[] ids = new long[idList.size()]; |
| 377 for (int i = 0; i < idList.size(); i++) { |
| 378 ids[i] = idList.get(i); |
| 379 } |
| 333 recordFreeSpaceHistograms("OfflinePages.DeletePage.FreeSpacePercentage", | 380 recordFreeSpaceHistograms("OfflinePages.DeletePage.FreeSpacePercentage", |
| 334 "OfflinePages.DeletePage.FreeSpaceMB"); | 381 "OfflinePages.DeletePage.FreeSpaceMB"); |
| 335 | 382 |
| 336 DeletePageCallback callbackWrapper = wrapCallbackWithHistogramReporting(
callback); | 383 DeletePageCallback callbackWrapper = wrapCallbackWithHistogramReporting(
callback); |
| 337 nativeDeletePages(mNativeOfflinePageBridge, callbackWrapper, ids); | 384 nativeDeletePages(mNativeOfflinePageBridge, callbackWrapper, ids); |
| 338 } | 385 } |
| 339 | 386 |
| 340 /** | 387 /** |
| 341 * Whether or not the underlying offline page model is loaded. | 388 * Whether or not the underlying offline page model is loaded. |
| 342 */ | 389 */ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (page == null) return onlineUrl; | 433 if (page == null) return onlineUrl; |
| 387 | 434 |
| 388 boolean isOnline = OfflinePageUtils.isConnected(); | 435 boolean isOnline = OfflinePageUtils.isConnected(); |
| 389 RecordHistogram.recordBooleanHistogram("OfflinePages.OnlineOnOpen", isOn
line); | 436 RecordHistogram.recordBooleanHistogram("OfflinePages.OnlineOnOpen", isOn
line); |
| 390 | 437 |
| 391 // When there is a network connection, we visit original URL online. | 438 // When there is a network connection, we visit original URL online. |
| 392 if (isOnline) return onlineUrl; | 439 if (isOnline) return onlineUrl; |
| 393 | 440 |
| 394 // Mark that the offline page has been accessed, that will cause last ac
cess time and access | 441 // Mark that the offline page has been accessed, that will cause last ac
cess time and access |
| 395 // count being updated. | 442 // count being updated. |
| 396 markPageAccessed(page.getBookmarkId()); | 443 nativeMarkPageAccessed(mNativeOfflinePageBridge, page.getBookmarkId().ge
tId()); |
| 397 | 444 |
| 398 // Returns the offline URL for offline access. | 445 // Returns the offline URL for offline access. |
| 399 return page.getOfflineUrl(); | 446 return page.getOfflineUrl(); |
| 400 } | 447 } |
| 401 | 448 |
| 402 /** | 449 /** |
| 403 * Gets the offline URL of an offline page of that is saved for the online U
RL. | 450 * Gets the offline URL of an offline page of that is saved for the online U
RL. |
| 404 * @param onlineUrl Online URL, which might have offline copy. | 451 * @param onlineUrl Online URL, which might have offline copy. |
| 405 * @return URL pointing to the offline copy or <code>null</code> if none exi
sts. | 452 * @return URL pointing to the offline copy or <code>null</code> if none exi
sts. |
| 406 */ | 453 */ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 435 } | 482 } |
| 436 | 483 |
| 437 @CalledByNative | 484 @CalledByNative |
| 438 private void offlinePageModelChanged() { | 485 private void offlinePageModelChanged() { |
| 439 for (OfflinePageModelObserver observer : mObservers) { | 486 for (OfflinePageModelObserver observer : mObservers) { |
| 440 observer.offlinePageModelChanged(); | 487 observer.offlinePageModelChanged(); |
| 441 } | 488 } |
| 442 } | 489 } |
| 443 | 490 |
| 444 @CalledByNative | 491 @CalledByNative |
| 445 private void offlinePageDeleted(long bookmarkId) { | 492 private void offlinePageDeleted(long offlineId) { |
| 446 BookmarkId id = new BookmarkId(bookmarkId, BookmarkType.NORMAL); | 493 BookmarkId id = new BookmarkId(offlineId, BookmarkType.NORMAL); |
| 447 for (OfflinePageModelObserver observer : mObservers) { | 494 for (OfflinePageModelObserver observer : mObservers) { |
| 448 observer.offlinePageDeleted(id); | 495 observer.offlinePageDeleted(id); |
| 449 } | 496 } |
| 450 } | 497 } |
| 451 | 498 |
| 452 @CalledByNative | 499 @CalledByNative |
| 453 private static void createOfflinePageAndAddToList(List<OfflinePageItem> offl
inePagesList, | 500 private static void createOfflinePageAndAddToList(List<OfflinePageItem> offl
inePagesList, |
| 454 String url, long bookmarkId, String offlineUrl, long fileSize, long
creationTime, | 501 String url, long offlineId, String offlineUrl, long fileSize, long c
reationTime, |
| 455 int accessCount, long lastAccessTimeMs) { | 502 int accessCount, long lastAccessTimeMs) { |
| 456 offlinePagesList.add(createOfflinePageItem( | 503 offlinePagesList.add(createOfflinePageItem( |
| 457 url, bookmarkId, offlineUrl, fileSize, creationTime, accessCount
, | 504 url, offlineId, offlineUrl, fileSize, creationTime, accessCount,
lastAccessTimeMs)); |
| 458 lastAccessTimeMs)); | |
| 459 } | 505 } |
| 460 | 506 |
| 461 @CalledByNative | 507 @CalledByNative |
| 462 private static OfflinePageItem createOfflinePageItem(String url, long bookma
rkId, | 508 private static OfflinePageItem createOfflinePageItem(String url, long offlin
eId, |
| 463 String offlineUrl, long fileSize, long creationTime, int accessCount
, | 509 String offlineUrl, long fileSize, long creationTime, int accessCount
, |
| 464 long lastAccessTimeMs) { | 510 long lastAccessTimeMs) { |
| 465 return new OfflinePageItem( | 511 return new OfflinePageItem( |
| 466 url, bookmarkId, offlineUrl, fileSize, creationTime, accessCount
, lastAccessTimeMs); | 512 url, offlineId, offlineUrl, fileSize, creationTime, accessCount,
lastAccessTimeMs); |
| 467 } | 513 } |
| 468 | 514 |
| 469 private static native int nativeGetFeatureMode(); | 515 private static native int nativeGetFeatureMode(); |
| 470 private static native boolean nativeCanSavePage(String url); | 516 private static native boolean nativeCanSavePage(String url); |
| 471 | 517 |
| 472 private native long nativeInit(Profile profile); | 518 private native long nativeInit(Profile profile); |
| 473 private native void nativeDestroy(long nativeOfflinePageBridge); | 519 private native void nativeDestroy(long nativeOfflinePageBridge); |
| 474 private native void nativeGetAllPages( | 520 private native void nativeGetAllPages( |
| 475 long nativeOfflinePageBridge, List<OfflinePageItem> offlinePages); | 521 long nativeOfflinePageBridge, List<OfflinePageItem> offlinePages); |
| 476 private native OfflinePageItem nativeGetPageByBookmarkId( | 522 private native long[] nativeGetOfflineIdsForClientId( |
| 477 long nativeOfflinePageBridge, long bookmarkId); | 523 long nativeOfflinePageBridge, String clientNamespace, String clientI
d); |
| 524 private native OfflinePageItem nativeGetPageByOfflineId( |
| 525 long nativeOfflinePageBridge, long offlineId); |
| 478 private native OfflinePageItem nativeGetPageByOnlineURL( | 526 private native OfflinePageItem nativeGetPageByOnlineURL( |
| 479 long nativeOfflinePageBridge, String onlineURL); | 527 long nativeOfflinePageBridge, String onlineURL); |
| 480 private native OfflinePageItem nativeGetPageByOfflineUrl( | 528 private native OfflinePageItem nativeGetPageByOfflineUrl( |
| 481 long nativeOfflinePageBridge, String offlineUrl); | 529 long nativeOfflinePageBridge, String offlineUrl); |
| 482 private native void nativeSavePage(long nativeOfflinePageBridge, SavePageCal
lback callback, | 530 private native void nativeSavePage(long nativeOfflinePageBridge, SavePageCal
lback callback, |
| 483 WebContents webContents, long bookmarkId); | 531 WebContents webContents, String clientNamespace, String clientId); |
| 484 private native void nativeMarkPageAccessed(long nativeOfflinePageBridge, lon
g bookmarkId); | 532 private native void nativeMarkPageAccessed(long nativeOfflinePageBridge, lon
g offlineId); |
| 485 private native void nativeDeletePage(long nativeOfflinePageBridge, | 533 private native void nativeDeletePage( |
| 486 DeletePageCallback callback, long bookmarkId); | 534 long nativeOfflinePageBridge, DeletePageCallback callback, long offl
ineId); |
| 487 private native void nativeDeletePages( | 535 private native void nativeDeletePages( |
| 488 long nativeOfflinePageBridge, DeletePageCallback callback, long[] bo
okmarkIds); | 536 long nativeOfflinePageBridge, DeletePageCallback callback, long[] of
flineIds); |
| 489 private native void nativeGetPagesToCleanUp( | 537 private native void nativeGetPagesToCleanUp( |
| 490 long nativeOfflinePageBridge, List<OfflinePageItem> offlinePages); | 538 long nativeOfflinePageBridge, List<OfflinePageItem> offlinePages); |
| 491 private native void nativeCheckMetadataConsistency(long nativeOfflinePageBri
dge); | 539 private native void nativeCheckMetadataConsistency(long nativeOfflinePageBri
dge); |
| 492 private native String nativeGetOfflineUrlForOnlineUrl( | 540 private native String nativeGetOfflineUrlForOnlineUrl( |
| 493 long nativeOfflinePageBridge, String onlineUrl); | 541 long nativeOfflinePageBridge, String onlineUrl); |
| 494 } | 542 } |
| OLD | NEW |