Bug 1266104 - Ensure SavedReaderViewHelper is loaded for recent tabs panel r=margaret
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 20 Apr 2016 22:02:49 +0200
changeset 331953 a1823d3e691960016d156ed062eb416d2d135707
parent 331952 59ce733181109d13ec748b94d2069ebe699be33b
child 331954 c1a9497a212d54fda334e9174aac33926196df8e
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1266104
milestone48.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 1266104 - Ensure SavedReaderViewHelper is loaded for recent tabs panel r=margaret I wonder if there is a better solution to guarantee we have the necessary data loaded, however this seems to be the only special case (i.e. the only place we use TwoLinePageRow without the DB having been loaded first). MozReview-Commit-ID: F4iAIpe87IY
mobile/android/base/java/org/mozilla/gecko/home/RecentTabsPanel.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/RecentTabsPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/RecentTabsPanel.java
@@ -17,16 +17,17 @@ import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.SessionParser;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.db.BrowserContract.CommonColumns;
 import org.mozilla.gecko.db.BrowserContract.URLColumns;
+import org.mozilla.gecko.reader.SavedReaderViewHelper;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.NativeEventListener;
 import org.mozilla.gecko.util.NativeJSObject;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.content.Context;
 import android.database.Cursor;
 import android.database.MatrixCursor;
@@ -281,16 +282,25 @@ public class RecentTabsPanel extends Hom
             row.add(url);
             row.add(title);
             row.add(type);
             row.add(data);
         }
 
         @Override
         public Cursor loadCursor() {
+            // TwoLinePageRow requires the SavedReaderViewHelper to be initialised. Usually this is
+            // done as part of BrowserDatabaseHelper.onOpen(), however we don't actually access
+            // the DB when showing the Recent Tabs panel, hence it's possible that the SavedReaderViewHelper
+            // isn't loaded. Therefore we need to explicitly force loading here.
+            // Note: loadCursor is run on a background thread, hence it's safe to do this here.
+            // (loading time is a few ms, and hence shouldn't impact overall loading time for this
+            // panel in any significant way).
+            SavedReaderViewHelper.getSavedReaderViewHelper(getContext()).loadItems();
+
             final Context context = getContext();
 
             final MatrixCursor c = new MatrixCursor(new String[] { RecentTabs._ID,
                                                                    RecentTabs.URL,
                                                                    RecentTabs.TITLE,
                                                                    RecentTabs.TYPE,
                                                                    RecentTabs.DATA});