obsService->RemoveObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get());
obsService->RemoveObserver(splashScreenObserver, NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID);
static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ){  nsresult rv;  NS_TIMELINE_ENTER("main1");  //----------------------------------------------------------------  // First we need to check if a previous installation occured and  // if so, make sure it finished and cleaned up correctly.  //  // If there is an xpicleanup.dat file left around, that means the  // previous installation did not finish correctly. We must cleanup  // before a valid mozilla can run.  //  // Show the user a platform-specific Alert message, then spawn the  // xpicleanup utility, then exit.  //----------------------------------------------------------------  rv = VerifyInstallation(argc, argv);  if (NS_FAILED(rv))    return NS_ERROR_FAILURE;#ifdef DEBUG_warren//  _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF);#endif#ifndef XP_MAC  // Unbuffer debug output (necessary for automated QA performance scripts).  setbuf( stdout, 0 );#endif#if defined(FREEBSD)  // Disable all SIGFPE's on FreeBSD, as it has non-IEEE-conformant fp  // trap behavior that trips up on floating-point tests performed by  // the JS engine.  See bugzilla bug 9967 details.  fpsetmask(0);#endif  NS_TIMELINE_ENTER("init event service");  nsCOMPtr<nsIEventQueueService> eventQService(do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv));  if (NS_SUCCEEDED(rv)) {    // XXX: What if this fails?    rv = eventQService->CreateThreadEventQueue();  }  NS_TIMELINE_LEAVE("init event service");  NS_TIMELINE_ENTER("init observer service");  // Setup an autoreg obserer, so that we can update a progress  // string in the splash screen  nsCOMPtr<nsIObserverService> obsService(do_GetService(NS_OBSERVERSERVICE_CONTRACTID));  if (obsService)  {    nsCOMPtr<nsIObserver> splashScreenObserver(do_QueryInterface(nativeApp));    if (splashScreenObserver)    {      obsService->AddObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get());    }  }  NS_TIMELINE_LEAVE("init observer service");#if XP_MAC  stTSMCloser  tsmCloser;  rv = InitializeMacCommandLine( argc, argv);  NS_ASSERTION(NS_SUCCEEDED(rv), "Initializing AppleEvents failed");#endif  NS_TIMELINE_ENTER("setup registry");  // Ask XPInstall if we need to autoregister anything new.  PRBool needAutoReg = NS_SoftwareUpdateNeedsAutoReg();#ifdef DEBUG  // _Always_ autoreg if we're in a debug build, under the assumption  // that people are busily modifying components and will be angry if  // their changes aren't noticed.  needAutoReg = PR_TRUE;#endif  NS_SetupRegistry_1(needAutoReg);  if (needAutoReg)  // XXX ...and autoreg was successful?    NS_SoftwareUpdateDidAutoReg();  NS_TIMELINE_LEAVE("setup registry");  // remove the nativeApp as an XPCOM autoreg observer  if (obsService)  {    nsCOMPtr<nsIObserver> splashScreenObserver(do_QueryInterface(nativeApp));    if (splashScreenObserver)    {      obsService->RemoveObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get());    }  }  NS_TIMELINE_ENTER("startupNotifier");  // Start up the core services:  // Please do not add new things to main1() - please hook into the  // nsIAppStartupNotifier service.  nsCOMPtr<nsIObserver> startupNotifier = do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID, &rv);  if(NS_FAILED(rv))    return rv;  startupNotifier->Observe(nsnull, APPSTARTUP_TOPIC, nsnull);  NS_TIMELINE_LEAVE("startupNotifier");  NS_TIMELINE_ENTER("cmdLineArgs");  // Initialize the cmd line service  nsCOMPtr<nsICmdLineService> cmdLineArgs(do_GetService(kCmdLineServiceCID, &rv));  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get command line service");  if (NS_FAILED(rv)) {    NS_ASSERTION(PR_FALSE, "Could not obtain CmdLine processing service\n");    return rv;  }  rv = cmdLineArgs->Initialize(argc, argv);  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize command line args");  if (rv == NS_ERROR_INVALID_ARG) {    PrintUsage();    return rv;  }  NS_TIMELINE_LEAVE("cmdLineArgs");  NS_TIMELINE_ENTER("InstallGlobalLocale");  rv = InstallGlobalLocale(cmdLineArgs);  if(NS_FAILED(rv))    return rv;  NS_TIMELINE_LEAVE("InstallGlobalLocale");  NS_TIMELINE_ENTER("appShell");  nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID, &rv));  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get the appshell service");  /* if we couldn't get the nsIAppShellService service, then we should hide the     splash screen and return */  if (NS_FAILED(rv)) {    // See if platform supports nsINativeAppSupport.    nsCOMPtr<nsINativeAppSupport> nativeAppSupport(do_QueryInterface(nativeApp));    if (nativeAppSupport) {      // Use that interface to remove splash screen.      nativeAppSupport->HideSplashScreen();    } else {      // See if platform supports nsISplashScreen, instead.      nsCOMPtr<nsISplashScreen> splashScreen(do_QueryInterface(nativeApp));      if (splashScreen) {        splashScreen->Hide();      }    }    // Release argument object.    NS_IF_RELEASE(nativeApp);    return rv;  }  NS_TIMELINE_LEAVE("appShell");  NS_TIMELINE_ENTER("appShell->Initialize");  // Create the Application Shell instance...  rv = appShell->Initialize(cmdLineArgs, nativeApp);  NS_TIMELINE_LEAVE("appShell->Initialize");  // We are done with the native app (or splash screen) object here;  // the app shell owns it now.  NS_IF_RELEASE(nativeApp);  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize appshell");  if (NS_FAILED(rv)) return rv;  rv = InitializeWindowCreator();  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize window creator");  if (NS_FAILED(rv)) return rv;  // So we can open and close windows during startup  appShell->SetQuitOnLastWindowClosing(PR_FALSE);  // Initialize Profile Service here.  NS_TIMELINE_ENTER("InitializeProfileService");  rv = InitializeProfileService(cmdLineArgs);  NS_TIMELINE_LEAVE("InitializeProfileService");  if (NS_FAILED(rv)) return rv;  rv = VerifyPsmAbsentOrSane(argc, argv);  if (NS_FAILED(rv)) return rv;  // rjc: now must explicitly call appshell's CreateHiddenWindow() function AFTER profile manager.  //      if the profile manager ever switches to using nsIDOMWindowInternal stuff, this might have to change  NS_TIMELINE_ENTER("appShell->CreateHiddenWindow");  appShell->CreateHiddenWindow();  NS_TIMELINE_LEAVE("appShell->CreateHiddenWindow");  // This will go away once Components are handling there own commandlines  // if we have no command line arguments, we need to heed the  // "general.startup.*" prefs  // if we had no command line arguments, argc == 1.#ifdef XP_MAC  // if we do no command line args on the mac, it says argc is 0, and not 1  rv = DoCommandLines( cmdLineArgs, ((argc == 1) || (argc == 0)) );#else  rv = DoCommandLines( cmdLineArgs, (argc == 1) );#endif /* XP_MAC */    NS_ASSERTION(NS_SUCCEEDED(rv), "failed to process command line");  if ( NS_FAILED(rv) )    return rv;  // Make sure there exists at least 1 window.  NS_TIMELINE_ENTER("Ensure1Window");  rv = Ensure1Window( cmdLineArgs );  NS_TIMELINE_LEAVE("Ensure1Window");  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to Ensure1Window");  if (NS_FAILED(rv)) return rv;  // From this point on, should be true  appShell->SetQuitOnLastWindowClosing(PR_TRUE);	  nsCOMPtr<nsINativeAppSupport> nativeAppSupport;  rv = appShell->GetNativeAppSupport(getter_AddRefs( nativeAppSupport ));  if (NS_SUCCEEDED(rv))      nativeAppSupport->StartAddonFeatures();#ifdef MOZ_ENABLE_XREMOTE  // if we have X remote support and we have our one window up and  // running start listening for requests on the proxy window.  nsCOMPtr<nsIXRemoteService> remoteService;  remoteService = do_GetService(NS_IXREMOTESERVICE_CONTRACTID);  if (remoteService)    remoteService->Startup();#endif /* MOZ_ENABLE_XREMOTE */  // Start main event loop  NS_TIMELINE_ENTER("appShell->Run");  rv = appShell->Run();  NS_TIMELINE_LEAVE("appShell->Run");  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to run appshell");#ifdef MOZ_ENABLE_XREMOTE  // shut down the x remote proxy window  if (remoteService)    remoteService->Shutdown();#endif /* MOZ_ENABLE_XREMOTE */  NS_TIMELINE_LEAVE("main1");  return rv;}