Bug 862796: LocalBrowser DB doesn't need reading list. [r=bnicholson]
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 29 May 2013 15:04:22 -0700
changeset 156212 5ac643b8155bad79be1dc80d7b845baab39681be
parent 156211 762d1865d454eb946cbbdd4945e5407e50e22c8f
child 156213 e4c63bf2c0e869ed5e99f02a0f1c6f1c65a754ef
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)
reviewersbnicholson
bugs862796
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 862796: LocalBrowser DB doesn't need reading list. [r=bnicholson]
mobile/android/base/db/LocalBrowserDB.java
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -47,17 +47,16 @@ public class LocalBrowserDB implements B
 
     private final String mProfile;
 
     // Map of folder GUIDs to IDs. Used for caching.
     private HashMap<String, Long> mFolderIdMap;
 
     // Use wrapped Boolean so that we can have a null state
     private Boolean mDesktopBookmarksExist;
-    private Boolean mReadingListItemsExist;
 
     private final Uri mBookmarksUriWithProfile;
     private final Uri mParentsUriWithProfile;
     private final Uri mHistoryUriWithProfile;
     private final Uri mHistoryExpireUriWithProfile;
     private final Uri mCombinedUriWithProfile;
     private final Uri mDeletedHistoryUriWithProfile;
     private final Uri mUpdateHistoryUriWithProfile;
