Bug 842457 - Limit columns in queries used for getCount r=bnicholson

This commit is contained in:
Mark Finkle 2013-02-19 15:53:03 -05:00
parent 96ed5c9c26
commit d07e148677

View File

@ -185,23 +185,28 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
public int getCount(ContentResolver cr, String database) { public int getCount(ContentResolver cr, String database) {
Cursor cursor = null; Cursor cursor = null;
int count = 0; int count = 0;
String[] columns = null;
String constraint = null; String constraint = null;
try { try {
Uri uri = null; Uri uri = null;
if ("history".equals(database)) { if ("history".equals(database)) {
uri = mHistoryUriWithProfile; uri = mHistoryUriWithProfile;
columns = new String[] { History._ID };
constraint = Combined.VISITS + " > 0"; constraint = Combined.VISITS + " > 0";
} else if ("bookmarks".equals(database)) { } else if ("bookmarks".equals(database)) {
uri = mBookmarksUriWithProfile; uri = mBookmarksUriWithProfile;
columns = new String[] { Bookmarks._ID };
// ignore folders, tags, keywords, separators, etc. // ignore folders, tags, keywords, separators, etc.
constraint = Bookmarks.TYPE + " = " + Bookmarks.TYPE_BOOKMARK; constraint = Bookmarks.TYPE + " = " + Bookmarks.TYPE_BOOKMARK;
} else if ("thumbnails".equals(database)) { } else if ("thumbnails".equals(database)) {
uri = mThumbnailsUriWithProfile; uri = mThumbnailsUriWithProfile;
columns = new String[] { Thumbnails._ID };
} else if ("favicons".equals(database)) { } else if ("favicons".equals(database)) {
uri = mFaviconsUriWithProfile; uri = mFaviconsUriWithProfile;
columns = new String[] { Favicons._ID };
} }
if (uri != null) { if (uri != null) {
cursor = cr.query(uri, null, constraint, null, null); cursor = cr.query(uri, columns, constraint, null, null);
count = cursor.getCount(); count = cursor.getCount();
} }
} finally { } finally {