Bug 1074787 - Unable to Remove bookmarks via context menu. r=rnewman, a=lsblakk
authorMark Capella <markcapella@twcny.rr.com>
Sun, 19 Oct 2014 20:12:11 -0400
changeset 234817 0b91fda29efcd708ca79a803790bfd7b64811e39
parent 234816 3d7a6ba48e98b9b962e893d90465f79801d4da1b
child 234818 9046bff55bf966d802b17ed5cc69ceaf21d7e0d7
push id611
push userraliiev@mozilla.com
push dateMon, 05 Jan 2015 23:23:16 +0000
treeherdermozilla-release@345cd3b9c445 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, lsblakk
bugs1074787
milestone35.0a2
Bug 1074787 - Unable to Remove bookmarks via context menu. r=rnewman, a=lsblakk
mobile/android/base/db/LocalBrowserDB.java
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -77,17 +77,17 @@ public class LocalBrowserDB {
     }
 
     private final String mProfile;
 
     // Map of folder GUIDs to IDs. Used for caching.
     private final HashMap<String, Long> mFolderIdMap;
 
     // Use wrapped Boolean so that we can have a null state
-    private Boolean mDesktopBookmarksExist;
+    private volatile Boolean mDesktopBookmarksExist;
 
     private final Uri mBookmarksUriWithProfile;
     private final Uri mParentsUriWithProfile;
     private final Uri mHistoryUriWithProfile;
     private final Uri mHistoryExpireUriWithProfile;
     private final Uri mCombinedUriWithProfile;
     private final Uri mUpdateHistoryUriWithProfile;
     private final Uri mFaviconsUriWithProfile;
@@ -754,22 +754,23 @@ public class LocalBrowserDB {
                                   Bookmarks.PARENT + " = ? OR " +
                                   Bookmarks.PARENT + " = ?",
                                   new String[] { String.valueOf(getFolderIdFromGuid(cr, Bookmarks.TOOLBAR_FOLDER_GUID)),
                                                  String.valueOf(getFolderIdFromGuid(cr, Bookmarks.MENU_FOLDER_GUID)),
                                                  String.valueOf(getFolderIdFromGuid(cr, Bookmarks.UNFILED_FOLDER_GUID)) },
                                   null);
 
         try {
-            mDesktopBookmarksExist = c.getCount() > 0;
+            // Don't read back out of the cache to avoid races with invalidation.
+            final boolean e = c.getCount() > 0;
+            mDesktopBookmarksExist = e;
+            return e;
         } finally {
             c.close();
         }
-
-        return mDesktopBookmarksExist;
     }
 
     @RobocopTarget
     public boolean isBookmark(ContentResolver cr, String uri) {
         final Cursor c = cr.query(bookmarksUriWithLimit(1),
                                   new String[] { Bookmarks._ID },
                                   Bookmarks.URL + " = ? AND " + Bookmarks.PARENT + " != ?",
                                   new String[] { uri, String.valueOf(Bookmarks.FIXED_PINNED_LIST_ID) },