From 2282b2d613a86ded2b25f4d1e72e7ba6e7140ee2 Mon Sep 17 00:00:00 2001 From: Wes Johnston Date: Thu, 21 Aug 2014 10:03:44 -0700 Subject: [PATCH] Bug 1056468 - Clear metadata when history entries are removed. r=lucasr --- mobile/android/base/db/BrowserProvider.java | 3 ++- mobile/android/base/db/URLMetadata.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mobile/android/base/db/BrowserProvider.java b/mobile/android/base/db/BrowserProvider.java index 04e62e7f32a2..db6f8e07f92a 100644 --- a/mobile/android/base/db/BrowserProvider.java +++ b/mobile/android/base/db/BrowserProvider.java @@ -1400,7 +1400,8 @@ public class BrowserProvider extends SharedBrowserDatabaseProvider { + " AND " + Bookmarks.URL + " IS NOT NULL)"; return deleteFavicons(uri, faviconSelection, null) + - deleteThumbnails(uri, thumbnailSelection, null); + deleteThumbnails(uri, thumbnailSelection, null) + + URLMetadata.deleteUnused(getContext().getContentResolver()); } @Override diff --git a/mobile/android/base/db/URLMetadata.java b/mobile/android/base/db/URLMetadata.java index 7b9a6b54d040..741e82759092 100644 --- a/mobile/android/base/db/URLMetadata.java +++ b/mobile/android/base/db/URLMetadata.java @@ -5,6 +5,8 @@ */ package org.mozilla.gecko.db; +import org.mozilla.gecko.db.BrowserContract.Bookmarks; +import org.mozilla.gecko.db.BrowserContract.History; import org.mozilla.gecko.util.ThreadUtils; import org.mozilla.gecko.Telemetry; @@ -187,4 +189,18 @@ public class URLMetadata { Log.e(LOGTAG, "error saving", ex); } } + + public static int deleteUnused(final ContentResolver cr) { + final String selection = URLMetadataTable.URL_COLUMN + " NOT IN " + + "(SELECT " + History.URL + + " FROM " + History.TABLE_NAME + + " WHERE " + History.IS_DELETED + " = 0" + + " UNION " + + " SELECT " + Bookmarks.URL + + " FROM " + Bookmarks.TABLE_NAME + + " WHERE " + Bookmarks.IS_DELETED + " = 0 " + + " AND " + Bookmarks.URL + " IS NOT NULL)"; + + return cr.delete(URLMetadataTable.CONTENT_URI, selection, null); + } }