Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
tmTransactionManager Class Reference

This class manages the flow of messages from the IPC daemon (coming to it through the tmIPCModule) that ultimately come from a Transaction Service (TS) in a mozilla based client somewhere. More...

#include <tmTransactionManager.h>

Collaboration diagram for tmTransactionManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~tmTransactionManager ()
 reclaim the memory allcoated during initialization
PRInt32 Init ()
 Set up the storage of the queues - initialize the vector.
void HandleTransaction (tmTransaction *aTrans)
 Called from the tmIPCModule.
void SendTransaction (PRUint32 aDestClientIPCID, tmTransaction *aTrans)
 Called by the queues when they need to get a message back out to a client.

Protected Member Functions

tmQueueGetQueue (PRUint32 aQueueID)
tmQueueGetQueue (const char *aQueueName)
PRInt32 AddQueue (const char *aQueueType)
 If all is successful a new queue with the name provided will be created, and added to the collection of queues.
void RemoveQueue (PRUint32 aQueueID)
 
 

Protected Attributes

tmVector mQueues

Detailed Description

This class manages the flow of messages from the IPC daemon (coming to it through the tmIPCModule) that ultimately come from a Transaction Service (TS) in a mozilla based client somewhere.

The message is delivered to the proper queue, where it is dealt with.

New queues get created here as clients request them.

Definition at line 59 of file tmTransactionManager.h.


Constructor & Destructor Documentation

reclaim the memory allcoated during initialization

Definition at line 48 of file tmTransactionManager.cpp.

                                            {

  PRUint32 size = mQueues.Size();
  tmQueue *queue = nsnull;
  for (PRUint32 index = 0; index < size; index++) {
     queue = (tmQueue *)mQueues[index];
     if (queue) {
       delete queue;
     }
  }
}

Here is the call graph for this function:


Member Function Documentation

PRInt32 tmTransactionManager::AddQueue ( const char *  aQueueType) [protected]

If all is successful a new queue with the name provided will be created, and added to the collection of queues.

It will be initialized and ready to have transactions added.

This doesn't check for the existance of a queue with this name. IF there is already a queue with this name then you will get that when using GetQueue(qName) and never get the new queue created here. A call to GetQueue(qID) will be able to get at the new queue, however you had better cache the ID.

Returns:
-1 if the queue can't be created, or is not added
>= 0 if the queue was added successfully

Definition at line 140 of file tmTransactionManager.cpp.

                                                     {

  tmQueue* queue = new tmQueue();
  if (!queue)
    return -1;
  PRInt32 index = mQueues.Append(queue);
  if (index < 0)
    delete queue;
  else
    queue->Init(aQueueName, index, this);
  return index;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tmQueue* tmTransactionManager::GetQueue ( PRUint32  aQueueID) [inline, protected]
Returns:
the queue indexed by the ID passed in, which could be nsnull

Definition at line 108 of file tmTransactionManager.h.

                                       {
    return (tmQueue*) mQueues[aQueueID];
  }

Here is the caller graph for this function:

tmQueue * tmTransactionManager::GetQueue ( const char *  aQueueName) [protected]
Returns:
the queue with the name passed in
nsnull if there is no queue with that name

Definition at line 126 of file tmTransactionManager.cpp.

                                                     {

  PRUint32 size = mQueues.Size();
  tmQueue *queue = nsnull;
  for (PRUint32 index = 0; index < size; index++) {
    queue = (tmQueue*) mQueues[index];
    if (queue && strcmp(queue->GetName(), aQueueName) == 0)
      return queue;
  }
  return nsnull;
}

Here is the call graph for this function:

Called from the tmIPCModule.

Decide where to send the message and dispatch it.

Definition at line 69 of file tmTransactionManager.cpp.

                                                             {

  PRUint32 action = aTrans->GetAction();
  PRUint32 ownerID = aTrans->GetOwnerID();
  tmQueue *queue = nsnull;

  // get the right queue -- attaches do it differently
  if (action == TM_ATTACH) {
    const char *name = (char*) aTrans->GetMessage(); // is qName for Attaches
    queue = GetQueue(name);  
    if (!queue) {
      PRInt32 index = AddQueue(name);
      if (index >= 0)
        queue = GetQueue(index); // GetQueue may return nsnull
    }
  }
  else  // all other trans should have a valid queue ID already
    queue = GetQueue(aTrans->GetQueueID());

  if (queue) {
    // All possible actions should have a case, default is not valid
    //   delete trans when done with them, let the queue own the trans
    //   that are posted to them.
    PRInt32 result = 0;
    switch (action) {
    case TM_ATTACH:
      queue->AttachClient(ownerID);
      break;
    case TM_POST:
      result = queue->PostTransaction(aTrans);
      if (result >= 0) // post failed, aTrans cached in a tmQueue
        return;
      break;
    case TM_FLUSH:
      queue->FlushQueue(ownerID);
      break;
    case TM_DETACH:
      if (queue->DetachClient(ownerID) == TM_SUCCESS_DELETE_QUEUE) {
        // the last client has been removed, remove the queue
        RemoveQueue(aTrans->GetQueueID()); // this _could_ be out of bounds
      }
      break;
    default:
      PR_NOT_REACHED("bad action in the transaction");
    }
  }
  delete aTrans;
}

Here is the call graph for this function:

Set up the storage of the queues - initialize the vector.

Returns:
NS_OK if successful
-1 if initialization fails

Definition at line 61 of file tmTransactionManager.cpp.

                           {
  return mQueues.Init();
}

Here is the call graph for this function:

void tmTransactionManager::RemoveQueue ( PRUint32  aQueueID) [protected]

 

Definition at line 154 of file tmTransactionManager.cpp.

                                                   {
  PR_ASSERT(aQueueID <= mQueues.Size());

  tmQueue *queue = (tmQueue*)mQueues[aQueueID];
  if (queue) {
    mQueues.RemoveAt(aQueueID);
    delete queue;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmTransactionManager::SendTransaction ( PRUint32  aDestClientIPCID,
tmTransaction aTrans 
) [inline]

Called by the queues when they need to get a message back out to a client.

Definition at line 93 of file tmTransactionManager.h.

                                                                         {
    PR_ASSERT(aTrans);
    tmIPCModule::SendMsg(aDestClientIPCID, aTrans);
  }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 141 of file tmTransactionManager.h.


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