From cbe2026152e4d683136aed20cc6e5938a8cd07d8 Mon Sep 17 00:00:00 2001 From: "dveditz%netscape.com" Date: Fri, 3 Dec 1999 13:37:23 +0000 Subject: [PATCH] Bug 12816, move XPInstall initialization closer to the front so we can clean up after an install *before* the wrong components are loaded. --- xpinstall/public/nsISoftwareUpdate.h | 1 + xpinstall/src/nsSoftwareUpdate.cpp | 109 ++++++++---------- xpinstall/src/nsSoftwareUpdate.h | 3 +- xpinstall/src/nsSoftwareUpdateRun.cpp | 14 ++- .../wizard/windows/setuprsc/setuprsc.cpp | 3 +- 5 files changed, 63 insertions(+), 67 deletions(-) diff --git a/xpinstall/public/nsISoftwareUpdate.h b/xpinstall/public/nsISoftwareUpdate.h index 09045292f706..947e4a7ec659 100644 --- a/xpinstall/public/nsISoftwareUpdate.h +++ b/xpinstall/public/nsISoftwareUpdate.h @@ -73,6 +73,7 @@ class nsISoftwareUpdate : public nsISupports NS_IMETHOD InstallJarCallBack() = 0; NS_IMETHOD GetMasterNotifier(nsIXPINotifier **notifier) = 0; NS_IMETHOD SetActiveNotifier(nsIXPINotifier *notifier) = 0; + NS_IMETHOD StartupTasks() = 0; }; diff --git a/xpinstall/src/nsSoftwareUpdate.cpp b/xpinstall/src/nsSoftwareUpdate.cpp index 1e3b62bb7f2c..c28867feeaf9 100644 --- a/xpinstall/src/nsSoftwareUpdate.cpp +++ b/xpinstall/src/nsSoftwareUpdate.cpp @@ -103,28 +103,12 @@ nsSoftwareUpdate::GetInstance() nsSoftwareUpdate::nsSoftwareUpdate() +: mInstalling(PR_FALSE), + mStubLockout(PR_FALSE) { NS_INIT_ISUPPORTS(); - mStubLockout = PR_FALSE; - /***************************************/ - /* Create us a queue */ - /***************************************/ mLock = PR_NewLock(); - mInstalling = PR_FALSE; - mJarInstallQueue = new nsVoidArray(); - - /***************************************/ - /* Add us to the Javascript Name Space */ - /***************************************/ - - RegisterNameset(); - - /***************************************/ - /* Register us with NetLib */ - /***************************************/ - // FIX - /***************************************/ /* Startup the Version Registry */ @@ -134,30 +118,6 @@ nsSoftwareUpdate::nsSoftwareUpdate() nsSpecialSystemDirectory appDir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); VR_SetRegDirectory( appDir.GetNativePathCString() ); - - - /***************************************/ - /* Perform Scheduled Tasks */ - /***************************************/ - -/* XXX Temporary workaround: see bugs 8849, 8971 */ -#ifndef XP_UNIX - PR_CreateThread(PR_USER_THREAD, - PerformScheduledTasks, - nsnull, - PR_PRIORITY_NORMAL, - PR_GLOBAL_THREAD, - PR_UNJOINABLE_THREAD, - 0); -#endif - - - /***************************************/ - /* Create a top level observer */ - /***************************************/ - - nsLoggingProgressNotifier *logger = new nsLoggingProgressNotifier(); - RegisterNotifier(logger); } @@ -167,20 +127,17 @@ nsSoftwareUpdate::nsSoftwareUpdate() nsSoftwareUpdate::~nsSoftwareUpdate() { PR_Lock(mLock); - if (mJarInstallQueue != nsnull) - { - nsInstallInfo* element; - for (PRInt32 i=0; i < mJarInstallQueue->Count(); i++) - { - element = (nsInstallInfo*)mJarInstallQueue->ElementAt(i); - //FIX: need to add to registry.... - delete element; - } - mJarInstallQueue->Clear(); - delete (mJarInstallQueue); - mJarInstallQueue = nsnull; + nsInstallInfo* element; + for (PRInt32 i=0; i < mJarInstallQueue.Count(); i++) + { + element = (nsInstallInfo*)mJarInstallQueue.ElementAt(i); + //FIX: need to add to registry.... + delete element; } + + mJarInstallQueue.Clear(); + PR_Unlock(mLock); PR_DestroyLock(mLock); @@ -236,16 +193,34 @@ nsSoftwareUpdate::QueryInterface( REFNSIID anIID, void **anInstancePtr ) NS_IMETHODIMP nsSoftwareUpdate::Initialize( nsIAppShellService *anAppShell, nsICmdLineService *aCmdLineService ) { - mStubLockout = PR_TRUE; // prevent use of nsPIXPIStubHook by browser + // prevent use of nsPIXPIStubHook by browser + mStubLockout = PR_TRUE; + + /***************************************/ + /* Add us to the Javascript Name Space */ + /***************************************/ + + RegisterNameset(); + + /***************************************/ + /* Register us with NetLib */ + /***************************************/ + // FIX + + + /***************************************/ + /* Create a top level observer */ + /***************************************/ + + nsLoggingProgressNotifier *logger = new nsLoggingProgressNotifier(); + RegisterNotifier(logger); -// rv = nsServiceManager::RegisterService( NS_IXPINSTALLCOMPONENT_PROGID, ( (nsISupports*) (nsISoftwareUpdate*) this ) ); return NS_OK; } NS_IMETHODIMP nsSoftwareUpdate::Shutdown() { -// rv = nsServiceManager::UnregisterService( NS_IXPINSTALLCOMPONENT_PROGID ); NS_IF_RELEASE(mInstance); return NS_OK; } @@ -299,7 +274,7 @@ nsSoftwareUpdate::InstallJar( nsIFileSpec* aLocalFile, return NS_ERROR_OUT_OF_MEMORY; PR_Lock(mLock); - mJarInstallQueue->AppendElement( info ); + mJarInstallQueue.AppendElement( info ); PR_Unlock(mLock); RunNextInstall(); @@ -312,11 +287,11 @@ nsSoftwareUpdate::InstallJarCallBack() { PR_Lock(mLock); - nsInstallInfo *nextInstall = (nsInstallInfo*)mJarInstallQueue->ElementAt(0); + nsInstallInfo *nextInstall = (nsInstallInfo*)mJarInstallQueue.ElementAt(0); if (nextInstall != nsnull) delete nextInstall; - mJarInstallQueue->RemoveElementAt(0); + mJarInstallQueue.RemoveElementAt(0); mInstalling = PR_FALSE; PR_Unlock(mLock); @@ -325,6 +300,14 @@ nsSoftwareUpdate::InstallJarCallBack() } +NS_IMETHODIMP +nsSoftwareUpdate::StartupTasks() +{ + PerformScheduledTasks(0); + return NS_OK; +} + + nsresult nsSoftwareUpdate::RunNextInstall() { @@ -334,9 +317,9 @@ nsSoftwareUpdate::RunNextInstall() PR_Lock(mLock); if (!mInstalling) { - if ( mJarInstallQueue->Count() > 0 ) + if ( mJarInstallQueue.Count() > 0 ) { - info = (nsInstallInfo*)mJarInstallQueue->ElementAt(0); + info = (nsInstallInfo*)mJarInstallQueue.ElementAt(0); if ( info ) mInstalling = PR_TRUE; @@ -680,7 +663,7 @@ nsSoftwareUpdateModule::RegisterSelf(nsIComponentManager *aCompMgr, nsresult rv = NS_OK; #ifdef DEBUG - printf("*** XPInstall is being registered\n"); + printf("*** Registering XPInstall\n"); #endif Components* cp = gComponents; diff --git a/xpinstall/src/nsSoftwareUpdate.h b/xpinstall/src/nsSoftwareUpdate.h index 88d767b0b2a5..d8d71bf057d9 100644 --- a/xpinstall/src/nsSoftwareUpdate.h +++ b/xpinstall/src/nsSoftwareUpdate.h @@ -50,6 +50,7 @@ class nsSoftwareUpdate: public nsIAppShellComponent, NS_IMETHOD InstallJarCallBack(); NS_IMETHOD GetMasterNotifier(nsIXPINotifier **notifier); NS_IMETHOD SetActiveNotifier(nsIXPINotifier *notifier); + NS_IMETHOD StartupTasks(); /** SetProgramDirectory() is private for the Install Wizard. * The mStubLockout property makes sure this is only called @@ -72,7 +73,7 @@ class nsSoftwareUpdate: public nsIAppShellComponent, PRLock* mLock; PRBool mInstalling; PRBool mStubLockout; - nsVoidArray* mJarInstallQueue; + nsVoidArray mJarInstallQueue; nsTopProgressNotifier mMasterNotifier; }; diff --git a/xpinstall/src/nsSoftwareUpdateRun.cpp b/xpinstall/src/nsSoftwareUpdateRun.cpp index c85622e1a12a..7078c5176156 100644 --- a/xpinstall/src/nsSoftwareUpdateRun.cpp +++ b/xpinstall/src/nsSoftwareUpdateRun.cpp @@ -43,8 +43,10 @@ #include "nsIZipReader.h" #include "nsCOMPtr.h" -static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID); +#include "nsIEventQueueService.h" +static NS_DEFINE_CID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID); +static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); extern JSObject *InitXPInstallObjects(JSContext *jscontext, JSObject *global, const nsFileSpec& jarfile, const PRUnichar* url, const PRUnichar* args); @@ -306,6 +308,16 @@ extern "C" void RunInstallOnThread(void *data) nsIXPINotifier *notifier; nsresult rv; + + // lets set up an eventQ so that our xpcom/proxies will not have to: + nsCOMPtr eventQ; + NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv); + if (NS_SUCCEEDED(rv)) + { + eventQService->CreateThreadEventQueue(); + eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eventQ)); + } + NS_WITH_SERVICE(nsISoftwareUpdate, softwareUpdate, kSoftwareUpdateCID, &rv ); if (!NS_SUCCEEDED(rv)) diff --git a/xpinstall/wizard/windows/setuprsc/setuprsc.cpp b/xpinstall/wizard/windows/setuprsc/setuprsc.cpp index 9a321119b50b..9800efd9b9de 100644 --- a/xpinstall/wizard/windows/setuprsc/setuprsc.cpp +++ b/xpinstall/wizard/windows/setuprsc/setuprsc.cpp @@ -10,8 +10,7 @@ * implied. See the License for the specific language governing * rights and limitations under the License. * - * The Original Code is Mozilla Communicator client code, - * released March 31, 1998. + * The Original Code is Mozilla Communicator * * The Initial Developer of the Original Code is Netscape Communications * Corporation. Portions created by Netscape are