Bug 1304389 - Indent code performing session write; r?Yoric draft
authorGregory Szorc <gps@mozilla.com>
Fri, 23 Sep 2016 09:39:49 -0700
changeset 417097 04c37779beda52b343ff125b429a265dc91e1115
parent 416981 60cc643978c7020926fe4145761e26945fcd5c37
child 417098 abfa99ad90633d1f3a875e98fe7556a013876a71
push id30338
push usergszorc@mozilla.com
push dateFri, 23 Sep 2016 17:09:43 +0000
reviewersYoric
bugs1304389
milestone52.0a1
Bug 1304389 - Indent code performing session write; r?Yoric This will make the next change easier to read. MozReview-Commit-ID: 3RjrwEDK2zF
browser/components/sessionstore/SessionWorker.js
--- a/browser/components/sessionstore/SessionWorker.js
+++ b/browser/components/sessionstore/SessionWorker.js
@@ -162,49 +162,51 @@ var Agent = {
       }
 
       if (this.state == STATE_CLEAN) {
         // Move $Path.clean out of the way, to avoid any ambiguity as
         // to which file is more recent.
         File.move(this.Paths.clean, this.Paths.cleanBackup);
       }
 
-      startWriteMs = Date.now();
+      if (true) {
+        startWriteMs = Date.now();
 
-      if (options.isFinalWrite) {
-        // We are shutting down. At this stage, we know that
-        // $Paths.clean is either absent or corrupted. If it was
-        // originally present and valid, it has been moved to
-        // $Paths.cleanBackup a long time ago. We can therefore write
-        // with the guarantees that we erase no important data.
-        File.writeAtomic(this.Paths.clean, data, {
-          tmpPath: this.Paths.clean + ".tmp"
-        });
-      } else if (this.state == STATE_RECOVERY) {
-        // At this stage, either $Paths.recovery was written >= 15
-        // seconds ago during this session or we have just started
-        // from $Paths.recovery left from the previous session. Either
-        // way, $Paths.recovery is good. We can move $Path.backup to
-        // $Path.recoveryBackup without erasing a good file with a bad
-        // file.
-        File.writeAtomic(this.Paths.recovery, data, {
-          tmpPath: this.Paths.recovery + ".tmp",
-          backupTo: this.Paths.recoveryBackup
-        });
-      } else {
-        // In other cases, either $Path.recovery is not necessary, or
-        // it doesn't exist or it has been corrupted. Regardless,
-        // don't backup $Path.recovery.
-        File.writeAtomic(this.Paths.recovery, data, {
-          tmpPath: this.Paths.recovery + ".tmp"
-        });
+        if (options.isFinalWrite) {
+          // We are shutting down. At this stage, we know that
+          // $Paths.clean is either absent or corrupted. If it was
+          // originally present and valid, it has been moved to
+          // $Paths.cleanBackup a long time ago. We can therefore write
+          // with the guarantees that we erase no important data.
+          File.writeAtomic(this.Paths.clean, data, {
+            tmpPath: this.Paths.clean + ".tmp"
+          });
+        } else if (this.state == STATE_RECOVERY) {
+          // At this stage, either $Paths.recovery was written >= 15
+          // seconds ago during this session or we have just started
+          // from $Paths.recovery left from the previous session. Either
+          // way, $Paths.recovery is good. We can move $Path.backup to
+          // $Path.recoveryBackup without erasing a good file with a bad
+          // file.
+          File.writeAtomic(this.Paths.recovery, data, {
+            tmpPath: this.Paths.recovery + ".tmp",
+            backupTo: this.Paths.recoveryBackup
+          });
+        } else {
+          // In other cases, either $Path.recovery is not necessary, or
+          // it doesn't exist or it has been corrupted. Regardless,
+          // don't backup $Path.recovery.
+          File.writeAtomic(this.Paths.recovery, data, {
+            tmpPath: this.Paths.recovery + ".tmp"
+          });
+        }
+
+        stopWriteMs = Date.now();
       }
 
-      stopWriteMs = Date.now();
-
     } catch (ex) {
       // Don't throw immediately
       exn = exn || ex;
     }
 
     // If necessary, perform an upgrade backup
     let upgradeBackupComplete = false;
     if (this.upgradeBackupNeeded