@@ -73,17 +72,16 @@ public class LocalBrowserDB implements B
                            Bookmarks.PARENT,
                            Bookmarks.KEYWORD,
                            Bookmarks.FAVICON }; 
 
     public LocalBrowserDB(String profile) {
         mProfile = profile;
         mFolderIdMap = new HashMap<String, Long>();
         mDesktopBookmarksExist = null;
-        mReadingListItemsExist = null;
 
         mBookmarksUriWithProfile = appendProfile(Bookmarks.CONTENT_URI);
         mParentsUriWithProfile = appendProfile(Bookmarks.PARENTS_CONTENT_URI);
         mHistoryUriWithProfile = appendProfile(History.CONTENT_URI);
         mHistoryExpireUriWithProfile = appendProfile(History.CONTENT_OLD_URI);
         mCombinedUriWithProfile = appendProfile(Combined.CONTENT_URI);
         mFaviconsUriWithProfile = appendProfile(Favicons.CONTENT_URI);
         mThumbnailsUriWithProfile = appendProfile(Thumbnails.CONTENT_URI);
@@ -95,17 +93,16 @@ public class LocalBrowserDB implements B
             appendQueryParameter(BrowserContract.PARAM_INCREMENT_VISITS, "true").
             appendQueryParameter(BrowserContract.PARAM_INSERT_IF_NEEDED, "true").build();
     }
 
     // Invalidate cached data
     @Override
     public void invalidateCachedState() {
         mDesktopBookmarksExist = null;
-        mReadingListItemsExist = null;
     }
 
     private Uri historyUriWithLimit(int limit) {
         return mHistoryUriWithProfile.buildUpon().appendQueryParameter(BrowserContract.PARAM_LIMIT,
                                                                        String.valueOf(limit)).build();
     }
 
     private Uri bookmarksUriWithLimit(int limit) {
@@ -367,29 +364,24 @@ public class LocalBrowserDB implements B
     public void clearHistory(ContentResolver cr) {
         cr.delete(mHistoryUriWithProfile, null, null);
     }
 
     @Override
     public Cursor getBookmarksInFolder(ContentResolver cr, long folderId) {
         Cursor c = null;
         boolean addDesktopFolder = false;
-        boolean addReadingListFolder = false;
 
         // We always want to show mobile bookmarks in the root view.
         if (folderId == Bookmarks.FIXED_ROOT_ID) {
             folderId = getFolderIdFromGuid(cr, Bookmarks.MOBILE_FOLDER_GUID);
 
             // We'll add a fake "Desktop Bookmarks" folder to the root view if desktop 
             // bookmarks exist, so that the user can still access non-mobile bookmarks.
             addDesktopFolder = desktopBookmarksExist(cr);
-
-            // We'll add the Reading List folder to the root view if any reading
-            // list items exist.
-            addReadingListFolder = readingListItemsExist(cr);
         }
 
         if (folderId == Bookmarks.FAKE_DESKTOP_FOLDER_ID) {
             // Since the "Desktop Bookmarks" folder doesn't actually exist, we
             // just fake it by querying specifically certain known desktop folders.
             c = cr.query(mBookmarksUriWithProfile,
                          DEFAULT_BOOKMARK_COLUMNS,
                          Bookmarks.GUID + " = ? OR " +
@@ -407,19 +399,19 @@ public class LocalBrowserDB implements B
                          Bookmarks.PARENT + " = ? AND " +
                          "(" + Bookmarks.TYPE + " = ? OR " + Bookmarks.TYPE + " = ?)",
                          new String[] { String.valueOf(folderId),
                                         String.valueOf(Bookmarks.TYPE_BOOKMARK),
                                         String.valueOf(Bookmarks.TYPE_FOLDER) },
                          null);
         }
 
-        if (addDesktopFolder || addReadingListFolder) {
+        if (addDesktopFolder) {
             // Wrap cursor to add fake desktop bookmarks and reading list folders
-            c = new SpecialFoldersCursorWrapper(c, addDesktopFolder, addReadingListFolder);
+            c = new SpecialFoldersCursorWrapper(c, addDesktopFolder);
         }
 
         return new LocalDBCursor(c);
     }
 
     // Returns true if any desktop bookmarks exist, which will be true if the user
     // has set up sync at one point, or done a profile migration from XUL fennec.
     private boolean desktopBookmarksExist(ContentResolver cr) {
@@ -445,38 +437,16 @@ public class LocalBrowserDB implements B
             c.close();
         }
 
         // Cache result for future queries
         mDesktopBookmarksExist = (count > 0);
         return mDesktopBookmarksExist;
     }
 
-    private boolean readingListItemsExist(ContentResolver cr) {
-        if (mReadingListItemsExist != null)
-            return mReadingListItemsExist;
-
-        Cursor c = null;
-        int count = 0;
-        try {
-            c = cr.query(bookmarksUriWithLimit(1),
-                         new String[] { Bookmarks._ID },
-                         Bookmarks.PARENT + " = ?",
-                         new String[] { String.valueOf(Bookmarks.FIXED_READING_LIST_ID) },
-                         null);
-            count = c.getCount();
-        } finally {
-            c.close();
-        }
-
-        // Cache result for future queries
-        mReadingListItemsExist = (count > 0);
-        return mReadingListItemsExist;
-    }
-
     @Override
     public boolean isBookmark(ContentResolver cr, String uri) {
         // This method is about normal bookmarks, not the Reading List
         int count = 0;
         try {
             Cursor c = cr.query(bookmarksUriWithLimit(1),
                                 new String[] { Bookmarks._ID },
                                 Bookmarks.URL + " = ? AND " +
@@ -1018,96 +988,78 @@ public class LocalBrowserDB implements B
     }
 
     // This wrapper adds a fake "Desktop Bookmarks" folder entry to the
     // beginning of the cursor's data set.
     private class SpecialFoldersCursorWrapper extends CursorWrapper {
         private int mIndexOffset;
 
         private int mDesktopBookmarksIndex = -1;
-        private int mReadingListIndex = -1;
 
         private boolean mAtDesktopBookmarksPosition = false;
-        private boolean mAtReadingListPosition = false;
 
-        public SpecialFoldersCursorWrapper(Cursor c, boolean showDesktopBookmarks, boolean showReadingList) {
+        public SpecialFoldersCursorWrapper(Cursor c, boolean showDesktopBookmarks) {
             super(c);
 
             mIndexOffset = 0;
 
             if (showDesktopBookmarks) {
                 mDesktopBookmarksIndex = mIndexOffset;
                 mIndexOffset++;
             }
-
-            if (showReadingList) {
-                mReadingListIndex = mIndexOffset;
-                mIndexOffset++;
-            }
         }
 
         @Override
         public int getCount() {
             return super.getCount() + mIndexOffset;
         }
 
         @Override
         public boolean moveToPosition(int position) {
             mAtDesktopBookmarksPosition = (mDesktopBookmarksIndex == position);
-            mAtReadingListPosition = (mReadingListIndex == position);
 
-            if (mAtDesktopBookmarksPosition || mAtReadingListPosition)
+            if (mAtDesktopBookmarksPosition)
                 return true;
 
             return super.moveToPosition(position - mIndexOffset);
         }
 
         @Override
         public long getLong(int columnIndex) {
-            if (!mAtDesktopBookmarksPosition && !mAtReadingListPosition)
+            if (!mAtDesktopBookmarksPosition)
                 return super.getLong(columnIndex);
 
             if (columnIndex == getColumnIndex(Bookmarks.PARENT)) {
                 return Bookmarks.FIXED_ROOT_ID;
             }
 
             return -1;
         }
 
         @Override
         public int getInt(int columnIndex) {
-            if (!mAtDesktopBookmarksPosition && !mAtReadingListPosition)
+            if (!mAtDesktopBookmarksPosition)
                 return super.getInt(columnIndex);
 
-            if (columnIndex == getColumnIndex(Bookmarks._ID)) {
-                if (mAtDesktopBookmarksPosition) {
+            if (columnIndex == getColumnIndex(Bookmarks._ID) && mAtDesktopBookmarksPosition)
                     return Bookmarks.FAKE_DESKTOP_FOLDER_ID;
-                } else if (mAtReadingListPosition) {
-                    return Bookmarks.FIXED_READING_LIST_ID;
-                }
-            }
 
             if (columnIndex == getColumnIndex(Bookmarks.TYPE))
                 return Bookmarks.TYPE_FOLDER;
 
             return -1;
         }
 
         @Override
         public String getString(int columnIndex) {
-            if (!mAtDesktopBookmarksPosition && !mAtReadingListPosition)
+            if (!mAtDesktopBookmarksPosition)
                 return super.getString(columnIndex);
 
-            if (columnIndex == getColumnIndex(Bookmarks.GUID)) {
-                if (mAtDesktopBookmarksPosition) {
+            if (columnIndex == getColumnIndex(Bookmarks.GUID) && mAtDesktopBookmarksPosition)
                     return Bookmarks.FAKE_DESKTOP_FOLDER_GUID;
-                } else if (mAtReadingListPosition) {
-                    return Bookmarks.READING_LIST_FOLDER_GUID;
-                }
-            }
 
             return "";
         }
     }
 
     private static class LocalDBCursor extends CursorWrapper {
         public LocalDBCursor(Cursor c) {
             super(c);