Skip to content

Commit 55dc7cb

Browse files
committed
Bug 1518587: Move startup profile selection to nsToolkitProfileService. r=froydnj
Currently nsAppRunner is responsible for choosing or creating a profile to use at startup. It then has to create a reset profile if necessary and lock the selected profile directories. But these latter things are done in different places of the selection code and done in different ways, sometimes we delay while trying to get the lock, sometimes we don't. This patch moves the profile selection part of the code to its own function so that then we only have to have one place that does the profile reset and locking logic. It makes a lot of sense to have the selection code live in the profile service. It can use information from the database load to help make the choices and it also means that we can expose the profile selection code through xpcom allowing it to be easily automatically tested. It will also be more important for future patches for the dedicated profiles feature. Differential Revision: https://phabricator.services.mozilla.com/D16116 --HG-- extra : moz-landing-system : lando
1 parent 4a86022 commit 55dc7cb

26 files changed

+1152
-531
lines changed

browser/components/migration/tests/marionette/test_refresh_firefox.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ def doReset(self):
541541
env.set("MOZ_MARIONETTE_PREF_STATE_ACROSS_RESTARTS", JSON.stringify(prefObj));
542542
env.set("MOZ_RESET_PROFILE_RESTART", "1");
543543
env.set("XRE_PROFILE_PATH", arguments[0]);
544-
env.set("XRE_PROFILE_NAME", profileName);
545544
""", script_args=(self.marionette.instance.profile.profile, profileName,))
546545

547546
profileLeafName = os.path.basename(os.path.normpath(

toolkit/profile/moz.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
88

9+
XPCSHELL_TESTS_MANIFESTS += ['xpcshell/xpcshell.ini']
10+
911
if CONFIG['ENABLE_TESTS']:
1012
DIRS += ['gtest']
1113

toolkit/profile/nsIToolkitProfileService.idl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface nsIFile;
1010
interface nsIToolkitProfile;
1111
interface nsIProfileLock;
1212

13-
[scriptable, uuid(1947899b-f369-48fa-89da-f7c37bb1e6bc)]
13+
[scriptable, builtinclass, uuid(1947899b-f369-48fa-89da-f7c37bb1e6bc)]
1414
interface nsIToolkitProfileService : nsISupports
1515
{
1616
attribute boolean startWithLastProfile;
@@ -37,6 +37,28 @@ interface nsIToolkitProfileService : nsISupports
3737
*/
3838
attribute nsIToolkitProfile defaultProfile;
3939

40+
/**
41+
* Selects or creates a profile to use based on the profiles database, any
42+
* environment variables and any command line arguments. Will not create
43+
* a profile if aIsResetting is true. The profile is selected based on this
44+
* order of preference:
45+
* * Environment variables (set when restarting the application).
46+
* * --profile command line argument.
47+
* * --createprofile command line argument (this also causes the app to exit).
48+
* * -p command line argument.
49+
* * A new profile created if this is the first run of the application.
50+
* * The default profile.
51+
* aRootDir and aLocalDir are set to the data and local directories for the
52+
* profile data. If a profile from the database was selected it will be
53+
* returned in aProfile.
54+
* This returns true if a new profile was created.
55+
* This method is primarily for testing. It can be called only once.
56+
*/
57+
bool selectStartupProfile(in Array<ACString> aArgv,
58+
in boolean aIsResetting,
59+
out nsIFile aRootDir, out nsIFile aLocalDir,
60+
out nsIToolkitProfile aProfile);
61+
4062
/**
4163
* Get a profile by name. This is mainly for use by the -P
4264
* commandline flag.

0 commit comments

Comments
 (0)