Added an observer to autoregistration, which allows a callback during that

part of startup to advance a progress display, per bug 35866.

I did not get the code actually reviewed, but I discussed it, and tested it
for breakage.  Other developers must register for the observer before it can
be ascertained whether it performs as advertized.


git-svn-id: svn://10.0.0.236/trunk@69818 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rayw%netscape.com
2000-05-15 19:28:12 +00:00
parent 1be79694ec
commit 126369b22d
3 changed files with 134 additions and 53 deletions

View File

@@ -42,6 +42,8 @@
#include "nsXPIDLString.h"
#include "nsCRT.h"
#include "nsIObserverService.h"
#ifdef XP_MAC // sdagley dougt fix
#include <Files.h>
#include <Errors.h>
@@ -649,6 +651,14 @@ nsNativeComponentLoader::SelfUnregisterDll(nsDll *dll)
return res;
}
static const PRUnichar sNativeComponentReg[] = {'R','e','g','i','s','t','e','r',
'i','n','g',' ','n', 'a', 't', 'i', 'v', 'e', ' ', 'c', 'o', 'm', 'p', 'o',
'n', 'e', 'n', 't',':',' ', 0};
static const PRUnichar sNativeComponentUnreg[] = {'U','n','r','e','g','i','s','t','e','r',
'i','n','g',' ','n', 'a', 't', 'i', 'v', 'e', ' ', 'c', 'o', 'm', 'p', 'o',
'n', 'e', 'n', 't',':',' ', 0};
nsresult
nsNativeComponentLoader::AutoUnregisterComponent(PRInt32 when,
nsIFile *component,
@@ -661,6 +671,21 @@ nsNativeComponentLoader::AutoUnregisterComponent(PRInt32 when,
getter_Copies(persistentDescriptor));
if (NS_FAILED(rv)) return rv;
// Notify observers, if any, of autoregistration work
NS_WITH_SERVICE (nsIObserverService, observerService, NS_OBSERVERSERVICE_PROGID, &rv);
if (NS_SUCCEEDED(rv))
{
nsIServiceManager *mgr; // NO COMPtr as we dont release the service manager
rv = nsServiceManager::GetGlobalServiceManager(&mgr);
if (NS_SUCCEEDED(rv))
{
nsAutoString topic; // This is quite ineficient, but is how it is
// done in every other example.
topic.AssignWithConversion(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID);
(void) observerService->Notify(mgr, topic.GetUnicode(), sNativeComponentUnreg);
}
}
nsDll *dll = NULL;
PRInt64 mod = LL_Zero(), size = LL_Zero();
rv = CreateDll(component, persistentDescriptor, &mod, &size, &dll);
@@ -678,7 +703,6 @@ nsNativeComponentLoader::AutoUnregisterComponent(PRInt32 when,
return rv;
}
nsresult
nsNativeComponentLoader::AutoRegisterComponent(PRInt32 when,
nsIFile *component,
@@ -806,6 +830,23 @@ nsNativeComponentLoader::AutoRegisterComponent(PRInt32 when,
// Aagh! the dll has changed since the last time we saw it.
// re-register dll
// Notify observers, if any, of autoregistration work
NS_WITH_SERVICE (nsIObserverService, observerService, NS_OBSERVERSERVICE_PROGID, &rv);
if (NS_SUCCEEDED(rv))
{
nsIServiceManager *mgr; // NO COMPtr as we dont release the service manager
rv = nsServiceManager::GetGlobalServiceManager(&mgr);
if (NS_SUCCEEDED(rv))
{
nsAutoString topic; // This is quite ineficient, but is how it is
// done in every other example.
topic.AssignWithConversion(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID);
(void) observerService->Notify(mgr, topic.GetUnicode(), sNativeComponentReg);
}
}
if (dll->IsLoaded())
{
// We loaded the old version of the dll and now we find that the