Back to index

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

#include <nsIMAPBodyShell.h>

List of all members.

Public Member Functions

virtual ~nsIMAPBodyShellCache ()
PRBool AddShellToCache (nsIMAPBodyShell *shell)
nsIMAPBodyShellFindShellForUID (nsCString &UID, const char *mailboxName, IMAP_ContentModifiedType modType)
nsIMAPBodyShellFindShellForUID (PRUint32 UID, const char *mailboxName, IMAP_ContentModifiedType modType)

Static Public Member Functions

static nsIMAPBodyShellCacheCreate ()

Protected Member Functions

 nsIMAPBodyShellCache ()
PRBool EjectEntry ()
PRUint32 GetSize ()
PRUint32 GetMaxSize ()

Protected Attributes

nsVoidArraym_shellList
nsHashtable * m_shellHash

Detailed Description

Definition at line 308 of file nsIMAPBodyShell.h.


Constructor & Destructor Documentation

Definition at line 1234 of file nsIMAPBodyShell.cpp.

{
  while (EjectEntry()) ;
  delete m_shellHash;
  delete m_shellList;
}

Here is the call graph for this function:

Definition at line 1219 of file nsIMAPBodyShell.cpp.

{
  m_shellHash = new nsHashtable(20); /* , XP_StringHash, imap_shell_cache_strcmp); */
  m_shellList = new nsVoidArray();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

Definition at line 1261 of file nsIMAPBodyShell.cpp.

{
       // If it's already in the cache, then just return.
       // This has the side-effect of re-ordering the LRU list
       // to put this at the top, which is good, because it's what we want.
       if (FindShellForUID(shell->GetUID(), shell->GetFolderName(), shell->GetContentModified()))
              return PR_TRUE;

       // OK, so it's not in the cache currently.

       // First, for safety sake, remove any entry with the given UID,
       // just in case we have a collision between two messages in different
       // folders with the same UID.
       nsCStringKey hashKey1(shell->GetUID());
       nsIMAPBodyShell *foundShell = (nsIMAPBodyShell *) m_shellHash->Get(&hashKey1);
       if (foundShell)
       {
              nsCStringKey hashKey(foundShell->GetUID());
              m_shellHash->Remove(&hashKey);
              m_shellList->RemoveElement(foundShell);
       }

       // Add the new one to the cache
       m_shellList->AppendElement(shell);
       
       nsCStringKey hashKey2 (shell->GetUID());
       m_shellHash->Put(&hashKey2, shell);
       shell->SetIsCached(PR_TRUE);

       // while we're not over our size limit, eject entries
       PRBool rv = PR_TRUE;
       while (GetSize() > GetMaxSize())
       {
              rv = EjectEntry();
       }

       return rv;

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1225 of file nsIMAPBodyShell.cpp.

{
  nsIMAPBodyShellCache *cache = new nsIMAPBodyShellCache();
  if (!cache || !cache->m_shellHash || !cache->m_shellList)
    return NULL;
  
  return cache;
}

Here is the call graph for this function:

Definition at line 1244 of file nsIMAPBodyShell.cpp.

{
       if (m_shellList->Count() < 1)
              return PR_FALSE;



       nsIMAPBodyShell *removedShell = (nsIMAPBodyShell *) (m_shellList->ElementAt(0));

       m_shellList->RemoveElementAt(0);
       nsCStringKey hashKey (removedShell->GetUID());
       m_shellHash->Remove(&hashKey);
       delete removedShell;

       return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1301 of file nsIMAPBodyShell.cpp.

{
       nsCStringKey hashKey(UID);
       nsIMAPBodyShell *foundShell = (nsIMAPBodyShell *) m_shellHash->Get(&hashKey);

       if (!foundShell)
              return nsnull;

  // Make sure the content-modified types are compatible.
  // This allows us to work seamlessly while people switch between
  // View Attachments Inline and View Attachments As Links.
  // Enforce the invariant that any cached shell we use
  // match the current content-modified settings.
  if (modType != foundShell->GetContentModified())
    return nsnull;

       // mailbox names must match also.
       if (PL_strcmp(mailboxName, foundShell->GetFolderName()))
              return nsnull;

       // adjust the LRU stuff
       m_shellList->RemoveElement(foundShell);   // oh well, I suppose this defeats the performance gain of the hash if it actually is found
       m_shellList->AppendElement(foundShell);          // Adds to end
       
       return foundShell;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1329 of file nsIMAPBodyShell.cpp.

{
       nsCString uidString;
       
       uidString.AppendInt(UID);
       nsIMAPBodyShell *rv = FindShellForUID(uidString, mailboxName, modType);
       return rv;
}

Here is the call graph for this function:

PRUint32 nsIMAPBodyShellCache::GetMaxSize ( ) [inline, protected]

Definition at line 326 of file nsIMAPBodyShell.h.

{ return 20; }

Here is the caller graph for this function:

PRUint32 nsIMAPBodyShellCache::GetSize ( void  ) [inline, protected]

Definition at line 325 of file nsIMAPBodyShell.h.

{ return m_shellList->Count(); }

Here is the caller graph for this function:


Member Data Documentation

nsHashtable* nsIMAPBodyShellCache::m_shellHash [protected]

Definition at line 331 of file nsIMAPBodyShell.h.

Definition at line 330 of file nsIMAPBodyShell.h.


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