Bug 718240 - Use 30 second timeout for crash restore. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Mon, 19 Mar 2012 11:20:42 -0700
changeset 91888 3cf12ee16e7f6a2c9af798de0e13c4332427cda9
parent 91887 c120dd831b3f14b72f7b1afd1994a26e0cc0cbea
child 91890 d334b443ef9e5503731bbba2699c37d592a1ece0
push idunknown
push userunknown
push dateunknown
reviewersmfinkle
bugs718240
milestone14.0a1
Bug 718240 - Use 30 second timeout for crash restore. r=mfinkle
mobile/android/app/mobile.js
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoProfile.java
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -140,17 +140,17 @@ pref("browser.display.history.maxresults
 pref("browser.display.remotetabs.timeout", 10);
 
 /* session history */
 pref("browser.sessionhistory.max_total_viewers", 1);
 pref("browser.sessionhistory.max_entries", 50);
 
 /* session store */
 pref("browser.sessionstore.resume_session_once", false);
-pref("browser.sessionstore.resume_from_crash", true);
+pref("browser.sessionstore.resume_from_crash", false);
 pref("browser.sessionstore.resume_from_crash_timeout", 60); // minutes
 pref("browser.sessionstore.interval", 10000); // milliseconds
 pref("browser.sessionstore.max_tabs_undo", 1);
 pref("browser.sessionstore.max_resumed_crashes", 1);
 pref("browser.sessionstore.recent_crashes", 0);
 
 /* these should help performance */
 pref("mozilla.widget.force-24bpp", true);
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1672,19 +1672,20 @@ abstract public class GeckoApp
 
         mBrowserToolbar.setTitle(mLastTitle);
 
         String passedUri = null;
         String uri = getURIFromIntent(intent);
         if (uri != null && uri.length() > 0)
             passedUri = mLastTitle = uri;
 
+        mRestoreSession |= getProfile().shouldRestoreSession();
         if (passedUri == null || passedUri.equals("about:home")) {
             // show about:home if we aren't restoring previous session
-            if (! getProfile().hasSession()) {
+            if (!mRestoreSession) {
                 mBrowserToolbar.updateTabCount(1);
                 showAboutHome();
             }
         } else {
             mBrowserToolbar.updateTabCount(1);
         }
 
         Uri data = intent.getData();
--- a/mobile/android/base/GeckoProfile.java
+++ b/mobile/android/base/GeckoProfile.java
@@ -28,16 +28,19 @@ public final class GeckoProfile {
 
     private static HashMap<String, GeckoProfile> sProfileCache = new HashMap<String, GeckoProfile>();
 
     private final Context mContext;
     private final String mName;
     private File mMozDir;
     private File mDir;
 
+    // this short timeout is a temporary fix until bug 735399 is implemented
+    private static final long SESSION_TIMEOUT = 30 * 1000; // 30 seconds
+
     public static GeckoProfile get(Context context) {
         return get(context, null);
     }
 
     public static GeckoProfile get(Context context, String profileName) {
         if (context == null) {
             throw new IllegalArgumentException("context must be non-null");
         }
@@ -75,22 +78,29 @@ public final class GeckoProfile {
                 Log.d(LOGTAG, "Found profile dir: " + mDir.getAbsolutePath());
             }
         } catch (IOException ioe) {
             Log.e(LOGTAG, "Error getting profile dir", ioe);
         }
         return mDir;
     }
 
-    public boolean hasSession() {
+    public boolean shouldRestoreSession() {
         Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - start check sessionstore.js exists");
         File dir = getDir();
-        boolean hasSession = (dir != null && new File(dir, "sessionstore.js").exists());
+        if (dir == null)
+            return false;
+
+        File sessionFile = new File(dir, "sessionstore.js");
+        if (!sessionFile.exists())
+            return false;
+
+        boolean shouldRestore = (System.currentTimeMillis() - sessionFile.lastModified() < SESSION_TIMEOUT);
         Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - finish check sessionstore.js exists");
-        return hasSession;
+        return shouldRestore;
     }
 
     public String readSessionFile(boolean geckoReady) {
         File dir = getDir();
         if (dir == null) {
             return null;
         }