From e33d52ae4d94040aef0151ec41dbbb363113fcfa Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Sat, 11 Sep 1999 22:15:24 +0000 Subject: [PATCH] change the nsIProfileService interface and implemenation. add an Init() method instead of doing things in the constructor. git-svn-id: svn://10.0.0.236/trunk@46981 18797224-902f-48f8-a5cc-f745e15eee43 --- .../idlservices/nsIProfileServices.idl | 1 + .../profile/idlservices/nsProfileServices.cpp | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mozilla/profile/idlservices/nsIProfileServices.idl b/mozilla/profile/idlservices/nsIProfileServices.idl index 35a997f6397..fe2c7ce94bd 100644 --- a/mozilla/profile/idlservices/nsIProfileServices.idl +++ b/mozilla/profile/idlservices/nsIProfileServices.idl @@ -27,6 +27,7 @@ [scriptable, uuid(F4C0DA81-3887-11d3-9F5D-006008A6EFE9)] interface nsIProfileServices : nsISupports { + void Init(); void CreateNewProfile(in string data); void RenameProfile(in string oldName, in string newName); void DeleteProfile(in string profileName, in string canDeleteFiles); diff --git a/mozilla/profile/idlservices/nsProfileServices.cpp b/mozilla/profile/idlservices/nsProfileServices.cpp index 82488b924b0..41da7d42b15 100644 --- a/mozilla/profile/idlservices/nsProfileServices.cpp +++ b/mozilla/profile/idlservices/nsProfileServices.cpp @@ -56,6 +56,8 @@ private: nsresult NS_NewProfileServices(nsIProfileServices** aProfile) { + nsresult rv; + NS_PRECONDITION(aProfile != nsnull, "null ptr"); if (! aProfile) return NS_ERROR_NULL_POINTER; @@ -64,6 +66,13 @@ NS_NewProfileServices(nsIProfileServices** aProfile) if (! *aProfile) return NS_ERROR_OUT_OF_MEMORY; + rv = (*aProfile)->Init(); + if (NS_FAILED(rv)) { + delete *aProfile; + *aProfile = nsnull; + return rv; + } + NS_ADDREF(*aProfile); return NS_OK; } @@ -76,9 +85,6 @@ ProfileServicesImpl::ProfileServicesImpl() { NS_INIT_REFCNT(); - nsresult rv = nsServiceManager::GetService(kProfileCID, - nsIProfile::GetIID(), - (nsISupports **)&mProfile); } @@ -90,6 +96,14 @@ ProfileServicesImpl::~ProfileServicesImpl() NS_IMPL_ISUPPORTS(ProfileServicesImpl, nsIProfileServices::GetIID()); +NS_IMETHODIMP +ProfileServicesImpl::Init() +{ + nsresult rv = nsServiceManager::GetService(kProfileCID, + nsIProfile::GetIID(), + (nsISupports **)&mProfile); + return rv; +} NS_IMETHODIMP ProfileServicesImpl::CreateNewProfile(const char* data)