nsCOMPtr<nsIComponentRegistrar> registrar (do_QueryInterface(mServiceManager)); NS_ASSERTION(registrar, "Where's the component registrar?");  nsCOMPtr<nsIFactory> nativeFactory = new nsSingletonFactory(native); NS_ENSURE_TRUE(nativeFactory, NS_ERROR_OUT_OF_MEMORY);  rv = registrar->RegisterFactory(kNativeAppSupportCID, "Native App Support", NS_NATIVEAPPSUPPORT_CONTRACTID, nativeFactory); NS_ENSURE_SUCCESS(rv, rv);
ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport* native){  nsresult rv;  // Initialize the cmd line service  nsCOMPtr<nsICmdLineService> cmdLineArgs    (do_GetService("@mozilla.org/app-startup/commandLineService;1"));  NS_ENSURE_TRUE(cmdLineArgs, NS_ERROR_FAILURE);  rv = cmdLineArgs->Initialize(gArgc, gArgv);  if (NS_FAILED(rv)) {    if (rv == NS_ERROR_INVALID_ARG)      DumpHelp();    return rv;  }  nsCOMPtr<nsIWindowCreator> creator (do_GetService(NS_APPSTARTUP_CONTRACTID));  if (!creator) return NS_ERROR_UNEXPECTED;  nsCOMPtr<nsIWindowWatcher> wwatch    (do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));  NS_ENSURE_SUCCESS(rv, rv);  return wwatch->SetWindowCreator(creator);}