Bug 917455 - Revert getTopBookmarks back to getTopSites. r=wesj a=lsblakk
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 18 Sep 2013 13:32:22 -0400
changeset 160507 7951523d9b542c10c7925df9e13e6b604f6b0df8
parent 160506 40b02c6fdbb22ccfd1fefb7ed986a62f04194f00
child 160508 c444238cb90a011d0fa0e389e10b4d20ecba0861
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj, lsblakk
bugs917455
milestone26.0a2
Bug 917455 - Revert getTopBookmarks back to getTopSites. r=wesj a=lsblakk
mobile/android/base/db/BrowserDB.java
mobile/android/base/db/LocalBrowserDB.java
mobile/android/base/home/TopSitesPage.java
--- a/mobile/android/base/db/BrowserDB.java
+++ b/mobile/android/base/db/BrowserDB.java
@@ -34,19 +34,19 @@ public class BrowserDB {
 
     private static BrowserDBIface sDb = null;
 
     public interface BrowserDBIface {
         public void invalidateCachedState();
 
         public Cursor filter(ContentResolver cr, CharSequence constraint, int limit);
 
-        // This should only return frecent bookmarks, BrowserDB.getTopBookmarks will do the
+        // This should onlyl return frecent sites, BrowserDB.getTopSites will do the
         // work to combine that list with the pinned sites list
-        public Cursor getTopBookmarks(ContentResolver cr, int limit);
+        public Cursor getTopSites(ContentResolver cr, int limit);
 
         public void updateVisitedHistory(ContentResolver cr, String uri);
 
         public void updateHistoryTitle(ContentResolver cr, String uri, String title);
 
         public void updateHistoryEntry(ContentResolver cr, String uri, String title,
                                        long date, int visits);
 
@@ -133,22 +133,22 @@ public class BrowserDB {
     public static void invalidateCachedState() {
         sDb.invalidateCachedState();
     }
 
     public static Cursor filter(ContentResolver cr, CharSequence constraint, int limit) {
         return sDb.filter(cr, constraint, limit);
     }
 
-    public static Cursor getTopBookmarks(ContentResolver cr, int limit) {
-        // Note this is not a single query anymore, but actually returns a mixture of two queries,
-        // one for top bookmarks, and one for pinned sites (which are actually bookmarks as well).
-        Cursor topBookmarks = sDb.getTopBookmarks(cr, limit);
+    public static Cursor getTopSites(ContentResolver cr, int limit) {
+        // Note this is not a single query anymore, but actually returns a mixture of two queries, one for topSites
+        // and one for pinned sites
+        Cursor topSites = sDb.getTopSites(cr, limit);
         Cursor pinnedSites = sDb.getPinnedSites(cr, limit);
-        return new TopSitesCursorWrapper(pinnedSites, topBookmarks, limit);
+        return new TopSitesCursorWrapper(pinnedSites, topSites, limit);
     }
 
     public static void updateVisitedHistory(ContentResolver cr, String uri) {
         if (sAreContentProvidersEnabled) {
             sDb.updateVisitedHistory(cr, uri);
         }
     }
 
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -226,23 +226,19 @@ public class LocalBrowserDB implements B
                                              Combined.BOOKMARK_ID,
                                              Combined.HISTORY_ID },
                               constraint,
                               limit,
                               null);
     }
 
     @Override
-    public Cursor getTopBookmarks(ContentResolver cr, int limit) {
-        // Only select bookmarks. Unfortunately, we need to query the combined view,
-        // instead of just the bookmarks table, in order to do the frecency calculation.
-        String selection = Combined.BOOKMARK_ID + " IS NOT NULL";
-
-        // Filter out sites that are pinned.
-        selection = DBUtils.concatenateWhere(selection, Combined.URL + " NOT IN (SELECT " +
+    public Cursor getTopSites(ContentResolver cr, int limit) {
+        // Filter out sites that are pinned
+        String selection = DBUtils.concatenateWhere("", Combined.URL + " NOT IN (SELECT " +
                                              Bookmarks.URL + " FROM bookmarks WHERE " +
                                              DBUtils.qualifyColumn("bookmarks", Bookmarks.PARENT) + " == ? AND " +
                                              DBUtils.qualifyColumn("bookmarks", Bookmarks.IS_DELETED) + " == 0)");
         String[] selectionArgs = DBUtils.appendSelectionArgs(new String[0], new String[] { String.valueOf(Bookmarks.FIXED_PINNED_LIST_ID) });
         return filterAllSites(cr,
                               new String[] { Combined._ID,
                                              Combined.URL,
                                              Combined.TITLE },
--- a/mobile/android/base/home/TopSitesPage.java
+++ b/mobile/android/base/home/TopSitesPage.java
@@ -470,17 +470,17 @@ public class TopSitesPage extends HomeFr
     private static class TopSitesGridLoader extends SimpleCursorLoader {
         public TopSitesGridLoader(Context context) {
             super(context);
         }
 
         @Override
         public Cursor loadCursor() {
             final int max = getContext().getResources().getInteger(R.integer.number_of_top_sites);
-            return BrowserDB.getTopBookmarks(getContext().getContentResolver(), max);
+            return BrowserDB.getTopSites(getContext().getContentResolver(), max);
         }
     }
 
     private class VisitedAdapter extends CursorAdapter {
         public VisitedAdapter(Context context, Cursor cursor) {
             super(context, cursor);
         }