Bug 1518639: Hold the profile service as its concrete type. r=froydnj

We cast the nsIToolkitProfileService to nsToolkitProfileService in a bunch of
places, might as well just hold that instead.

Differential Revision: https://phabricator.services.mozilla.com/D19414

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dave Townsend 2019-02-12 17:36:13 +00:00
Родитель 7972f03364
Коммит eb44cb01c4
3 изменённых файлов: 9 добавлений и 12 удалений

Просмотреть файл

@ -1585,7 +1585,7 @@ nsToolkitProfileFactory::CreateInstance(nsISupports* aOuter, const nsID& aIID,
void** aResult) {
if (aOuter) return NS_ERROR_NO_AGGREGATION;
nsCOMPtr<nsIToolkitProfileService> profileService =
RefPtr<nsToolkitProfileService> profileService =
nsToolkitProfileService::gService;
if (!profileService) {
nsresult rv = NS_NewToolkitProfileService(getter_AddRefs(profileService));
@ -1605,7 +1605,7 @@ nsresult NS_NewToolkitProfileFactory(nsIFactory** aResult) {
return NS_OK;
}
nsresult NS_NewToolkitProfileService(nsIToolkitProfileService** aResult) {
nsresult NS_NewToolkitProfileService(nsToolkitProfileService** aResult) {
nsToolkitProfileService* profileService = new nsToolkitProfileService();
if (!profileService) return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = profileService->Init();

Просмотреть файл

@ -84,7 +84,7 @@ class nsToolkitProfileService final : public nsIToolkitProfileService {
private:
friend class nsToolkitProfile;
friend class nsToolkitProfileFactory;
friend nsresult NS_NewToolkitProfileService(nsIToolkitProfileService**);
friend nsresult NS_NewToolkitProfileService(nsToolkitProfileService**);
nsToolkitProfileService();
~nsToolkitProfileService();

Просмотреть файл

@ -2069,7 +2069,7 @@ static nsCOMPtr<nsIToolkitProfile> gResetOldProfile;
// 5) if there are *no* profiles, set up profile-migration
// 6) display the profile-manager UI
static nsresult SelectProfile(nsIProfileLock** aResult,
nsIToolkitProfileService* aProfileSvc,
nsToolkitProfileService* aProfileSvc,
nsINativeAppSupport* aNative, bool* aStartOffline,
nsACString* aProfileName) {
StartupTimeline::Record(StartupTimeline::SELECT_PROFILE);
@ -2133,10 +2133,8 @@ static nsresult SelectProfile(nsIProfileLock** aResult,
nsCOMPtr<nsIFile> localDir;
nsCOMPtr<nsIToolkitProfile> profile;
// Ask the profile manager to select the profile directories to use.
nsToolkitProfileService* service =
static_cast<nsToolkitProfileService*>(aProfileSvc);
bool didCreate = false;
rv = service->SelectStartupProfile(
rv = aProfileSvc->SelectStartupProfile(
&gArgc, gArgv, gDoProfileReset, getter_AddRefs(rootDir),
getter_AddRefs(localDir), getter_AddRefs(profile), &didCreate);
@ -2173,7 +2171,7 @@ static nsresult SelectProfile(nsIProfileLock** aResult,
// If we're resetting a profile, create a new one and use it to startup.
gResetOldProfile = profile;
rv = service->CreateResetProfile(getter_AddRefs(profile));
rv = aProfileSvc->CreateResetProfile(getter_AddRefs(profile));
if (NS_SUCCEEDED(rv)) {
rv = profile->GetRootDir(getter_AddRefs(rootDir));
NS_ENSURE_SUCCESS(rv, rv);
@ -2993,7 +2991,7 @@ class XREMain {
Result<bool, nsresult> CheckLastStartupWasCrash();
nsCOMPtr<nsINativeAppSupport> mNativeApp;
nsCOMPtr<nsIToolkitProfileService> mProfileSvc;
RefPtr<nsToolkitProfileService> mProfileSvc;
nsCOMPtr<nsIFile> mProfD;
nsCOMPtr<nsIFile> mProfLD;
nsCOMPtr<nsIProfileLock> mProfileLock;
@ -4496,8 +4494,7 @@ nsresult XREMain::XRE_mainRun() {
}
if (gDoProfileReset) {
nsresult backupCreated = ProfileResetCleanup(
static_cast<nsToolkitProfileService*>(mProfileSvc.get()),
nsresult backupCreated = ProfileResetCleanup(mProfileSvc,
gResetOldProfile);
if (NS_FAILED(backupCreated))
NS_WARNING("Could not cleanup the profile that was reset");
@ -4695,7 +4692,7 @@ nsresult XREMain::XRE_mainRun() {
AddSandboxAnnotations();
#endif /* MOZ_CONTENT_SANDBOX */
static_cast<nsToolkitProfileService*>(mProfileSvc.get())->CompleteStartup();
mProfileSvc->CompleteStartup();
{
rv = appStartup->Run();