Bug 1234012 - Do not try to copy files from the non-existing default profile. r=bsmedberg
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 25 Dec 2015 07:36:02 +0900
changeset 279175 67f78903bbce0d12bb2b1d66d3cd81fcc315c49c
parent 279174 b083f0748d81ca48810dfcf6ef503d77d065b2bd
child 279176 ad491a4fcf8af0454fa90e5bd8e69c87efcecfe3
push id29871
push userphilringnalda@gmail.com
push dateSat, 09 Jan 2016 19:40:57 +0000
treeherdermozilla-central@9afb89dd315f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs1234012
milestone46.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 1234012 - Do not try to copy files from the non-existing default profile. r=bsmedberg When creating the profile for the first time, we're trying to copy files that just don't exist, so we just skip that. No code in mozilla-central or comm-central was using the optional argument to pass a custom default profile either, so that goes away as well.
toolkit/profile/nsIToolkitProfileService.idl
toolkit/profile/nsToolkitProfileService.cpp
--- a/toolkit/profile/nsIToolkitProfileService.idl
+++ b/toolkit/profile/nsIToolkitProfileService.idl
@@ -5,17 +5,17 @@
 
 #include "nsISupports.idl"
 
 interface nsISimpleEnumerator;
 interface nsIFile;
 interface nsIToolkitProfile;
 interface nsIProfileLock;
 
-[scriptable, uuid(b81c33a6-1ce8-4695-856b-02b7f15cc114)]
+[scriptable, uuid(1947899b-f369-48fa-89da-f7c37bb1e6bc)]
 interface nsIToolkitProfileService : nsISupports
 {
     attribute boolean startWithLastProfile;
     attribute boolean startOffline;
 
     readonly attribute nsISimpleEnumerator /*nsIToolkitProfile*/ profiles;
 
     /**
@@ -74,33 +74,27 @@ interface nsIToolkitProfileService : nsI
      * The profile will be typically in
      * {Application Data}/.profilename/{salt}.default or
      * {Application Data}/.appname/{salt}.default
      * or if aVendorName is provided
      * {Application Data}/.vendor/appname/{salt}.default
      *
      * @note Either aProfileName or aAppName must be non-empty
      *
-     * The contents of aProfileDefaultsDir will be copied to the
-     * new profile directory.
-     * 
      * @param  aProfileName
      *         The name of the profile
      * @param  aAppName
      *         The name of the application
      * @param  aVendorName
      *         The name of the vendor
-     * @param  aProfileDefaultsDir
-     *         The location where the profile defaults are.
      * @return The created profile.
      */                                    
     nsIToolkitProfile createDefaultProfileForApp(in AUTF8String aProfileName,
                                                  in AUTF8String aAppName,
-                                                 in AUTF8String aVendorName,
-                                                 [optional] in nsIFile aProfileDefaultsDir);
+                                                 in AUTF8String aVendorName);
 
     /**
      * Returns the number of profiles.
      * @return 0, 1, or 2. More than 2 profiles will always return 2.
      */
     readonly attribute unsigned long profileCount;
 
     /**
--- a/toolkit/profile/nsToolkitProfileService.cpp
+++ b/toolkit/profile/nsToolkitProfileService.cpp
@@ -130,17 +130,16 @@ private:
 
     nsresult CreateTimesInternal(nsIFile *profileDir);
 
     nsresult CreateProfileInternal(nsIFile* aRootDir,
                                    const nsACString& aName,
                                    const nsACString* aProfileName,
                                    const nsACString* aAppName,
                                    const nsACString* aVendorName,
-                                   /*in*/ nsIFile** aProfileDefaultsDir,
                                    bool aForExternalApp,
                                    nsIToolkitProfile** aResult);
 
     RefPtr<nsToolkitProfile>  mFirst;
     nsCOMPtr<nsIToolkitProfile> mChosen;
     nsCOMPtr<nsIToolkitProfile> mDefault;
     nsCOMPtr<nsIFile>           mAppData;
     nsCOMPtr<nsIFile>           mTempData;
