Bug 1518639: Move offline command line argument handling alongside the other command line argument handling. r=froydnj
☠☠ backed out by fc8431c4497f ☠ ☠
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 12 Feb 2019 17:36:30 +0000
changeset 458769 0780bd0ba2e1
parent 458768 14c454f88604
child 458770 e2a0ca34bab9
push id35548
push useropoprus@mozilla.com
push dateWed, 13 Feb 2019 09:48:26 +0000
treeherdermozilla-central@93e37c529818 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1518639
milestone67.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 1518639: Move offline command line argument handling alongside the other command line argument handling. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D19417
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2065,53 +2065,39 @@ static nsCOMPtr<nsIToolkitProfile> gRese
 // 1) check for --profile <path>
 // 2) check for -P <name>
 // 3) check for --ProfileManager
 // 4) use the default profile, if there is one
 // 5) if there are *no* profiles, set up profile-migration
 // 6) display the profile-manager UI
 static nsresult SelectProfile(nsIProfileLock** aResult,
                               nsToolkitProfileService* aProfileSvc,
-                              nsINativeAppSupport* aNative,
-                              bool* aStartOffline) {
+                              nsINativeAppSupport* aNative) {
   StartupTimeline::Record(StartupTimeline::SELECT_PROFILE);
 
   nsresult rv;
-  ArgResult ar;
   *aResult = nullptr;
-  *aStartOffline = false;
-
-  ar = CheckArg("offline", nullptr,
-                CheckArgFlag::CheckOSInt | CheckArgFlag::RemoveArg);
-  if (ar == ARG_BAD) {
-    PR_fprintf(PR_STDERR,
-               "Error: argument --offline is invalid when argument --osint is "
-               "specified\n");
-    return NS_ERROR_FAILURE;
-  }
-
-  if (ar || EnvHasValue("XRE_START_OFFLINE")) *aStartOffline = true;
 
   if (EnvHasValue("MOZ_RESET_PROFILE_RESTART")) {
     gDoProfileReset = true;
     gDoMigration = true;
     SaveToEnv("MOZ_RESET_PROFILE_RESTART=");
     // We only want to restore the previous session if the profile refresh was
     // triggered by user. And if it was a user-triggered profile refresh
     // through, say, the safeMode dialog or the troubleshooting page, the
     // MOZ_RESET_PROFILE_RESTART env variable would be set. Hence we set
     // MOZ_RESET_PROFILE_MIGRATE_SESSION here so that Firefox profile migrator
     // would migrate old session data later.
     SaveToEnv("MOZ_RESET_PROFILE_MIGRATE_SESSION=1");
   }
 
   // reset-profile and migration args need to be checked before any profiles are
   // chosen below.
-  ar = CheckArg("reset-profile", nullptr,
-                CheckArgFlag::CheckOSInt | CheckArgFlag::RemoveArg);
+  ArgResult ar = CheckArg("reset-profile", nullptr,
+                          CheckArgFlag::CheckOSInt | CheckArgFlag::RemoveArg);
   if (ar == ARG_BAD) {
     PR_fprintf(PR_STDERR,
                "Error: argument --reset-profile is invalid when argument "
                "--osint is specified\n");
     return NS_ERROR_FAILURE;
   }
   if (ar == ARG_FOUND) {
     gDoProfileReset = true;
@@ -3520,16 +3506,29 @@ int XREMain::XRE_mainInit(bool* aExitFla
                "Error: argument --new-instance is invalid when argument "
                "--osint is specified\n");
     return 1;
   }
   if (ar == ARG_FOUND) {
     SaveToEnv("MOZ_NEW_INSTANCE=1");
   }
 
+  ar = CheckArg("offline", nullptr,
+                CheckArgFlag::CheckOSInt | CheckArgFlag::RemoveArg);
+  if (ar == ARG_BAD) {
+    PR_fprintf(PR_STDERR,
+               "Error: argument --offline is invalid when argument --osint is "
+               "specified\n");
+    return 1;
+  }
+
+  if (ar || EnvHasValue("XRE_START_OFFLINE")) {
+    mStartOffline = true;
+  }
+
   // Handle --help and --version command line arguments.
   // They should return quickly, so we deal with them here.
   if (CheckArg("h") || CheckArg("help") || CheckArg("?")) {
     DumpHelp();
     *aExitFlag = true;
     return 0;
   }
 
@@ -4165,18 +4164,17 @@ int XREMain::XRE_mainStartup(bool* aExit
                "your profile directory.\n");
   }
   if (NS_FAILED(rv)) {
     // We failed to choose or create profile - notify user and quit
     ProfileMissingDialog(mNativeApp);
     return 1;
   }
 
-  rv = SelectProfile(getter_AddRefs(mProfileLock), mProfileSvc, mNativeApp,
-                     &mStartOffline);
+  rv = SelectProfile(getter_AddRefs(mProfileLock), mProfileSvc, mNativeApp);
   if (rv == NS_ERROR_LAUNCHED_CHILD_PROCESS || rv == NS_ERROR_ABORT) {
     *aExitFlag = true;
     return 0;
   }
 
   if (NS_FAILED(rv)) {
     // We failed to choose or create profile - notify user and quit
     ProfileMissingDialog(mNativeApp);