Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
nsToolkit.cpp File Reference
#include "nsToolkit.h"
#include "nsSwitchToUIThread.h"

Go to the source code of this file.

Classes

struct  ThreadInitInfo

Functions

static MRESULT EXPENTRY nsToolkitWindowProc (HWND, ULONG, MPARAM, MPARAM)
void PR_CALLBACK RunPump (void *arg)
NS_METHOD NS_GetCurrentToolkit (nsIToolkit **aResult)

Variables

static PRUintn gToolkitTLSIndex = 0
PRBool gThreadState = PR_FALSE

Class Documentation

struct ThreadInitInfo

Definition at line 70 of file nsToolkit.cpp.

Collaboration diagram for ThreadInitInfo:
Class Members
PRMonitor * monitor
nsToolkit * toolkit

Function Documentation

Definition at line 225 of file nsToolkit.cpp.

{
  nsIToolkit* toolkit = nsnull;
  nsresult rv = NS_OK;
  PRStatus status;

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

  if (NS_SUCCEEDED(rv)) {
    toolkit = (nsIToolkit*)PR_GetThreadPrivate(gToolkitTLSIndex);

    //
    // Create a new toolkit for this thread...
    //
    if (!toolkit) {
      toolkit = new nsToolkit();

      if (!toolkit) {
        rv = NS_ERROR_OUT_OF_MEMORY;
      } else {
        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 rv;
}

Here is the call graph for this function:

MRESULT EXPENTRY nsToolkitWindowProc ( HWND  hWnd,
ULONG  msg,
MPARAM  mp1,
MPARAM  mp2 
) [static]

Definition at line 204 of file nsToolkit.cpp.

{
    switch (msg) {
        case WM_CALLMETHOD:
        {
            MethodInfo *info = (MethodInfo *)mp2;
            return (MRESULT)info->Invoke();
        }
    }
    return ::WinDefWindowProc(hWnd, msg, mp1, mp2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 64 of file nsToolkit.cpp.

{
    ThreadInitInfo *info = (ThreadInitInfo*)arg;
    ::PR_EnterMonitor(info->monitor);

    // do registration and creation in this thread
    info->toolkit->CreateInternalWindow(PR_GetCurrentThread());

    gThreadState = PR_TRUE;

    ::PR_Notify(info->monitor);
    ::PR_ExitMonitor(info->monitor);

    delete info;

    // Process messages
    QMSG qmsg;
    while (WinGetMsg((HAB)0, &qmsg, 0, 0, 0)) {
        WinDispatchMsg((HAB)0, &qmsg);
    }
}

Here is the call graph for this function:


Variable Documentation

Definition at line 57 of file nsToolkit.cpp.

PRUintn gToolkitTLSIndex = 0 [static]

Definition at line 52 of file nsToolkit.cpp.