@@ -704,17 +703,16 @@ static void SaltProfileName(nsACString& 
 
     aName.Insert(salt, 0, 9);
 }
 
 NS_IMETHODIMP
 nsToolkitProfileService::CreateDefaultProfileForApp(const nsACString& aProfileName,
                                                     const nsACString& aAppName,
                                                     const nsACString& aVendorName,
-                                                    nsIFile* aProfileDefaultsDir,
                                                     nsIToolkitProfile** aResult)
 {
     NS_ENSURE_STATE(!aProfileName.IsEmpty() || !aAppName.IsEmpty());
     nsCOMPtr<nsIFile> appData;
     nsresult rv =
         gDirServiceProvider->GetUserDataDirectory(getter_AddRefs(appData),
                                                   false,
                                                   &aProfileName,
@@ -726,21 +724,20 @@ nsToolkitProfileService::CreateDefaultPr
     appData->Clone(getter_AddRefs(profilesini));
     rv = profilesini->AppendNative(NS_LITERAL_CSTRING("profiles.ini"));
     NS_ENSURE_SUCCESS(rv, rv);
 
     bool exists = false;
     profilesini->Exists(&exists);
     NS_ENSURE_FALSE(exists, NS_ERROR_ALREADY_INITIALIZED);
 
-    nsIFile* profileDefaultsDir = aProfileDefaultsDir;
     rv = CreateProfileInternal(nullptr,
                                NS_LITERAL_CSTRING("default"),
                                &aProfileName, &aAppName, &aVendorName,
-                               &profileDefaultsDir, true, aResult);
+                               true, aResult);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_STATE(*aResult);
 
     nsCOMPtr<nsIFile> rootDir;
     (*aResult)->GetRootDir(getter_AddRefs(rootDir));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsAutoCString profileDir;
@@ -773,26 +770,25 @@ nsToolkitProfileService::CreateDefaultPr
 }
 
 NS_IMETHODIMP
 nsToolkitProfileService::CreateProfile(nsIFile* aRootDir,
                                        const nsACString& aName,
                                        nsIToolkitProfile** aResult)
 {
     return CreateProfileInternal(aRootDir, aName,
-                                 nullptr, nullptr, nullptr, nullptr, false, aResult);
+                                 nullptr, nullptr, nullptr, false, aResult);
 }
 
 nsresult
 nsToolkitProfileService::CreateProfileInternal(nsIFile* aRootDir,
                                                const nsACString& aName,
                                                const nsACString* aProfileName,
                                                const nsACString* aAppName,
                                                const nsACString* aVendorName,
-                                               nsIFile** aProfileDefaultsDir,
                                                bool aForExternalApp,
                                                nsIToolkitProfile** aResult)
 {
     nsresult rv = NS_ERROR_FAILURE;
 
     if (!aForExternalApp) {
         rv = GetProfileByName(aName, aResult);
         if (NS_SUCCEEDED(rv)) {
@@ -844,42 +840,28 @@ nsToolkitProfileService::CreateProfileIn
     if (exists) {
         rv = rootDir->IsDirectory(&exists);
         NS_ENSURE_SUCCESS(rv, rv);
 
         if (!exists)
             return NS_ERROR_FILE_NOT_DIRECTORY;
     }
     else {
-        nsCOMPtr<nsIFile> profileDefaultsDir;
         nsCOMPtr<nsIFile> profileDirParent;
         nsAutoString profileDirName;
 
         rv = rootDir->GetParent(getter_AddRefs(profileDirParent));
         NS_ENSURE_SUCCESS(rv, rv);
 
         rv = rootDir->GetLeafName(profileDirName);
         NS_ENSURE_SUCCESS(rv, rv);
 
-        if (aProfileDefaultsDir) {
-            profileDefaultsDir = *aProfileDefaultsDir;
-        } else {
-            bool dummy;
-            rv = gDirServiceProvider->GetFile(NS_APP_PROFILE_DEFAULTS_50_DIR, &dummy,
-                                              getter_AddRefs(profileDefaultsDir));
-        }
-
-        if (NS_SUCCEEDED(rv) && profileDefaultsDir)
-            rv = profileDefaultsDir->CopyTo(profileDirParent,
-                                            profileDirName);
-        if (NS_FAILED(rv) || !profileDefaultsDir) {
-            // if copying failed, lets just ensure that the profile directory exists.
-            rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
-            NS_ENSURE_SUCCESS(rv, rv);
-        }
+        // let's ensure that the profile directory exists.
+        rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
+        NS_ENSURE_SUCCESS(rv, rv);
         rv = rootDir->SetPermissions(0700);
 #ifndef ANDROID
         // If the profile is on the sdcard, this will fail but its non-fatal
         NS_ENSURE_SUCCESS(rv, rv);
 #endif
     }
 
     rv = localDir->Exists(&exists);