Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
ScopedXPCOMStartup Class Reference

Because we're starting/stopping XPCOM several times in different scenarios, this class is a stack-based critter that makes sure that XPCOM is shut down during early returns. More...

Collaboration diagram for ScopedXPCOMStartup:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ScopedXPCOMStartup ()
 ~ScopedXPCOMStartup ()
nsresult Initialize ()
nsresult DoAutoreg ()
nsresult RegisterProfileService (nsIToolkitProfileService *aProfileService)
nsresult InitEventQueue ()
nsresult SetWindowCreator (nsINativeAppSupport *native)
 Set our windowcreator on the WindowWatcher service.

Private Attributes

nsIServiceManagermServiceManager

Detailed Description

Because we're starting/stopping XPCOM several times in different scenarios, this class is a stack-based critter that makes sure that XPCOM is shut down during early returns.

Definition at line 741 of file nsAppRunner.cpp.


Constructor & Destructor Documentation

Definition at line 744 of file nsAppRunner.cpp.

Definition at line 758 of file nsAppRunner.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 862 of file nsAppRunner.cpp.

{
#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
    (do_QueryInterface(mServiceManager));
  NS_ASSERTION(registrar, "Where's the component registrar?");

  registrar->AutoRegister(nsnull);
#endif

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 847 of file nsAppRunner.cpp.

{
  NS_TIMELINE_ENTER("init event service");
  nsresult rv;

  nsCOMPtr<nsIEventQueueService> eventQService(do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv));
  NS_ENSURE_SUCCESS(rv, rv);

  rv = eventQService->CreateThreadEventQueue();
  NS_TIMELINE_LEAVE("init event service");

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 800 of file nsAppRunner.cpp.

{
  NS_ASSERTION(gDirServiceProvider, "Should not get here!");

  nsresult rv;
  rv = NS_InitXPCOM3(&mServiceManager, gDirServiceProvider->GetAppDir(),
                     gDirServiceProvider,
                     kPStaticModules, kStaticModuleCount);
  if (NS_FAILED(rv)) {
    NS_ERROR("Couldn't start xpcom!");
    mServiceManager = nsnull;
  }
  else {
    nsCOMPtr<nsIComponentRegistrar> reg =
      do_QueryInterface(mServiceManager);
    NS_ASSERTION(reg, "Service Manager doesn't QI to Registrar.");
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 830 of file nsAppRunner.cpp.

{
  NS_ASSERTION(mServiceManager, "Not initialized!");

  nsCOMPtr<nsIFactory> factory = do_QueryInterface(aProfileService);
  NS_ASSERTION(factory, "Supposed to be an nsIFactory!");

  nsCOMPtr<nsIComponentRegistrar> reg (do_QueryInterface(mServiceManager));
  if (!reg) return NS_ERROR_NO_INTERFACE;

  return reg->RegisterFactory(kProfileServiceCID,
                              "Toolkit Profile Service",
                              NS_PROFILESERVICE_CONTRACTID,
                              factory);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Set our windowcreator on the WindowWatcher service.

Definition at line 923 of file nsAppRunner.cpp.

{
  nsresult rv;

  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);

  // Inform the chrome registry about OS accessibility
  nsCOMPtr<nsIToolkitChromeRegistry> cr (do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
  if (cr)
    cr->CheckForOSAccessibility();

  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 755 of file nsAppRunner.cpp.


The documentation for this class was generated from the following file: