rv = DoCommandLines(cmdLineArgs, &windowOpened);
PRBool defaultStartup; #if defined(XP_MAC) || defined(XP_MACOSX)   PRInt32 processedArgc; cmdLineArgs->GetArgc(&processedArgc); defaultStartup = (processedArgc == 1); #if defined(XP_MACOSX)   if (argc == 2 && processedArgc == 2) { ProcessSerialNumber ourPSN; if (::MacGetCurrentProcess(&ourPSN) == noErr) { char argBuf[64]; sprintf(argBuf, "-psn_%ld_%ld", ourPSN.highLongOfPSN, ourPSN.lowLongOfPSN); if (!strcmp(argBuf, argv[1])) defaultStartup = PR_TRUE; } } #endif  #else defaultStartup = (argc == 1); #endif rv = DoCommandLines(cmdLineArgs, defaultStartup, &windowOpened);
static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ){  nsresult rv;  NS_TIMELINE_ENTER("main1");  nsCOMPtr<nsISupports> nativeAppOwner(dont_AddRef(nativeApp));  //----------------------------------------------------------------  // 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");  // Setup an autoreg obserer, so that we can update a progress  // string in the splash screen  nsCOMPtr<nsIObserverService> obsService(do_GetService("@mozilla.org/observer-service;1"));  if (obsService)  {    nsCOMPtr<nsIObserver> splashScreenObserver(do_QueryInterface(nativeAppOwner));    if (splashScreenObserver)    {      obsService->AddObserver(splashScreenObserver, NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID, PR_FALSE);      obsService->AddObserver(splashScreenObserver, "startup_user_notifcations", PR_FALSE);    }  }#if XP_MAC  stTSMCloser  tsmCloser;  rv = InitializeMacCommandLine(argc, argv);  NS_ASSERTION(NS_SUCCEEDED(rv), "Initializing AppleEvents failed");#endif#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.  nsCOMPtr<nsIComponentRegistrar> registrar;  NS_GetComponentRegistrar(getter_AddRefs(registrar));  registrar->AutoRegister(nsnull);  registrar = nsnull;#endif  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(NS_COMMANDLINESERVICE_CONTRACTID, &rv));  NS_ASSERTION(NS_SUCCEEDED(rv), "Could not obtain CmdLine processing service\n");  if (NS_FAILED(rv))    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("appStartup");  nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));  NS_ASSERTION(appStartup, "failed to get the appstartup service");  /* if we couldn't get the nsIAppStartup service, then we should hide the     splash screen and return (and something is seriously screwed up) */  if (!appStartup)  {    // See if platform supports nsINativeAppSupport.    nsCOMPtr<nsINativeAppSupport> nativeAppSupport(do_QueryInterface(nativeAppOwner));    if (nativeAppSupport)     {      // Use that interface to remove splash screen.      nativeAppSupport->HideSplashScreen();    }    else    {      // See if platform supports nsISplashScreen, instead.      nsCOMPtr<nsISplashScreen> splashScreen(do_QueryInterface(nativeAppOwner));      if (splashScreen)      {        splashScreen->Hide();      }    }    return rv;  }  NS_TIMELINE_LEAVE("appStartup");  NS_TIMELINE_ENTER("appStartup->Initialize");  // Create the Application Shell instance...  rv = appStartup->Initialize(nativeAppOwner);  NS_TIMELINE_LEAVE("appStartup->Initialize");  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize appstartup");  if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsIWindowCreator> wcreator (do_QueryInterface(appStartup));  NS_ASSERTION(wcreator, "appstartup doesn't do nsIWindowCreator?");  NS_ENSURE_TRUE(wcreator, NS_ERROR_FAILURE);  nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));  NS_ASSERTION(wwatch, "Couldn't get the window watcher!");  NS_ENSURE_TRUE(wwatch, NS_ERROR_FAILURE);  wwatch->SetWindowCreator(wcreator);  // So we can open and close windows during startup  appStartup->EnterLastWindowClosingSurvivalArea();  // Initialize Profile Service here.  NS_TIMELINE_ENTER("InitializeProfileService");  rv = InitializeProfileService(cmdLineArgs);  NS_TIMELINE_LEAVE("InitializeProfileService");  if (NS_FAILED(rv)) return rv;  NS_TIMELINE_ENTER("CheckUseAccessibleSkin");  // Need to do this after profile service init'd  // If OS accessibility theme is used, then we always load classic theme   // which follows the system appearance.  CheckUseAccessibleSkin();  NS_TIMELINE_LEAVE("CheckUseAccessibleSkin");  NS_TIMELINE_ENTER("appStartup->CreateHiddenWindow");  appStartup->CreateHiddenWindow();  NS_TIMELINE_LEAVE("appStartup->CreateHiddenWindow");  PRBool windowOpened = PR_FALSE;  rv = DoCommandLines(cmdLineArgs, &windowOpened);  if (NS_FAILED(rv))  {    NS_WARNING("failed to process command line");    return rv;  }  	if (obsService)  {    NS_NAMED_LITERAL_STRING(userMessage, "Creating first window...");    obsService->NotifyObservers(nsnull, "startup_user_notifcations", userMessage.get());  }    // Make sure there exists at least 1 window.  NS_TIMELINE_ENTER("Ensure1Window");  rv = appStartup->Ensure1Window(cmdLineArgs);  NS_TIMELINE_LEAVE("Ensure1Window");  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to Ensure1Window");  if (NS_FAILED(rv)) return rv;#if !defined(XP_MAC) && !defined(XP_MACOSX)  appStartup->ExitLastWindowClosingSurvivalArea();#endif#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.  // It will shut itself down before the event queue stops processing events.  nsCOMPtr<nsIXRemoteService> remoteService;  remoteService = do_GetService(NS_IXREMOTESERVICE_CONTRACTID);  if (remoteService)    remoteService->Startup(MOZ_APP_NAME);#endif /* MOZ_ENABLE_XREMOTE */  // remove the nativeApp as an XPCOM autoreg observer  if (obsService)  {    nsCOMPtr<nsIObserver> splashScreenObserver(do_QueryInterface(nativeAppOwner));    if (splashScreenObserver)    {      obsService->RemoveObserver(splashScreenObserver, NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID);      obsService->RemoveObserver(splashScreenObserver, "startup_user_notifcations");    }  }  // We are done with the native app (or splash screen) object here;  // the app shell owns it now.  nativeAppOwner = nsnull;  // Start main event loop  NS_TIMELINE_ENTER("appStartup->Run");  rv = appStartup->Run();  NS_TIMELINE_LEAVE("appStartup->Run");  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to run appstartup");#ifdef MOZ_TIMELINE  // Make sure we print this out even if timeline is runtime disabled  if (NS_FAILED(NS_TIMELINE_LEAVE("main1")))      NS_TimelineForceMark("...main1");#endif  return rv;}