Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
nsToolkitBase.cpp File Reference
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <mach/mach_port.h>
#include <mach/mach_interface.h>
#include <mach/mach_init.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
#include <IOKit/IOMessage.h>
#include <CoreFoundation/CoreFoundation.h>
#include <Carbon/Carbon.h>
#include "nsToolkitBase.h"
#include "nsWidgetAtoms.h"
#include "nsIEventQueue.h"
#include "nsIEventQueueService.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"

Go to the source code of this file.

Functions

 NS_IMPL_THREADSAFE_ISUPPORTS1 (nsToolkitBase, nsIToolkit)
static void ToolkitSleepWakeCallback (void *refCon, io_service_t service, natural_t messageType, void *messageArgument)
NS_METHOD NS_GetCurrentToolkit (nsIToolkit **aResult)

Variables

static io_connect_t gRootPort = nsnull
static const char kQuartzRenderingPref [] = "browser.quartz.enable"
static const char kAllFontSizesPref [] = "browser.quartz.enable.all_font_sizes"
static PRUintn gToolkitTLSIndex = 0

Function Documentation

Definition at line 256 of file nsToolkitBase.cpp.

{
  NS_ENSURE_ARG_POINTER(aResult);
  *aResult = nsnull;

  // Create the TLS index the first time through...
  if (gToolkitTLSIndex == 0)
  {
    PRStatus status = PR_NewThreadPrivateIndex(&gToolkitTLSIndex, NULL);
    if (PR_FAILURE == status)
      return NS_ERROR_FAILURE;
  }

  //
  // Create a new toolkit for this thread...
  //
  nsToolkitBase* toolkit = (nsToolkitBase*)PR_GetThreadPrivate(gToolkitTLSIndex);
  if (!toolkit)
  {
    toolkit = NS_CreateToolkitInstance();
    if (!toolkit)
      return NS_ERROR_OUT_OF_MEMORY;

    NS_ADDREF(toolkit);
    toolkit->Init(PR_GetCurrentThread());
    //
    // The reference stored in the TLS is weak.  It is removed in the
    // nsToolkit destructor...
    //
    PR_SetThreadPrivate(gToolkitTLSIndex, (void*)toolkit);
  }
  else
  {
    NS_ADDREF(toolkit);
  }
  *aResult = toolkit;
  return NS_OK;
}

Here is the call graph for this function:

static void ToolkitSleepWakeCallback ( void refCon,
io_service_t  service,
natural_t  messageType,
void messageArgument 
) [static]

Definition at line 173 of file nsToolkitBase.cpp.

{
  switch (messageType)
  {
    case kIOMessageSystemWillSleep:
      // System is going to sleep now.
      nsToolkitBase::PostSleepWakeNotification("sleep_notification");
      ::IOAllowPowerChange(gRootPort, (long)messageArgument);
      break;

    case kIOMessageCanSystemSleep:
      // In this case, the computer has been idle for several minutes
      // and will sleep soon so you must either allow or cancel
      // this notification. Important: if you donŐt respond, there will
      // be a 30-second timeout before the computer sleeps.
      // In Mozilla's case, we always allow sleep.
      ::IOAllowPowerChange(gRootPort,(long)messageArgument);
      break;

    case kIOMessageSystemHasPoweredOn:
      // Handle wakeup.
      nsToolkitBase::PostSleepWakeNotification("wake_notification");
      break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

io_connect_t gRootPort = nsnull [static]

Definition at line 63 of file nsToolkitBase.cpp.

PRUintn gToolkitTLSIndex = 0 [static]

Definition at line 72 of file nsToolkitBase.cpp.

const char kAllFontSizesPref[] = "browser.quartz.enable.all_font_sizes" [static]

Definition at line 66 of file nsToolkitBase.cpp.

const char kQuartzRenderingPref[] = "browser.quartz.enable" [static]

Definition at line 65 of file nsToolkitBase.cpp.