Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsCache.cpp File Reference
#include "nsCache.h"
#include "nsReadableUtils.h"
#include "nsDependentSubstring.h"
#include "nsString.h"

Go to the source code of this file.

Functions

PRUint32 SecondsFromPRTime (PRTime prTime)
 Cache Service Utility Functions.
PRTime PRTimeFromSeconds (PRUint32 seconds)
nsresult ClientIDFromCacheKey (const nsACString &key, char **result)
nsresult ClientKeyFromCacheKey (const nsCString &key, nsACString &result)

Function Documentation

nsresult ClientIDFromCacheKey ( const nsACString &  key,
char **  result 
)

Definition at line 108 of file nsCache.cpp.

{
    nsresult  rv = NS_OK;
    *result = nsnull;

    nsReadingIterator<char> colon;
    key.BeginReading(colon);
        
    nsReadingIterator<char> start;
    key.BeginReading(start);
        
    nsReadingIterator<char> end;
    key.EndReading(end);
        
    if (FindCharInReadable(':', colon, end)) {
        *result = ToNewCString( Substring(start, colon));
        if (!*result) rv = NS_ERROR_OUT_OF_MEMORY;
    } else {
        NS_ASSERTION(PR_FALSE, "FindCharInRead failed to find ':'");
        rv = NS_ERROR_UNEXPECTED;
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult ClientKeyFromCacheKey ( const nsCString key,
nsACString &  result 
)

Definition at line 134 of file nsCache.cpp.

{
    nsresult  rv = NS_OK;

    nsReadingIterator<char> start;
    key.BeginReading(start);
        
    nsReadingIterator<char> end;
    key.EndReading(end);
        
    if (FindCharInReadable(':', start, end)) {
        ++start;  // advance past clientID ':' delimiter
        result.Assign(Substring(start, end));
    } else {
        NS_ASSERTION(PR_FALSE, "FindCharInRead failed to find ':'");
        rv = NS_ERROR_UNEXPECTED;
        result.Truncate(0);
    }
    return rv;
}

Here is the call graph for this function:

Definition at line 95 of file nsCache.cpp.

{
  PRInt64 microSecondsPerSecond, intermediateResult;
  PRTime  prTime;

  LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
  LL_UI2L(intermediateResult, seconds);
  LL_MUL(prTime, intermediateResult, microSecondsPerSecond);
  return prTime;
}

Here is the caller graph for this function:

Cache Service Utility Functions.

Definition at line 82 of file nsCache.cpp.

{
  PRInt64  microSecondsPerSecond, intermediateResult;
  PRUint32 seconds;

  LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
  LL_DIV(intermediateResult, prTime, microSecondsPerSecond);
  LL_L2UI(seconds, intermediateResult);
  return seconds;
}