Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsCacheEntryDescriptor.cpp File Reference
#include "nsICache.h"
#include "nsCache.h"
#include "nsCacheService.h"
#include "nsCacheEntryDescriptor.h"
#include "nsCacheEntry.h"
#include "nsReadableUtils.h"
#include "nsIOutputStream.h"
#include "nsCRT.h"
#include "nsAutoLock.h"

Go to the source code of this file.

Functions

 NS_IMPL_THREADSAFE_ISUPPORTS2 (nsCacheEntryDescriptor, nsICacheEntryDescriptor, nsICacheEntryInfo) nsCacheEntryDescriptor
 NS_IMPL_THREADSAFE_ISUPPORTS1 (nsCacheEntryDescriptor::nsInputStreamWrapper, nsIInputStream) nsresult nsCacheEntryDescriptor
 NS_IMPL_THREADSAFE_ISUPPORTS1 (nsCacheEntryDescriptor::nsOutputStreamWrapper, nsIOutputStream) nsresult nsCacheEntryDescriptor

Function Documentation

Definition at line 481 of file nsCacheEntryDescriptor.cpp.

{
    nsAutoLock lock(nsCacheService::ServiceLock());

    nsCacheAccessMode mode;
    nsresult rv = mDescriptor->GetAccessGranted(&mode);
    if (NS_FAILED(rv)) return rv;

    NS_ENSURE_TRUE(mode & nsICache::ACCESS_READ, NS_ERROR_UNEXPECTED);

    nsCacheEntry* cacheEntry = mDescriptor->CacheEntry();
    if (!cacheEntry) return NS_ERROR_NOT_AVAILABLE;

    nsCOMPtr<nsIInputStream> input;
    rv = nsCacheService::OpenInputStreamForEntry(cacheEntry, mode,
                                                 mStartOffset,
                                                 getter_AddRefs(mInput));
    if (NS_FAILED(rv)) return rv;

    mInitialized = PR_TRUE;
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 558 of file nsCacheEntryDescriptor.cpp.

{
    nsAutoLock lock(nsCacheService::ServiceLock());

    nsCacheAccessMode mode;
    nsresult rv = mDescriptor->GetAccessGranted(&mode);
    if (NS_FAILED(rv)) return rv;

    NS_ENSURE_TRUE(mode & nsICache::ACCESS_WRITE, NS_ERROR_UNEXPECTED);

    nsCacheEntry* cacheEntry = mDescriptor->CacheEntry();
    if (!cacheEntry) return NS_ERROR_NOT_AVAILABLE;

    rv = nsCacheService::OpenOutputStreamForEntry(cacheEntry, mode, mStartOffset,
                                                  getter_AddRefs(mOutput));
    if (NS_FAILED(rv)) return rv;

    nsCacheDevice* device = cacheEntry->CacheDevice();
    if (!device) return NS_ERROR_NOT_AVAILABLE;

    // the entry has been truncated to mStartOffset bytes, inform the device.
    PRInt32 size = cacheEntry->DataSize();
    rv = device->OnDataSizeChange(cacheEntry, mStartOffset - size);
    if (NS_FAILED(rv)) return rv;

    cacheEntry->SetDataSize(mStartOffset);

    mInitialized = PR_TRUE;
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 51 of file nsCacheEntryDescriptor.cpp.

    : mCacheEntry(entry),
      mAccessGranted(accessGranted)
{
    PR_INIT_CLIST(this);
    NS_ADDREF(nsCacheService::GlobalInstance());  // ensure it lives for the lifetime of the descriptor
}

Here is the call graph for this function: