Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsStreamTransportService.cpp File Reference
#include "nsStreamTransportService.h"
#include "nsNetSegmentUtils.h"
#include "nsAutoLock.h"
#include "nsInt64.h"
#include "nsTransportUtils.h"
#include "nsStreamUtils.h"
#include "nsNetError.h"
#include "nsNetCID.h"
#include "nsIServiceManager.h"
#include "nsIAsyncInputStream.h"
#include "nsIAsyncOutputStream.h"
#include "nsISeekableStream.h"
#include "nsIPipe.h"
#include "nsITransport.h"
#include "nsIRunnable.h"
#include "nsIProxyObjectManager.h"
#include "nsIEventTarget.h"

Go to the source code of this file.

Classes

class  nsInputStreamTransport
class  nsOutputStreamTransport

Functions

 NS_IMPL_THREADSAFE_ISUPPORTS2 (nsInputStreamTransport, nsITransport, nsIInputStream) NS_IMETHODIMP nsInputStreamTransport
 nsITransport
 NS_IMPL_THREADSAFE_ISUPPORTS2 (nsOutputStreamTransport, nsITransport, nsIOutputStream) NS_IMETHODIMP nsOutputStreamTransport
 nsITransport

Function Documentation

nsITransport

Definition at line 107 of file nsStreamTransportService.cpp.

{
    NS_ENSURE_TRUE(!mInProgress, NS_ERROR_IN_PROGRESS);

    nsresult rv;
    nsCOMPtr<nsIEventTarget> target =
            do_GetService(NS_IOTHREADPOOL_CONTRACTID, &rv);
    if (NS_FAILED(rv)) return rv;

    // XXX if the caller requests an unbuffered stream, then perhaps
    //     we'd want to simply return mSource; however, then we would
    //     not be reading mSource on a background thread.  is this ok?
 
    PRBool nonblocking = !(flags & OPEN_BLOCKING);

    net_ResolveSegmentParams(segsize, segcount);
    nsIMemory *segalloc = net_GetSegmentAlloc(segsize);

    nsCOMPtr<nsIAsyncOutputStream> pipeOut;
    rv = NS_NewPipe2(getter_AddRefs(mPipeIn),
                     getter_AddRefs(pipeOut),
                     nonblocking, PR_TRUE,
                     segsize, segcount, segalloc);
    if (NS_FAILED(rv)) return rv;

    mInProgress = PR_TRUE;

    // startup async copy process...
    rv = NS_AsyncCopy(this, pipeOut, target,
                      NS_ASYNCCOPY_VIA_WRITESEGMENTS, segsize);
    if (NS_SUCCEEDED(rv))
        NS_ADDREF(*result = mPipeIn);

    return rv;
}

Here is the call graph for this function:

nsITransport

Definition at line 309 of file nsStreamTransportService.cpp.

{
    // this transport only supports writing!
    NS_NOTREACHED("nsOutputStreamTransport::OpenInputStream");
    return NS_ERROR_UNEXPECTED;
}