Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
imgCache.cpp File Reference
#include "imgCache.h"
#include "ImageLogging.h"
#include "imgRequest.h"
#include "nsXPIDLString.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIMemory.h"
#include "nsIObserverService.h"
#include "nsICache.h"
#include "nsICacheService.h"
#include "nsICacheSession.h"
#include "nsICacheEntryDescriptor.h"
#include "nsIFile.h"
#include "nsIFileURL.h"

Go to the source code of this file.

Functions

void GetCacheSession (nsIURI *aURI, nsICacheSession **_retval)
static PRUint32 SecondsFromPRTime (PRTime prTime)

Variables

static nsCOMPtr< nsICacheSessiongSession = nsnull
static nsCOMPtr< nsICacheSessiongChromeSession = nsnull

Function Documentation

void GetCacheSession ( nsIURI aURI,
nsICacheSession **  _retval 
)

Definition at line 133 of file imgCache.cpp.

{
  NS_ASSERTION(aURI, "Null URI!");

  PRBool isChrome = PR_FALSE;
  aURI->SchemeIs("chrome", &isChrome);

  if (gSession && !isChrome) {
    *_retval = gSession;
    NS_ADDREF(*_retval);
    return;
  }

  if (gChromeSession && isChrome) {
    *_retval = gChromeSession;
    NS_ADDREF(*_retval);
    return;
  }

  nsCOMPtr<nsICacheService> cacheService(do_GetService("@mozilla.org/network/cache-service;1"));
  if (!cacheService) {
    NS_WARNING("Unable to get the cache service");
    return;
  }

  nsCOMPtr<nsICacheSession> newSession;
  cacheService->CreateSession(isChrome ? "image-chrome" : "image",
                              nsICache::STORE_IN_MEMORY,
                              nsICache::NOT_STREAM_BASED,
                              getter_AddRefs(newSession));

  if (!newSession) {
    NS_WARNING("Unable to create a cache session");
    return;
  }

  if (isChrome)
    gChromeSession = newSession;
  else {
    gSession = newSession;
    gSession->SetDoomEntriesIfExpired(PR_FALSE);
  }

  *_retval = newSession;
  NS_ADDREF(*_retval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRUint32 SecondsFromPRTime ( PRTime  prTime) [static]

Definition at line 244 of file imgCache.cpp.

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

Variable Documentation

Definition at line 131 of file imgCache.cpp.

Definition at line 130 of file imgCache.cpp.