From 0aeede673219728570f1acbd6f043c32380175d6 Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Tue, 16 Oct 2001 21:10:35 +0000 Subject: [PATCH] bug 76339 - kill nsIAppShellComponent, finally. sr=sfraser, r=dveditz --- build/mac/build_scripts/MozillaBuildList.pm | 5 - xpfe/appshell/public/nsIAppShellService.idl | 11 -- xpfe/appshell/src/nsAppShellService.cpp | 161 -------------------- xpfe/appshell/src/nsAppShellService.h | 4 - xpfe/bootstrap/nsAppRunner.cpp | 12 -- xpfe/components/Makefile.in | 2 +- xpfe/components/makefile.win | 1 - 7 files changed, 1 insertion(+), 195 deletions(-) diff --git a/build/mac/build_scripts/MozillaBuildList.pm b/build/mac/build_scripts/MozillaBuildList.pm index 15483db97d1..8ff016b7870 100644 --- a/build/mac/build_scripts/MozillaBuildList.pm +++ b/build/mac/build_scripts/MozillaBuildList.pm @@ -807,11 +807,6 @@ sub BuildClientDist() InstallFromManifest(":mozilla:xpinstall:public:MANIFEST", "$distdirectory:xpinstall:"); InstallFromManifest(":mozilla:xpinstall:cleanup:MANIFEST", "$distdirectory:xpinstall:"); - - # XPFE COMPONENTS - InstallFromManifest(":mozilla:xpfe:components:public:MANIFEST", "$distdirectory:xpfe:components"); - InstallFromManifest(":mozilla:xpfe:components:public:MANIFEST_IDL", "$distdirectory:idl:"); - my $dir = ''; for $dir (qw(bookmarks find history related search shistory sidebar urlbarhistory xfer)) { diff --git a/xpfe/appshell/public/nsIAppShellService.idl b/xpfe/appshell/public/nsIAppShellService.idl index 464e1938d21..c205ac30d20 100644 --- a/xpfe/appshell/public/nsIAppShellService.idl +++ b/xpfe/appshell/public/nsIAppShellService.idl @@ -88,12 +88,6 @@ interface nsIAppShellService : nsISupports */ void quit(); - /** - * Required exit routine. Cleanly shuts down - * the appshell components. - */ - void shutdown(); - /** * Create a window. * @param aParent the parent window. Can be null. @@ -123,11 +117,6 @@ interface nsIAppShellService : nsISupports in long aInitialWidth, in long aInitialHeight); - /** - * Apply Initialize function to each app shell component. - */ - void enumerateAndInitializeComponents(); - /** * Close a window. * @param aWindow a window. diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index cbe61fa2b8e..8a93b8a78cc 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -58,7 +58,6 @@ #include "nsIWebShellWindow.h" #include "nsWebShellWindow.h" -#include "nsIAppShellComponent.h" #include "nsIRegistry.h" #include "nsIEnumerator.h" #include "nsICmdLineService.h" @@ -299,157 +298,6 @@ nsAppShellService::CreateHiddenWindow() } -NS_IMETHODIMP nsAppShellService::EnumerateAndInitializeComponents(void) -{ - // Initialize each registered component. - EnumerateComponents( &nsAppShellService::InitializeComponent ); - return NS_OK; -} - - -// Apply function (Initialize/Shutdown) to each app shell component. -void -nsAppShellService::EnumerateComponents( EnumeratorMemberFunction function ) { - nsresult rv; - nsRegistryKey key; - nsCOMPtr components; - const char *failed = "GetService"; - nsCOMPtr registry = - do_GetService(NS_REGISTRY_CONTRACTID, &rv); - if ( NS_SUCCEEDED(rv) - && - ( failed = "Open" ) - && - NS_SUCCEEDED( ( rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry) ) ) - && - ( failed = "GetSubtree" ) - && - NS_SUCCEEDED( ( rv = registry->GetSubtree( nsIRegistry::Common, - NS_IAPPSHELLCOMPONENT_KEY, - &key ) ) ) - && - ( failed = "EnumerateSubtrees" ) - && - NS_SUCCEEDED( ( rv = registry->EnumerateSubtrees( key, - getter_AddRefs(components )) ) ) - && - ( failed = "First" ) - && - NS_SUCCEEDED( ( rv = components->First() ) ) ) { - // Enumerate all subtrees - while ( NS_SUCCEEDED( rv ) && (NS_OK != components->IsDone()) ) { - nsCOMPtr base; - - rv = components->CurrentItem( getter_AddRefs(base) ); - if ( NS_SUCCEEDED( rv ) ) { - // Get specific interface. - nsCOMPtr node; - nsIID nodeIID = NS_IREGISTRYNODE_IID; - rv = base->QueryInterface( nodeIID, - (void**)getter_AddRefs(node) ); - // Test that result. - if ( NS_SUCCEEDED( rv ) ) { - // Get node name. - char *name; - rv = node->GetNameUTF8( &name ); - if ( NS_SUCCEEDED( rv ) ) { - // If this is a CID of a component; apply function to it. - nsCID cid; - if ( cid.Parse( name ) ) { - (this->*function)( cid ); - } else { - // Not a valid CID, ignore it. - } - } else { - // Unable to get subkey name, ignore it. - } - nsCRT::free(name); - } else { - // Unable to convert item to registry node, ignore it. - } - - } else { - // Unable to get current item, ignore it. - } - - // Go on to next component, if this fails, we quit. - rv = components->Next(); - } - } else { - // Unable to set up for subkey enumeration. - #ifdef NS_DEBUG - printf( "Unable to enumerator app shell components, %s rv=0x%08X\n", - failed, (int)rv ); - #endif - } - - return; -} - -void -nsAppShellService::InitializeComponent( const nsCID &aComponentCID ) { - // Attempt to create instance of the component. - nsIAppShellComponent *component; - nsresult rv = nsComponentManager::CreateInstance( aComponentCID, - 0, - NS_GET_IID(nsIAppShellComponent), - (void**)&component ); - if ( NS_SUCCEEDED( rv ) ) { - // Then tell it to initialize (it may RegisterService itself). - rv = component->Initialize( this, mCmdLineService ); - #ifdef NS_DEBUG - char *name = aComponentCID.ToString(); - printf( "Initialized app shell component %s, rv=0x%08X\n", - name, (int)rv ); - Recycle(name); - #endif - // Release it (will live on if it registered itself as service). - component->Release(); - } else { - // Error creating component. - #ifdef NS_DEBUG - char *name = aComponentCID.ToString(); - printf( "Error creating app shell component %s, rv=0x%08X\n", - name, (int)rv ); - Recycle(name); - #endif - } - - return; -} - -void -nsAppShellService::ShutdownComponent( const nsCID &aComponentCID ) { - // Attempt to create instance of the component (must be a service). - nsIAppShellComponent *component; - nsresult rv = nsServiceManager::GetService( aComponentCID, - NS_GET_IID(nsIAppShellComponent), - (nsISupports**)&component ); - if ( NS_SUCCEEDED( rv ) ) { - // Instance accessed, tell it to shutdown. - rv = component->Shutdown(); -#ifdef NS_DEBUG - char *name = aComponentCID.ToString(); - printf( "Shut down app shell component %s, rv=0x%08X\n", - name, (int)rv ); - nsCRT::free(name); -#endif - // Release the service. - nsServiceManager::ReleaseService( aComponentCID, component ); - } else { - // Error getting component service (perhaps due to that component not being - // a service). -#ifdef NS_DEBUG - char *name = aComponentCID.ToString(); - printf( "Unable to shut down app shell component %s, rv=0x%08X\n", - name, (int)rv ); - nsCRT::free(name); -#endif - } - - return; -} - NS_IMETHODIMP nsAppShellService::Run(void) { @@ -572,15 +420,6 @@ nsAppShellService::DestroyExitEvent(PLEvent* aEvent) delete event; } -NS_IMETHODIMP -nsAppShellService::Shutdown(void) -{ - // Shutdown all components. - EnumerateComponents(&nsAppShellService::ShutdownComponent); - - return NS_OK; -} - /* * Create a new top level window and display the given URL within it... */ diff --git a/xpfe/appshell/src/nsAppShellService.h b/xpfe/appshell/src/nsAppShellService.h index 8e550a6ec65..1c509c0c35e 100644 --- a/xpfe/appshell/src/nsAppShellService.h +++ b/xpfe/appshell/src/nsAppShellService.h @@ -71,10 +71,6 @@ protected: PRUint32 aChromeMask, PRInt32 aInitialWidth, PRInt32 aInitialHeight, PRBool aIsHiddenWindow, nsIXULWindow **aResult); - void InitializeComponent( const nsCID &aComponentCID ); - void ShutdownComponent( const nsCID &aComponentCID ); - typedef void (nsAppShellService::*EnumeratorMemberFunction)(const nsCID&); - void EnumerateComponents( void (nsAppShellService::*function)(const nsCID&) ); nsresult SetXPConnectSafeContext(); nsresult ClearXPConnectSafeContext(); diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 4d6990ed3be..9134f6cd812 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -50,7 +50,6 @@ #include "nsIAppShell.h" #include "nsICmdLineService.h" #include "nsIAppShellService.h" -#include "nsIAppShellComponent.h" #include "nsIAppStartupNotifier.h" #include "nsIObserverService.h" #include "nsAppShellCIDs.h" @@ -1233,11 +1232,6 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) NS_TIMELINE_LEAVE("InitializeProfileService"); if (NS_FAILED(rv)) return rv; - // Enumerate AppShellComponenets - NS_TIMELINE_ENTER("appShell->EnumerateAndInitializeComponents"); - appShell->EnumerateAndInitializeComponents(); - NS_TIMELINE_LEAVE("appShell->EnumerateAndInitializeComponents"); - rv = VerifyPsmAbsentOrSane(argc, argv); if (NS_FAILED(rv)) return rv; @@ -1298,12 +1292,6 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) remoteService->Shutdown(); #endif /* MOZ_ENABLE_XREMOTE */ - /* - * Shut down the Shell instance... This is done even if the Run(...) - * method returned an error. - */ - (void) appShell->Shutdown(); - NS_TIMELINE_LEAVE("main1"); return rv; diff --git a/xpfe/components/Makefile.in b/xpfe/components/Makefile.in index f166d33ece8..0535e22ba02 100644 --- a/xpfe/components/Makefile.in +++ b/xpfe/components/Makefile.in @@ -26,7 +26,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = public bookmarks directory filepicker find history search sidebar related regviewer xfer prefwindow shistory remote console autocomplete urlbarhistory intl build +DIRS = bookmarks directory filepicker find history search sidebar related regviewer xfer prefwindow shistory remote console autocomplete urlbarhistory intl build ifdef MOZ_ENABLE_XREMOTE DIRS += xremote diff --git a/xpfe/components/makefile.win b/xpfe/components/makefile.win index c94a9bf4a54..5a6ec32dc7c 100644 --- a/xpfe/components/makefile.win +++ b/xpfe/components/makefile.win @@ -22,7 +22,6 @@ DEPTH=..\.. DIRS= \ - public \ bookmarks \ directory \ filepicker \