Bug 1266339 - Part 1 - Move session store file names in GeckoProfile into named constants. r=margaret draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 21 Apr 2016 20:28:38 +0200
changeset 367518 3f5f67b7ce87a935761477ec80cb10cbcbbb91d1
parent 367455 f0be41981cdc124d32718cf873d02a46723cbd39
child 367519 b8adc0fc9963fe8096204cc2cd808a2ac0f5ebce
child 367837 2a6383f430691a683fb15149d684ff7be81537f1
push id18255
push usermozilla@buttercookie.de
push dateMon, 16 May 2016 19:40:39 +0000
reviewersmargaret
bugs1266339
milestone49.0a1
Bug 1266339 - Part 1 - Move session store file names in GeckoProfile into named constants. r=margaret MozReview-Commit-ID: 8QESeQ5P6Ys
mobile/android/base/java/org/mozilla/gecko/GeckoProfile.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoProfile.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoProfile.java
@@ -68,16 +68,20 @@ public final class GeckoProfile {
 
     // Used to "lock" the guest profile, so that we'll always restart in it
     private static final String LOCK_FILE_NAME = ".active_lock";
     public static final String DEFAULT_PROFILE = "default";
     // Profile is using a custom directory outside of the Mozilla directory.
     public static final String CUSTOM_PROFILE = "";
     public static final String GUEST_PROFILE = "guest";
 
+    // Session store
+    private static final String SESSION_FILE = "sessionstore.js";
+    private static final String SESSION_FILE_BACKUP = "sessionstore.bak";
+
     private static final HashMap<String, GeckoProfile> sProfileCache = new HashMap<String, GeckoProfile>();
     private static String sDefaultProfileName;
 
     // Caches the guest profile dir.
     private static File sGuestDir;
     private static GeckoProfile sGuestProfile;
     private static boolean sShouldCheckForGuestProfile = true;
 
@@ -762,19 +766,19 @@ public final class GeckoProfile {
      * sessionstore.js should hold the current session, and sessionstore.bak
      * should hold the previous session (where it is used to read the "tabs
      * from last time"). Normally, sessionstore.js is moved to sessionstore.bak
      * on a clean quit, but this doesn't happen if Fennec crashed. Thus, this
      * method should be called after a crash so sessionstore.bak correctly
      * holds the previous session.
      */
     public void moveSessionFile() {
-        File sessionFile = getFile("sessionstore.js");
+        File sessionFile = getFile(SESSION_FILE);
         if (sessionFile != null && sessionFile.exists()) {
-            File sessionFileBackup = getFile("sessionstore.bak");
+            File sessionFileBackup = getFile(SESSION_FILE_BACKUP);
             sessionFile.renameTo(sessionFileBackup);
         }
     }
 
     /**
      * Get the string from a session file.
      *
      * The session can either be read from sessionstore.js or sessionstore.bak.
@@ -782,17 +786,17 @@ public final class GeckoProfile {
      * sessionstore.bak holds the previous session.
      *
      * @param readBackup if true, the session is read from sessionstore.bak;
      *                   otherwise, the session is read from sessionstore.js
      *
      * @return the session string
      */
     public String readSessionFile(boolean readBackup) {
-        File sessionFile = getFile(readBackup ? "sessionstore.bak" : "sessionstore.js");
+        File sessionFile = getFile(readBackup ? SESSION_FILE_BACKUP : SESSION_FILE);
 
         try {
             if (sessionFile != null && sessionFile.exists()) {
                 return readFile(sessionFile);
             }
         } catch (IOException ioe) {
             Log.e(LOGTAG, "Unable to read session file", ioe);
         }