Bug 1056468 - Clear metadata when history entries are removed. r=lucasr

This commit is contained in:
Wes Johnston 2014-08-21 10:03:44 -07:00
Родитель e47ba45aed
Коммит 2282b2d613
2 изменённых файлов: 18 добавлений и 1 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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);
}
}