Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsStorageStream.cpp File Reference
#include "nsStorageStream.h"
#include "nsSegmentedBuffer.h"
#include "nsCOMPtr.h"
#include "prbit.h"
#include "nsIInputStream.h"
#include "nsISeekableStream.h"
#include "prlog.h"
#include "nsInt64.h"

Go to the source code of this file.

Classes

class  nsStorageInputStream

Functions

 NS_IMPL_THREADSAFE_ISUPPORTS2 (nsStorageStream, nsIStorageStream, nsIOutputStream) NS_IMETHODIMP nsStorageStream
 NS_IMPL_THREADSAFE_ISUPPORTS2 (nsStorageInputStream, nsIInputStream, nsISeekableStream) NS_IMETHODIMP nsStorageStream
NS_COM nsresult NS_NewStorageStream (PRUint32 segmentSize, PRUint32 maxSize, nsIStorageStream **result)

Function Documentation

Definition at line 96 of file nsStorageStream.cpp.

{
    mSegmentedBuffer = new nsSegmentedBuffer();
    if (!mSegmentedBuffer)
        return NS_ERROR_OUT_OF_MEMORY;
    
    mSegmentSize = segmentSize;
    mSegmentSizeLog2 = PR_FloorLog2(segmentSize);

    // Segment size must be a power of two
    if (mSegmentSize != ((PRUint32)1 << mSegmentSizeLog2))
        return NS_ERROR_INVALID_ARG;

    return mSegmentedBuffer->Init(segmentSize, maxSize, segmentAllocator);
}

Definition at line 392 of file nsStorageStream.cpp.

{
    NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED);
    
    nsStorageInputStream *inputStream = new nsStorageInputStream(this, mSegmentSize);
    if (!inputStream)
        return NS_ERROR_OUT_OF_MEMORY;

    NS_ADDREF(inputStream);

    nsresult rv = inputStream->Seek(aStartingOffset);
    if (NS_FAILED(rv)) {
        NS_RELEASE(inputStream);
        return rv;
    }

    *aInputStream = inputStream;
    return NS_OK;
}

Here is the call graph for this function:

NS_COM nsresult NS_NewStorageStream ( PRUint32  segmentSize,
PRUint32  maxSize,
nsIStorageStream **  result 
)

Definition at line 578 of file nsStorageStream.cpp.

{
    NS_ENSURE_ARG(result);

    nsStorageStream* storageStream = new nsStorageStream();
    if (!storageStream) return NS_ERROR_OUT_OF_MEMORY;
    
    NS_ADDREF(storageStream);
    nsresult rv = storageStream->Init(segmentSize, maxSize, nsnull);
    if (NS_FAILED(rv)) {
        NS_RELEASE(storageStream);
        return rv;
    }
    *result = storageStream;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: