зеркало из https://github.com/mozilla/gecko-dev.git
Bug 735399- Only do session restore after a crash. r=mfinkle
This commit is contained in:
Родитель
39f47dc615
Коммит
81eb7d1e39
|
@ -133,6 +133,7 @@ public class CrashReporter extends Activity
|
|||
getSharedPreferences(GeckoApp.PREFS_NAME, 0);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putBoolean(GeckoApp.PREFS_WAS_STOPPED, true);
|
||||
editor.putBoolean(GeckoApp.PREFS_CRASHED, true);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
|
|
|
@ -146,6 +146,7 @@ abstract public class GeckoApp
|
|||
public static final String PREFS_NAME = "GeckoApp";
|
||||
public static final String PREFS_OOM_EXCEPTION = "OOMException";
|
||||
public static final String PREFS_WAS_STOPPED = "wasStopped";
|
||||
public static final String PREFS_CRASHED = "crashed";
|
||||
|
||||
static public final int RESTORE_NONE = 0;
|
||||
static public final int RESTORE_OOM = 1;
|
||||
|
@ -1790,7 +1791,19 @@ abstract public class GeckoApp
|
|||
}
|
||||
|
||||
protected boolean shouldRestoreSession() {
|
||||
return getProfile().shouldRestoreSession();
|
||||
SharedPreferences prefs = GeckoApp.mAppContext.getSharedPreferences(PREFS_NAME, 0);
|
||||
|
||||
// We record crashes in the crash reporter. If sessionstore.js
|
||||
// exists, but we didn't flag a crash in the crash reporter, we
|
||||
// were probably just force killed by the user, so we shouldn't do
|
||||
// a restore.
|
||||
if (prefs.getBoolean(PREFS_CRASHED, false)) {
|
||||
prefs.edit().putBoolean(GeckoApp.PREFS_CRASHED, false).commit();
|
||||
if (getProfile().shouldRestoreSession()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,9 +35,6 @@ public final class GeckoProfile {
|
|||
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
|
||||
|
||||
static private INIParser getProfilesINI(Context context) {
|
||||
File filesDir = context.getFilesDir();
|
||||
File mozillaDir = new File(filesDir, "mozilla");
|
||||
|
@ -185,11 +182,7 @@ public final class GeckoProfile {
|
|||
*/
|
||||
public boolean shouldRestoreSession() {
|
||||
File sessionFile = getFile("sessionstore.js");
|
||||
if (sessionFile == null || !sessionFile.exists())
|
||||
return false;
|
||||
|
||||
boolean shouldRestore = (System.currentTimeMillis() - sessionFile.lastModified() < SESSION_TIMEOUT);
|
||||
return shouldRestore;
|
||||
return sessionFile != null && sessionFile.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче