shutdown turbo/server mode after an install that requires a browser restart

(bug 86976). r=syd@netscape.com, sr=mscott@netscape.com
This commit is contained in:
dveditz%netscape.com 2001-07-14 07:19:00 +00:00
parent 8787457670
commit 18a0724c66
4 changed files with 48 additions and 13 deletions

View File

@ -34,4 +34,5 @@
interface nsPIXPIProxy : nsISupports
{
void refreshPlugins(in nsISupports aWindow);
void notifyRestartNeeded();
};

View File

@ -856,6 +856,14 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
{
*aReturn = SaveError( REBOOT_NEEDED );
nsSoftwareUpdate::mNeedCleanup = PR_TRUE;
// Broadcast the fact that we have an incomplete install so
// parts of Mozilla can take defensive action if necessary.
//
// This notification turns off turbo/server mode, for example
nsPIXPIProxy* proxy = GetUIThreadProxy();
if (proxy)
proxy->NotifyRestartNeeded();
}
// XXX for now all successful installs will trigger an Autoreg.
@ -1201,7 +1209,7 @@ nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aRetur
nsXPIDLCString spec;
ret = resFile->GetURL(getter_Copies(spec));
if (NS_FAILED(ret)) {
printf("cannot get url spec\n");
NS_WARNING("cannot get url spec\n");
nsServiceManager::ReleaseService(kStringBundleServiceCID, service);
return ret;
}
@ -1352,22 +1360,32 @@ nsInstall::RegisterChrome(nsIFile* chrome, PRUint32 chromeType, const char* path
return SaveError(ScheduleForInstall( ri ));
}
nsPIXPIProxy* nsInstall::GetUIThreadProxy()
{
if (!mUIThreadProxy)
{
nsresult rv;
NS_WITH_SERVICE( nsIProxyObjectManager, pmgr, kProxyObjectManagerCID, &rv);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsPIXPIProxy> tmp(do_QueryInterface(new nsXPIProxy()));
rv = pmgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsPIXPIProxy),
tmp, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs(mUIThreadProxy) );
}
}
return mUIThreadProxy;
}
PRInt32
nsInstall::RefreshPlugins()
{
nsresult rv;
NS_WITH_SERVICE( nsIProxyObjectManager, pmgr, kProxyObjectManagerCID, &rv);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsPIXPIProxy> tmp = do_QueryInterface(new nsXPIProxy());
nsCOMPtr<nsPIXPIProxy> proxy;
rv = pmgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsPIXPIProxy),
tmp, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs(proxy) );
if (NS_SUCCEEDED(rv))
rv = proxy->RefreshPlugins(GetParentDOMWindow());
}
return rv;
nsPIXPIProxy* proxy = GetUIThreadProxy();
if (proxy)
return proxy->RefreshPlugins(GetParentDOMWindow());
return NS_ERROR_FAILURE;
}

View File

@ -48,6 +48,7 @@
#include "nsInstallFolder.h"
#include "nsIXPINotifier.h"
#include "nsPIXPIProxy.h"
#include "nsIStringBundle.h"
#include "nsILocale.h"
@ -341,6 +342,7 @@ class nsInstall
nsHashtable* mPatchList;
nsCOMPtr<nsIXPIListener> mListener;
nsCOMPtr<nsPIXPIProxy> mUIThreadProxy;
nsCOMPtr<nsIStringBundle> mStringBundle;
@ -350,6 +352,7 @@ class nsInstall
PRInt32 SanityCheck(void);
void GetTime(nsString &aString);
nsPIXPIProxy* GetUIThreadProxy();
PRInt32 GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName );
PRInt32 GetQualifiedPackageName( const nsString& name, nsString& qualifiedName );

View File

@ -24,9 +24,12 @@
#include "nsXPIProxy.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIDOMWindowInternal.h"
#include "nsIDOMNavigator.h"
#include "nsIDOMPluginArray.h"
#include "nsIServiceManager.h"
#include "nsIObserverService.h"
nsXPIProxy::nsXPIProxy()
{
@ -62,3 +65,13 @@ nsXPIProxy::RefreshPlugins(nsISupports *aWindow)
rv = plugins->Refresh(PR_TRUE);
return rv;
}
NS_IMETHODIMP
nsXPIProxy::NotifyRestartNeeded()
{
nsCOMPtr<nsIObserverService> obs(do_GetService(NS_OBSERVERSERVICE_CONTRACTID));
if (obs)
obs->Notify( nsnull, NS_LITERAL_STRING("xpinstall-restart").get(), nsnull );
return NS_OK;
}