if ( NS_SUCCEEDED( rv) ) mWindowMediator->Init("rdf:window-mediator");
nsAppShellService::Initialize( nsICmdLineService *aCmdLineService ){  nsresult rv;#ifdef XP_PC  nsIPICS *pics = NULL;#endif  #ifdef MOZ_FULLCIRCLE  FCInitialize();#endif  // Remember cmd line service.  mCmdLineService = aCmdLineService;  NS_IF_ADDREF( mCmdLineService );  // Create the Event Queue for the UI thread...  nsIEventQueueService* eventQService;  rv = nsServiceManager::GetService(kEventQueueServiceCID,                                    kIEventQueueServiceIID,                                    (nsISupports **)&eventQService);  if (NS_OK == rv) {    // XXX: What if this fails?    rv = eventQService->CreateThreadEventQueue();  }  // Register the nsAppShellNameSet with the global nameset registry...  nsIScriptNameSetRegistry *registry;  rv = nsServiceManager::GetService(kCScriptNameSetRegistryCID,                                    kIScriptNameSetRegistryIID,                                    (nsISupports **)&registry);  if (NS_FAILED(rv)) {    goto done;  }    nsAppShellNameSet* nameSet;  nameSet = new nsAppShellNameSet();  registry->AddExternalNameSet(nameSet);  /* XXX: do we need to release this service?  When we do, it get deleted,and our name is lost. */  // Create the toplevel window list...  rv = NS_NewISupportsArray(&mWindowList);  if (NS_FAILED(rv)) {    goto done;  }#ifdef XP_PC  rv = nsComponentManager::CreateInstance(kPICSCID,							   NULL,							   kIPICSIID,							  (void **) &pics); #endif  nsIMetaCharsetService* metacharset;  rv = nsServiceManager::GetService(kMetaCharsetCID,                                    kIMetaCharsetServiceIID,                                     (nsISupports **) &metacharset);   if(NS_FAILED(rv)) {      goto done;   }   rv = metacharset->Start();   if(NS_FAILED(rv)) {      goto done;   }   rv = nsServiceManager::ReleaseService(kMetaCharsetCID, metacharset);  nsIXMLEncodingService* xmlencoding;  rv = nsServiceManager::GetService(kXMLEncodingCID,                                    nsIXMLEncodingService::GetIID(),                                     (nsISupports **) &xmlencoding);   if(NS_FAILED(rv)) {      goto done;   }   rv = xmlencoding->Start();   if(NS_FAILED(rv)) {      goto done;   }   rv = nsServiceManager::ReleaseService(kXMLEncodingCID, xmlencoding);  // Create widget application shell  rv = nsComponentManager::CreateInstance(kAppShellCID, nsnull, kIAppShellIID,                                    (void**)&mAppShell);  if (NS_FAILED(rv)) {    goto done;  }  rv = mAppShell->Create(0, nsnull);  if (NS_FAILED(rv)) {      goto done;  }  // Initialize each registered component.  EnumerateComponents( &nsAppShellService::InitializeComponent );	// enable window mediation	rv = nsServiceManager::GetService(kWindowMediatorCID, kIWindowMediatorIID,                                   (nsISupports**) &mWindowMediator);	if ( NS_SUCCEEDED( rv) )		mWindowMediator->Init("rdf:window-mediator");done:  return rv;}