Back to index

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

#include <nsDiskCacheBinding.h>

Inheritance diagram for nsDiskCacheBinding:
Inheritance graph
[legend]
Collaboration diagram for nsDiskCacheBinding:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS nsDiskCacheBinding (nsCacheEntry *entry, nsDiskCacheRecord *record)
virtual ~nsDiskCacheBinding ()
nsresult EnsureStreamIO ()
PRBool IsActive ()

Static Public Member Functions

static NS_DECL_ISUPPORTS
nsDiskCacheBinding
Create (nsIFile *cacheDir, const char *key, int generation)

Public Attributes

nsCacheEntrymCacheEntry
nsDiskCacheRecord mRecord
nsDiskCacheStreamIOmStreamIO
PRBool mDoomed
PRUint8 mGeneration
nsCOMPtr< nsIFilemDataFile
int mGeneration

Detailed Description

Definition at line 65 of file nsDiskCacheBinding.h.


Constructor & Destructor Documentation

Definition at line 124 of file nsDiskCacheBinding.cpp.

    :   mCacheEntry(entry)
    ,   mStreamIO(nsnull)
{
    NS_ASSERTION(record->ValidRecord(), "bad record");
    PR_INIT_CLIST(this);
    mRecord     = *record;
    mDoomed     = entry->IsDoomed();
    mGeneration = record->Generation();    // 0 == uninitialized, or data & meta using block files
}

Definition at line 135 of file nsDiskCacheBinding.cpp.

{
    NS_ASSERTION(PR_CLIST_IS_EMPTY(this), "binding deleted while still on list");
    if (!PR_CLIST_IS_EMPTY(this))
        PR_REMOVE_LINK(this);       // XXX why are we still on a list?
    
    // sever streamIO/binding link
    if (mStreamIO) {
        mStreamIO->ClearBinding();
        NS_RELEASE(mStreamIO);
    }
}

Here is the call graph for this function:


Member Function Documentation

nsDiskCacheBinding * nsDiskCacheBinding::Create ( nsIFile cacheDir,
const char *  key,
int  generation 
) [static]

Definition at line 284 of file nsDiskCacheDeviceSQL.cpp.

{
  nsCOMPtr<nsIFile> file;
  cacheDir->Clone(getter_AddRefs(file));
  if (!file)
    return nsnull;

  PRUint64 hash = DCacheHash(key);

  PRUint32 dir1 = (PRUint32) (hash & 0x0F);
  PRUint32 dir2 = (PRUint32)((hash & 0xF0) >> 4);

  hash >>= 8;

  // XXX we might want to create these directories up-front

  file->AppendNative(nsPrintfCString("%X", dir1));
  file->Create(nsIFile::DIRECTORY_TYPE, 00700);

  file->AppendNative(nsPrintfCString("%X", dir2));
  file->Create(nsIFile::DIRECTORY_TYPE, 00700);

  nsresult rv;
  char leaf[64];

  if (generation == -1)
  {
    file->AppendNative(NS_LITERAL_CSTRING("placeholder"));

    for (generation = 0; ; ++generation)
    {
      PR_snprintf(leaf, sizeof(leaf), "%014llX-%X", hash, generation);

      rv = file->SetNativeLeafName(nsDependentCString(leaf));
      if (NS_FAILED(rv))
        return nsnull;
      rv = file->Create(nsIFile::NORMAL_FILE_TYPE, 00600);
      if (NS_FAILED(rv) && rv != NS_ERROR_FILE_ALREADY_EXISTS)
        return nsnull;
      if (NS_SUCCEEDED(rv))
        break;
    }
  }
  else
  {
    PR_snprintf(leaf, sizeof(leaf), "%014llX-%X", hash, generation);
    rv = file->AppendNative(nsDependentCString(leaf));
    if (NS_FAILED(rv))
      return nsnull;
  }

  nsDiskCacheBinding *binding = new nsDiskCacheBinding;
  if (!binding)
    return nsnull;

  binding->mDataFile.swap(file);
  binding->mGeneration = generation;
  return binding;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 149 of file nsDiskCacheBinding.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 73 of file nsDiskCacheBinding.h.

{ return mCacheEntry != nsnull;}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 77 of file nsDiskCacheBinding.h.

Definition at line 277 of file nsDiskCacheDeviceSQL.cpp.

Definition at line 80 of file nsDiskCacheBinding.h.

Definition at line 81 of file nsDiskCacheBinding.h.

Definition at line 278 of file nsDiskCacheDeviceSQL.cpp.

Definition at line 78 of file nsDiskCacheBinding.h.

Definition at line 79 of file nsDiskCacheBinding.h.


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