Bug 931918 - Part 0: Tidying and logging. r=bnicholson, a=bajaj
authorRichard Newman <rnewman@mozilla.com>
Thu, 31 Oct 2013 10:35:16 -0700
changeset 166380 d0c8aba6bfb047597329cd0051433d4f1a524072
parent 166379 2535acbe5c168d4140420668a13bf282408ca2b7
child 166381 aee9feb9c9bb0c6ba220c84b5162f7a852d4ab06
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnicholson, bajaj
bugs931918
milestone27.0a2
Bug 931918 - Part 0: Tidying and logging. r=bnicholson, a=bajaj
mobile/android/base/db/BrowserProvider.java
mobile/android/base/db/LocalBrowserDB.java
mobile/android/base/home/TopSitesPage.java
--- a/mobile/android/base/db/BrowserProvider.java
+++ b/mobile/android/base/db/BrowserProvider.java
@@ -2028,16 +2028,18 @@ public class BrowserProvider extends Con
 
         if (uri != null)
             profile = uri.getQueryParameter(BrowserContract.PARAM_PROFILE);
 
         return getDatabaseHelperForProfile(profile, isTest(uri)).getWritableDatabase();
     }
 
     private void cleanupSomeDeletedRecords(Uri fromUri, Uri targetUri, String tableName) {
+        Log.d(LOGTAG, "Cleaning up deleted records from " + tableName);
+
         // we cleanup records marked as deleted that are older than a
         // predefined max age. It's important not be too greedy here and
         // remove only a few old deleted records at a time.
 
         // The PARAM_SHOW_DELETED argument is necessary to return the records
         // that were marked as deleted. We use PARAM_IS_SYNC here to ensure
         // that we'll be actually deleting records instead of flagging them.
         Uri.Builder uriBuilder = targetUri.buildUpon()
@@ -2085,16 +2087,17 @@ public class BrowserProvider extends Con
      *
      * Provide <code>keepAfter</code> less than or equal to zero to skip that check.
      *
      * Items will be removed according to an approximate frecency calculation.
      *
      * Call this method within a transaction.
      */
     private void expireHistory(final SQLiteDatabase db, final int retain, final long keepAfter) {
+        Log.d(LOGTAG, "Expiring history.");
         final long rows = DatabaseUtils.queryNumEntries(db, TABLE_HISTORY);
 
         if (retain >= rows) {
             debug("Not expiring history: only have " + rows + " rows.");
             return;
         }
 
         final String sortOrder = BrowserContract.getFrecencySortOrder(false, true);
@@ -2120,16 +2123,17 @@ public class BrowserProvider extends Con
 
     /**
      * Remove any thumbnails that for sites that aren't likely to be ever shown.
      * Items will be removed according to a frecency calculation and only if they are not pinned
      *
      * Call this method within a transaction.
      */
     private void expireThumbnails(final SQLiteDatabase db) {
+        Log.d(LOGTAG, "Expiring thumbnails.");
         final String sortOrder = BrowserContract.getFrecencySortOrder(true, false);
         final String sql = "DELETE FROM " + TABLE_THUMBNAILS +
                            " WHERE " + Thumbnails.URL + " NOT IN ( " +
                              " SELECT " + Combined.URL +
                              " FROM " + VIEW_COMBINED +
                              " ORDER BY " + sortOrder +
                              " LIMIT " + DEFAULT_EXPIRY_THUMBNAIL_COUNT +
                            ") AND " + Thumbnails.URL + " NOT IN ( " +
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -775,18 +775,19 @@ public class LocalBrowserDB implements B
         Uri faviconsUri = getAllFaviconsUri().buildUpon().
                 appendQueryParameter(BrowserContract.PARAM_INSERT_IF_NEEDED, "true").build();
 
         int updated = cr.update(faviconsUri,
                                 values,
                                 Favicons.URL + " = ?",
                                 new String[] { faviconUri });
 
-        if (updated == 0)
+        if (updated == 0) {
             cr.insert(mFaviconsUriWithProfile, values);
+        }
     }
 
     @Override
     public void updateThumbnailForUrl(ContentResolver cr, String uri,
             BitmapDrawable thumbnail) {
         Bitmap bitmap = thumbnail.getBitmap();
 
         byte[] data = null;
--- a/mobile/android/base/home/TopSitesPage.java
+++ b/mobile/android/base/home/TopSitesPage.java
@@ -510,16 +510,17 @@ public class TopSitesPage extends HomeFr
         @Override
         public View newView(Context context, Cursor cursor, ViewGroup parent) {
             return LayoutInflater.from(context).inflate(R.layout.bookmark_item_row, parent, false);
         }
     }
 
     public class TopSitesGridAdapter extends CursorAdapter {
         // Cache to store the thumbnails.
+        // Ensure that this is only accessed from the UI thread.
         private Map<String, Bitmap> mThumbnails;
 
         public TopSitesGridAdapter(Context context, Cursor cursor) {
             super(context, cursor, 0);
         }
 
         @Override
         public int getCount() {