Bug 736296: Avoid managed query while loading top sites. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Tue, 27 Mar 2012 14:31:29 -0700
changeset 90679 ddd5f1d102152d158f9676c12a1eceb6c69aa4c1
parent 90678 c6f1af4f27cdf6c2866c5bff0aef2b3e278927b6
child 90680 9f553761e367beca8d307f31f75e842723037fec
push id1069
push usermfinkle@mozilla.com
push dateWed, 04 Apr 2012 14:22:33 +0000
treeherdermozilla-aurora@883536e3b5da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs736296
milestone13.0a2
Bug 736296: Avoid managed query while loading top sites. [r=mfinkle]
mobile/android/base/AboutHomeContent.java
--- a/mobile/android/base/AboutHomeContent.java
+++ b/mobile/android/base/AboutHomeContent.java
@@ -245,16 +245,19 @@ public class AboutHomeContent extends Sc
         };
     }
 
     public void onDestroy() {
         if (mAccountListener != null) {
             mAccountManager.removeOnAccountsUpdatedListener(mAccountListener);
             mAccountListener = null;
         }
+
+        if (mCursor != null && !mCursor.isClosed())
+            mCursor.close();
     }
 
     void setLastTabsVisibility(boolean visible) {
         if (visible)
             mLastTabs.show();
         else
             mLastTabs.hide();
     }
@@ -325,31 +328,27 @@ public class AboutHomeContent extends Sc
         Configuration config = getContext().getResources().getConfiguration();
         if (config.orientation == Configuration.ORIENTATION_LANDSCAPE)
             return NUMBER_OF_COLS_LANDSCAPE;
         else
             return NUMBER_OF_COLS_PORTRAIT;
     }
 
     private void loadTopSites(final Activity activity) {
-        if (mCursor != null)
-            activity.stopManagingCursor(mCursor);
-
         // Ensure we initialize GeckoApp's startup mode in
         // background thread before we use it when updating
         // the top sites section layout in main thread.
         final GeckoApp.StartupMode startupMode = GeckoApp.mAppContext.getStartupMode();
 
         // The isSyncSetup method should not be called on
         // UI thread as it touches disk to access a sqlite DB.
         final boolean syncIsSetup = isSyncSetup();
 
         ContentResolver resolver = GeckoApp.mAppContext.getContentResolver();
         mCursor = BrowserDB.getTopSites(resolver, NUMBER_OF_TOP_SITES_PORTRAIT);
-        activity.startManagingCursor(mCursor);
 
         GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
             public void run() {
                 if (mTopSitesAdapter == null) {
                     mTopSitesAdapter = new TopSitesCursorAdapter(activity,
                                                                  R.layout.abouthome_topsite_item,
                                                                  mCursor,
                                                                  new String[] { URLColumns.TITLE,