Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsPipe3.cpp File Reference
#include "nsIPipe.h"
#include "nsIEventTarget.h"
#include "nsISeekableStream.h"
#include "nsSegmentedBuffer.h"
#include "nsStreamUtils.h"
#include "nsAutoLock.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "prlog.h"
#include "nsInt64.h"

Go to the source code of this file.

Classes

class  nsPipeEvents
class  nsPipeInputStream
class  nsPipeOutputStream
class  nsPipe

Defines

#define LOG(args)
#define DEFAULT_SEGMENT_SIZE   4096
#define DEFAULT_SEGMENT_COUNT   16
#define COMPARE(s1, s2, i)

Functions

 NS_IMPL_QUERY_INTERFACE4 (nsPipeInputStream, nsIInputStream, nsIAsyncInputStream, nsISeekableStream, nsISearchableInputStream) NS_IMETHODIMP nsPipeInputStream
static NS_METHOD nsWriteToRawBuffer (nsIInputStream *inStr, void *closure, const char *fromRawSegment, PRUint32 offset, PRUint32 count, PRUint32 *writeCount)
 NS_IMPL_QUERY_INTERFACE2 (nsPipeOutputStream, nsIOutputStream, nsIAsyncOutputStream) NS_IMETHODIMP nsPipeOutputStream
static NS_METHOD nsReadFromRawBuffer (nsIOutputStream *outStr, void *closure, char *toRawSegment, PRUint32 offset, PRUint32 count, PRUint32 *readCount)
static NS_METHOD nsReadFromInputStream (nsIOutputStream *outStr, void *closure, char *toRawSegment, PRUint32 offset, PRUint32 count, PRUint32 *readCount)
NS_COM nsresult NS_NewPipe2 (nsIAsyncInputStream **pipeIn, nsIAsyncOutputStream **pipeOut, PRBool nonBlockingInput, PRBool nonBlockingOutput, PRUint32 segmentSize, PRUint32 segmentCount, nsIMemory *segmentAlloc)
 NS_NewPipe2.
NS_METHOD nsPipeConstructor (nsISupports *outer, REFNSIID iid, void **result)

Define Documentation

#define COMPARE (   s1,
  s2,
  i 
)
Value:
(ignoreCase                                                            \
     ? nsCRT::strncasecmp((const char *)s1, (const char *)s2, (PRUint32)i) \
     : nsCRT::strncmp((const char *)s1, (const char *)s2, (PRUint32)i))

Definition at line 874 of file nsPipe3.cpp.

Definition at line 60 of file nsPipe3.cpp.

Definition at line 59 of file nsPipe3.cpp.

#define LOG (   args)

Definition at line 56 of file nsPipe3.cpp.


Function Documentation

Definition at line 1035 of file nsPipe3.cpp.

{
    LOG(("OOO CloseWithStatus [this=%x reason=%x]\n", this, reason));

    if (NS_SUCCEEDED(reason))
        reason = NS_BASE_STREAM_CLOSED;

    // input stream may remain open
    mPipe->OnPipeException(reason, PR_TRUE);
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 678 of file nsPipe3.cpp.

{
    LOG(("III CloseWithStatus [this=%x reason=%x]\n", this, reason));

    if (NS_SUCCEEDED(reason))
        reason = NS_BASE_STREAM_CLOSED;

    mPipe->OnPipeException(reason);
    return NS_OK;
}

Here is the call graph for this function:

NS_COM nsresult NS_NewPipe2 ( nsIAsyncInputStream **  pipeIn,
nsIAsyncOutputStream **  pipeOut,
PRBool  nonBlockingInput = PR_FALSE,
PRBool  nonBlockingOutput = PR_FALSE,
PRUint32  segmentSize = 0,
PRUint32  segmentCount = 0,
nsIMemory segmentAlloc = nsnull 
)

NS_NewPipe2.

This function supercedes NS_NewPipe. It differs from NS_NewPipe in two major ways: (1) returns nsIAsyncInputStream and nsIAsyncOutputStream, so it is not necessary to QI in order to access these interfaces. (2) the size of the pipe is determined by the number of segments times the size of each segment.

Parameters:
pipeInresulting input end of the pipe
pipeOutresulting output end of the pipe
nonBlockingInputtrue specifies non-blocking input stream behavior
nonBlockingOutputtrue specifies non-blocking output stream behavior
segmentSizespecifies the segment size in bytes (pass 0 to use default value)
segmentCountspecifies the max number of segments (pass 0 to use default value) passing PR_UINT32_MAX here causes the pipe to have "infinite" space. this mode can be useful in some cases, but should always be used with caution. the default value for this parameter is a finite value.
segmentAllocpass reference to nsIMemory to have all pipe allocations use this allocator (pass null to use the default allocator)

Definition at line 1243 of file nsPipe3.cpp.

{
    nsresult rv;

    nsPipe *pipe = new nsPipe();
    if (!pipe)
        return NS_ERROR_OUT_OF_MEMORY;

    rv = pipe->Init(nonBlockingInput,
                    nonBlockingOutput,
                    segmentSize,
                    segmentCount,
                    segmentAlloc);
    if (NS_FAILED(rv)) {
        NS_ADDREF(pipe);
        NS_RELEASE(pipe);
        return rv;
    }

    pipe->GetInputStream(pipeIn);
    pipe->GetOutputStream(pipeOut);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_METHOD nsPipeConstructor ( nsISupports *  outer,
REFNSIID  iid,
void **  result 
)

Definition at line 1274 of file nsPipe3.cpp.

{
    if (outer)
        return NS_ERROR_NO_AGGREGATION;
    nsPipe *pipe = new nsPipe();
    if (!pipe)
        return NS_ERROR_OUT_OF_MEMORY;
    NS_ADDREF(pipe);
    nsresult rv = pipe->QueryInterface(iid, result);
    NS_RELEASE(pipe);
    return rv;
}

Here is the call graph for this function:

static NS_METHOD nsReadFromInputStream ( nsIOutputStream outStr,
void closure,
char *  toRawSegment,
PRUint32  offset,
PRUint32  count,
PRUint32 readCount 
) [static]

Definition at line 1155 of file nsPipe3.cpp.

{
    nsIInputStream* fromStream = (nsIInputStream*)closure;
    return fromStream->Read(toRawSegment, count, readCount);
}
static NS_METHOD nsReadFromRawBuffer ( nsIOutputStream outStr,
void closure,
char *  toRawSegment,
PRUint32  offset,
PRUint32  count,
PRUint32 readCount 
) [static]

Definition at line 1126 of file nsPipe3.cpp.

{
    const char* fromBuf = (const char*)closure;
    memcpy(toRawSegment, &fromBuf[offset], count);
    *readCount = count;
    return NS_OK;
}

Here is the call graph for this function:

static NS_METHOD nsWriteToRawBuffer ( nsIInputStream inStr,
void closure,
const char *  fromRawSegment,
PRUint32  offset,
PRUint32  count,
PRUint32 writeCount 
) [static]

Definition at line 789 of file nsPipe3.cpp.

{
    char *toBuf = (char*)closure;
    memcpy(&toBuf[offset], fromRawSegment, count);
    *writeCount = count;
    return NS_OK;
}

Here is the call graph for this function: