backing out changes (for bug 116365) to fix btek page-loader crash.

This commit is contained in:
darin%netscape.com 2002-03-26 08:47:10 +00:00
Родитель 4a33e6b812
Коммит 6774091263
26 изменённых файлов: 77 добавлений и 377 удалений

Просмотреть файл

@ -539,11 +539,7 @@ NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileTransport(nsMsgKey msgKey, PRUint32 *
if (NS_FAILED(rv))
return rv;
rv = fts->CreateTransport(localStore,
PR_RDWR | PR_CREATE_FILE,
0664,
PR_TRUE,
aFileChannel);
rv = fts->CreateTransport(localStore, PR_RDWR | PR_CREATE_FILE, 0664, aFileChannel);
if (NS_SUCCEEDED(rv))
{

Просмотреть файл

@ -234,7 +234,7 @@ nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, PRUint32 aStartPosition, P
if (NS_FAILED(rv)) return rv;
//we are always using this file socket to read data from the mailbox.
rv = fts->CreateTransport(file, PR_RDONLY,
0664, PR_TRUE, getter_AddRefs(m_transport));
0664, getter_AddRefs(m_transport));
m_socketIsOpen = PR_FALSE;
return rv;
@ -880,7 +880,7 @@ nsresult nsMsgFilePostHelper::Init(nsIOutputStream * aOutStream, nsMsgAsyncWrite
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> transport;
rv = fts->CreateTransport(aFileToPost, PR_RDONLY, 0664, PR_TRUE, getter_AddRefs(transport));
rv = fts->CreateTransport(aFileToPost, PR_RDONLY, 0664, getter_AddRefs(transport));
if (transport)
{
rv = transport->AsyncRead(this, nsnull, 0, PRUint32(-1), 0, getter_AddRefs(mPostFileRequest));

Просмотреть файл

@ -339,7 +339,7 @@ nsJARChannel::AsyncReadJARElement()
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> jarTransport;
rv = fts->CreateTransportFromStreamIO(this, PR_TRUE, getter_AddRefs(jarTransport));
rv = fts->CreateTransportFromStreamIO(this, getter_AddRefs(jarTransport));
if (NS_FAILED(rv)) return rv;
if (mCallbacks) {

Просмотреть файл

@ -49,8 +49,7 @@ interface nsIFileTransportService : nsISupports
{
nsITransport createTransport(in nsIFile file,
in long ioFlags,
in long perm,
in boolean closeStreamWhenDone);
in long perm);
// This version can be used with an existing input stream to serve
// as a data pump:
@ -61,8 +60,7 @@ interface nsIFileTransportService : nsISupports
in long contentLength,
in boolean closeStreamWhenDone);
nsITransport createTransportFromStreamIO(in nsIStreamIO io,
in boolean closeStreamWhenDone);
nsITransport createTransportFromStreamIO(in nsIStreamIO io);
void dispatchRequest(in nsIRunnable runnable);
void processPendingRequests();

Просмотреть файл

@ -307,7 +307,7 @@ nsFileIO::GetInputStream(nsIInputStream * *aInputStream)
if (fileIn == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(fileIn);
rv = fileIn->InitWithFileDescriptor(mFD, mFile);
rv = fileIn->InitWithFileDescriptor(mFD, mFile, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
#ifdef NS_NO_INPUT_BUFFERING
*aInputStream = fileIn;
@ -391,14 +391,12 @@ nsFileIO::GetName(nsACString &aName)
nsFileStream::nsFileStream()
: mFD(nsnull)
, mCloseFD(PR_TRUE)
{
NS_INIT_REFCNT();
}
nsFileStream::~nsFileStream()
{
if (mCloseFD)
Close();
}
@ -408,7 +406,6 @@ nsresult
nsFileStream::Close()
{
if (mFD) {
if (mCloseFD)
PR_Close(mFD);
mFD = nsnull;
}
@ -508,8 +505,6 @@ nsFileInputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
NS_IMETHODIMP
nsFileInputStream::Init(nsIFile* file, PRInt32 ioFlags, PRInt32 perm, PRBool deleteOnClose)
{
NS_ENSURE_TRUE(mFD == nsnull, NS_ERROR_ALREADY_INITIALIZED);
nsresult rv = NS_OK;
nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(file, &rv);
if (NS_FAILED(rv)) return rv;
@ -522,6 +517,17 @@ nsFileInputStream::Init(nsIFile* file, PRInt32 ioFlags, PRInt32 perm, PRBool del
rv = localFile->OpenNSPRFileDesc(ioFlags, perm, &fd);
if (NS_FAILED(rv)) return rv;
return InitWithFileDescriptor(fd, file, deleteOnClose);
}
nsresult
nsFileInputStream::InitWithFileDescriptor(PRFileDesc* fd, nsIFile* file, PRBool deleteOnClose)
{
NS_ASSERTION(mFD == nsnull, "already inited");
if (mFD || !fd)
return NS_ERROR_FAILURE;
mLineBuffer = nsnull;
mFD = fd;
if (deleteOnClose) {
@ -537,15 +543,6 @@ nsFileInputStream::Init(nsIFile* file, PRInt32 ioFlags, PRInt32 perm, PRBool del
return NS_OK;
}
nsresult
nsFileInputStream::InitWithFileDescriptor(PRFileDesc* fd, nsIFile* file)
{
NS_ENSURE_TRUE(mFD == nsnull, NS_ERROR_ALREADY_INITIALIZED);
mFD = fd;
mCloseFD = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsFileInputStream::Close()
{
@ -612,7 +609,6 @@ nsFileInputStream::ReadSegments(nsWriteSegmentFun writer, void * closure, PRUint
if (NS_SUCCEEDED(rv)) {
rv = writer(this, closure, readBuf, 0, nBytes, _retval);
NS_ASSERTION(NS_SUCCEEDED(rv) ? nBytes == *_retval : PR_TRUE, "Didn't write all Data.");
// XXX this assertion is invalid!
}
nsMemory::Free(readBuf);
@ -651,8 +647,6 @@ nsFileOutputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
NS_IMETHODIMP
nsFileOutputStream::Init(nsIFile* file, PRInt32 ioFlags, PRInt32 perm)
{
NS_ENSURE_TRUE(mFD == nsnull, NS_ERROR_ALREADY_INITIALIZED);
nsresult rv;
nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(file, &rv);
if (NS_FAILED(rv)) return rv;
@ -660,22 +654,21 @@ nsFileOutputStream::Init(nsIFile* file, PRInt32 ioFlags, PRInt32 perm)
ioFlags = PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE;
if (perm <= 0)
perm = 0664;
PRFileDesc* fd;
rv = localFile->OpenNSPRFileDesc(ioFlags, perm, &fd);
if (NS_FAILED(rv)) return rv;
mFD = fd;
return NS_OK;
return InitWithFileDescriptor(fd, file);
}
nsresult
nsFileOutputStream::InitWithFileDescriptor(PRFileDesc* fd, nsIFile* file)
{
NS_ENSURE_TRUE(mFD == nsnull, NS_ERROR_ALREADY_INITIALIZED);
NS_ASSERTION(mFD == nsnull, "already inited");
if (mFD || !fd)
return NS_ERROR_FAILURE;
mFD = fd;
mCloseFD = PR_FALSE;
return NS_OK;
}

Просмотреть файл

@ -91,7 +91,6 @@ public:
protected:
PRFileDesc* mFD;
PRBool mCloseFD;
};
////////////////////////////////////////////////////////////////////////////////
@ -117,7 +116,7 @@ public:
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
nsresult InitWithFileDescriptor(PRFileDesc* fd, nsIFile* file);
nsresult InitWithFileDescriptor(PRFileDesc* fd, nsIFile* file, PRBool deleteOnClose);
protected:
nsLineBuffer *mLineBuffer;
nsCOMPtr<nsIFile> mFileToDelete;

Просмотреть файл

@ -234,18 +234,14 @@ nsFileTransport::nsFileTransport()
}
nsresult
nsFileTransport::Init(nsFileTransportService *aService,
nsIFile *file,
PRInt32 ioFlags,
PRInt32 perm,
PRBool closeStreamWhenDone)
nsFileTransport::Init(nsFileTransportService *aService, nsIFile* file, PRInt32 ioFlags, PRInt32 perm)
{
nsresult rv;
nsCOMPtr<nsIFileIO> io;
rv = NS_NewFileIO(getter_AddRefs(io), file, ioFlags, perm);
if (NS_FAILED(rv)) return rv;
return Init(aService, io, closeStreamWhenDone);
return Init(aService, io);
}
nsresult
@ -262,13 +258,12 @@ nsFileTransport::Init(nsFileTransportService *aService,
rv = NS_NewInputStreamIO(getter_AddRefs(io), name, inStr,
contentType, contentCharset, contentLength);
if (NS_FAILED(rv)) return rv;
return Init(aService, io, closeStreamWhenDone);
mCloseStreamWhenDone = closeStreamWhenDone;
return Init(aService, io);
}
nsresult
nsFileTransport::Init(nsFileTransportService *aService,
nsIStreamIO* io,
PRBool closeStreamWhenDone)
nsFileTransport::Init(nsFileTransportService *aService, nsIStreamIO* io)
{
nsresult rv = NS_OK;
if (mLock == nsnull) {
@ -280,8 +275,6 @@ nsFileTransport::Init(nsFileTransportService *aService,
rv = mStreamIO->GetName(mStreamName);
NS_ASSERTION(NS_SUCCEEDED(rv), "GetName failed");
mCloseStreamWhenDone = closeStreamWhenDone;
NS_ADDREF(mService = aService);
PR_AtomicIncrement(&mService->mTotalTransports);

Просмотреть файл

@ -88,17 +88,14 @@ public:
nsresult Init(nsFileTransportService *aService, nsIFile* file,
PRInt32 ioFlags,
PRInt32 perm,
PRBool closeStreamWhenDone);
PRInt32 perm);
nsresult Init(nsFileTransportService *aService, const nsACString &name,
nsIInputStream *fromStream,
const nsACString &contentType,
const nsACString &contentCharset,
PRInt32 contentLength,
PRBool closeStreamWhenDone);
nsresult Init(nsFileTransportService *aService,
nsIStreamIO* io,
PRBool closeStreamWhenDone);
nsresult Init(nsFileTransportService *aService, nsIStreamIO* io);
void Process(nsIProgressEventSink *);
void DoClose(void);

Просмотреть файл

@ -127,7 +127,6 @@ NS_IMETHODIMP
nsFileTransportService::CreateTransport(nsIFile* file,
PRInt32 ioFlags,
PRInt32 perm,
PRBool closeStreamWhenDone,
nsITransport** result)
{
nsresult rv;
@ -135,7 +134,7 @@ nsFileTransportService::CreateTransport(nsIFile* file,
if (trans == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(trans);
rv = trans->Init(this, file, ioFlags, perm, closeStreamWhenDone);
rv = trans->Init(this, file, ioFlags, perm);
if (NS_FAILED(rv)) {
NS_RELEASE(trans);
return rv;
@ -171,7 +170,6 @@ nsFileTransportService::CreateTransportFromStream(const nsACString &name,
NS_IMETHODIMP
nsFileTransportService::CreateTransportFromStreamIO(nsIStreamIO *io,
PRBool closeStreamWhenDone,
nsITransport **result)
{
nsresult rv;
@ -179,7 +177,7 @@ nsFileTransportService::CreateTransportFromStreamIO(nsIStreamIO *io,
if (trans == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(trans);
rv = trans->Init(this, io, closeStreamWhenDone);
rv = trans->Init(this, io);
if (NS_FAILED(rv)) {
NS_RELEASE(trans);
return rv;

Просмотреть файл

@ -311,8 +311,7 @@ nsStreamIOChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt)
do_GetService(kFileTransportServiceCID, &rv);
if (NS_FAILED(rv)) goto done;
rv = fts->CreateTransportFromStreamIO(mStreamIO, PR_TRUE,
getter_AddRefs(mFileTransport));
rv = fts->CreateTransportFromStreamIO(mStreamIO, getter_AddRefs(mFileTransport));
if (NS_FAILED(rv)) goto done;
}

2
netwerk/cache/src/nsDiskCacheDevice.cpp поставляемый
Просмотреть файл

@ -580,7 +580,7 @@ nsDiskCacheDevice::GetTransportForEntry(nsCacheEntry * entry,
break;
}
rv = gFileTransportService->CreateTransport(file, ioFlags, PR_IRUSR | PR_IWUSR, PR_FALSE, result);
rv = gFileTransportService->CreateTransport(file, ioFlags, PR_IRUSR | PR_IWUSR, result);
return rv;
}

Просмотреть файл

@ -308,11 +308,7 @@ nsXMLMIMEDataSource::Serialize() {
do_GetService(kFileTransportServiceCID, &rv) ;
if(NS_FAILED(rv)) return rv ;
rv = fts->CreateTransport(mFile,
PR_WRONLY|PR_CREATE_FILE,
PR_IRWXU,
PR_TRUE,
getter_AddRefs(transport)) ;
rv = fts->CreateTransport(mFile, PR_WRONLY|PR_CREATE_FILE, PR_IRWXU, getter_AddRefs(transport)) ;
if(NS_FAILED(rv))
return rv ;
@ -730,11 +726,7 @@ nsXMLMIMEDataSource::InitFromFile( nsIFile* aFile )
do_GetService(kFileTransportServiceCID, &rv) ;
if(NS_FAILED(rv)) return rv ;
// Made second parameter 0 since I really don't know what it is used for
rv = fts->CreateTransport(aFile,
PR_RDONLY,
PR_IRWXU,
PR_TRUE,
getter_AddRefs(transport)) ;
rv = fts->CreateTransport(aFile, PR_RDONLY, PR_IRWXU, getter_AddRefs(transport)) ;
if(NS_FAILED(rv))
return rv ;

Просмотреть файл

@ -231,7 +231,7 @@ nsFileChannel::EnsureTransport()
do_GetService(kFileTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransport(mFile, mIOFlags, mPerm, PR_TRUE,
rv = fts->CreateTransport(mFile, mIOFlags, mPerm,
getter_AddRefs(mFileTransport));
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -59,7 +59,6 @@ nsHttpChannel::nsHttpChannel()
, mConnectionInfo(nsnull)
, mLoadFlags(LOAD_NORMAL)
, mStatus(NS_OK)
, mLogicalOffset(0)
, mCapabilities(0)
, mReferrerType(REFERRER_NONE)
, mCachedResponseHead(nsnull)
@ -71,7 +70,6 @@ nsHttpChannel::nsHttpChannel()
, mApplyConversion(PR_TRUE)
, mFromCacheOnly(PR_FALSE)
, mCachedContentIsValid(PR_FALSE)
, mCachedContentIsPartial(PR_FALSE)
, mResponseHeadersModified(PR_FALSE)
, mCanceled(PR_FALSE)
, mUploadStreamHasHeaders(PR_FALSE)
@ -391,7 +389,7 @@ nsHttpChannel::SetupTransaction()
if (mConnectionInfo->UsingSSL() || !mConnectionInfo->UsingHttpProxy()) {
rv = mURI->GetPath(path);
if (NS_FAILED(rv)) return rv;
// path may contain UTF-8 characters, so ensure that they're escaped.
// path may contain UTF-8 characters, so ensure that their escaped.
if (NS_EscapeURL(path.get(), path.Length(), esc_OnlyNonASCII, buf))
requestURI = buf.get();
else
@ -491,13 +489,8 @@ nsHttpChannel::ProcessResponse()
switch (httpStatus) {
case 200:
case 203:
// these can normally be cached
rv = ProcessNormal();
break;
case 206:
if (mCachedContentIsPartial) // an internal byte range request...
rv = ProcessPartialContent();
else
// these can normally be cached
rv = ProcessNormal();
break;
case 300:
@ -603,160 +596,6 @@ nsHttpChannel::ProcessNormal()
return rv;
}
//-----------------------------------------------------------------------------
// nsHttpChannel <byte-range>
//-----------------------------------------------------------------------------
nsresult
nsHttpChannel::SetupByteRangeRequest(PRUint32 partialLen)
{
// cached content has been found to be partial, add necessary request
// headers to complete cache entry.
// use strongest validator available...
const char *val = mCachedResponseHead->PeekHeader(nsHttp::ETag);
if (!val)
val = mCachedResponseHead->PeekHeader(nsHttp::Last_Modified);
if (!val) {
// if we hit this code it means mCachedResponseHead->IsResumable() is
// either broken or not being called.
NS_NOTREACHED("no cache validator");
return NS_ERROR_FAILURE;
}
char buf[32];
PR_snprintf(buf, sizeof(buf), "bytes=%u-", partialLen);
mRequestHead.SetHeader(nsHttp::Range, nsDependentCString(buf));
mRequestHead.SetHeader(nsHttp::If_Range, nsDependentCString(val));
return NS_OK;
}
nsresult
nsHttpChannel::ProcessPartialContent()
{
nsresult rv;
// ok, we've just received a 206
//
// we need to stream whatever data is in the cache out first, and then
// pick up whatever data is on the wire, writing it into the cache.
LOG(("nsHttpChannel::ProcessPartialContent [this=%x]\n", this));
NS_ENSURE_TRUE(mCachedResponseHead, NS_ERROR_NOT_INITIALIZED);
NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_NOT_INITIALIZED);
// suspend the current transaction (may still get an OnDataAvailable)
rv = mTransaction->Suspend();
if (NS_FAILED(rv)) return rv;
// merge any new headers with the cached response headers
rv = mCachedResponseHead->UpdateHeaders(mResponseHead->Headers());
if (NS_FAILED(rv)) return rv;
// update the cached response head
nsCAutoString head;
mCachedResponseHead->Flatten(head, PR_TRUE);
rv = mCacheEntry->SetMetaDataElement("response-head", head.get());
if (NS_FAILED(rv)) return rv;
// make the cached response be the current response
delete mResponseHead;
mResponseHead = mCachedResponseHead;
mCachedResponseHead = 0;
rv = UpdateExpirationTime();
if (NS_FAILED(rv)) return rv;
// the cached content is valid, although incomplete.
mCachedContentIsValid = PR_TRUE;
return ReadFromCache();
}
nsresult
nsHttpChannel::BufferPartialContent(nsIInputStream *input, PRUint32 count)
{
nsresult rv;
LOG(("nsHttpChannel::BufferPartialContent [this=%x count=%u]\n", this, count));
if (!mBufferOut) {
LOG(("creating pipe...\n"));
//
// create a pipe for buffering network data (the size of this
// pipe must be equal to or greater than the size of the pipe
// used to proxy data from the socket transport thread).
//
rv = NS_NewPipe(getter_AddRefs(mBufferIn),
getter_AddRefs(mBufferOut),
NS_HTTP_SEGMENT_SIZE,
NS_HTTP_BUFFER_SIZE,
PR_TRUE,
PR_TRUE);
if (NS_FAILED(rv)) return rv;
}
PRUint32 bytesWritten = 0;
rv = mBufferOut->WriteFrom(input, count, &bytesWritten);
if (NS_FAILED(rv) || (bytesWritten != count)) {
LOG(("writing to pipe failed [rv=%s bytes-written=%u]\n", rv, bytesWritten));
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
nsresult
nsHttpChannel::OnDoneReadingPartialCacheEntry(PRBool *streamDone)
{
nsresult rv;
LOG(("nsHttpChannel::OnDoneReadingPartialCacheEntry [this=%x]", this));
// by default, assume we would have streamed all data or failed...
*streamDone = PR_TRUE;
// setup cache listener to append to cache entry
PRUint32 size;
rv = mCacheEntry->GetDataSize(&size);
if (NS_FAILED(rv)) return rv;
rv = InstallCacheListener(size);
if (NS_FAILED(rv)) return rv;
// process any buffered data
if (mBufferIn) {
PRUint32 avail;
rv = mBufferIn->Available(&avail);
if (NS_FAILED(rv)) return rv;
rv = mListener->OnDataAvailable(this, mListenerContext, mBufferIn, size, avail);
if (NS_FAILED(rv)) return rv;
// done with the pipe
mBufferIn = 0;
mBufferOut = 0;
}
// need to track the logical offset of the data being sent to our listener
mLogicalOffset = size;
// we're now completing the cached content, so we can clear this flag.
// this puts us in the state of a regular download.
mCachedContentIsPartial = PR_FALSE;
// resume the transaction if it exists, otherwise the pipe contained the
// remaining part of the document and we've now streamed all of the data.
if (mTransaction) {
rv = mTransaction->Resume();
if (NS_SUCCEEDED(rv))
*streamDone = PR_FALSE;
}
return rv;
}
//-----------------------------------------------------------------------------
// nsHttpChannel <cache>
//-----------------------------------------------------------------------------
@ -825,10 +664,7 @@ nsHttpChannel::OpenCacheEntry(PRBool *delayed)
return NS_OK;
}
else if (mRequestHead.PeekHeader(nsHttp::Range)) {
// we don't support caching for byte range requests initiated
// by our clients.
// XXX perhaps we could munge their byte range into the cache
// key to make caching sort'a work.
// we don't support caching for byte range requests
return NS_OK;
}
@ -1014,24 +850,18 @@ nsHttpChannel::CheckCache()
}
// If the cached content-length is set and it does not match the data size
// of the cached content, then the cached response is partial...
// either we need to issue a byte range request or we need to refetch the
// entire document.
PRUint32 contentLength = (PRUint32) mCachedResponseHead->ContentLength();
if (contentLength != PRUint32(-1)) {
// of the cached content, then refetch.
PRInt32 contentLength = mCachedResponseHead->ContentLength();
if (contentLength != -1) {
PRUint32 size;
rv = mCacheEntry->GetDataSize(&size);
if (NS_FAILED(rv)) return rv;
if (size != contentLength) {
if (size != (PRUint32) contentLength) {
LOG(("Cached data size does not match the Content-Length header "
"[content-length=%u size=%u]\n", contentLength, size));
if ((size < contentLength) && mCachedResponseHead->IsResumable()) {
// looks like a partial entry.
rv = SetupByteRangeRequest(size);
if (NS_FAILED(rv)) return rv;
mCachedContentIsPartial = PR_TRUE;
}
// XXX must re-fetch until we learn how to do byte range requests.
return NS_OK;
}
}
@ -1172,7 +1002,7 @@ nsHttpChannel::ReadFromCache()
if (!mSecurityInfo)
mCacheEntry->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
if ((mCacheAccess & nsICache::ACCESS_WRITE) && !mCachedContentIsPartial) {
if (mCacheAccess & nsICache::ACCESS_WRITE) {
// We have write access to the cache, but we don't need to go to the
// server to validate at this time, so just mark the cache entry as
// valid in order to allow others access to this cache entry.
@ -1320,22 +1150,17 @@ nsHttpChannel::FinalizeCacheEntry()
// Open an output stream to the cache entry and insert a listener tee into
// the chain of response listeners.
nsresult
nsHttpChannel::InstallCacheListener(PRUint32 offset)
nsHttpChannel::InstallCacheListener()
{
nsresult rv;
LOG(("Preparing to write data into the cache [uri=%s]\n", mSpec.get()));
NS_ASSERTION(mCacheEntry, "no cache entry");
NS_ASSERTION(mListener, "no listener");
if (!mCacheTransport) {
rv = mCacheEntry->GetTransport(getter_AddRefs(mCacheTransport));
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIOutputStream> out;
rv = mCacheTransport->OpenOutputStream(offset, PRUint32(-1), 0, getter_AddRefs(out));
rv = mCacheTransport->OpenOutputStream(0, PRUint32(-1), 0, getter_AddRefs(out));
if (NS_FAILED(rv)) return rv;
// XXX disk cache does not support overlapped i/o yet
@ -2711,17 +2536,14 @@ nsHttpChannel::GetContentEncodings(nsISimpleEnumerator** aEncodings)
NS_IMETHODIMP
nsHttpChannel::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
{
if (!(mCanceled || NS_FAILED(mStatus))) {
// capture the request's status, so our consumers will know ASAP of any
// connection failures, etc - bug 93581
request->GetStatus(&mStatus);
}
LOG(("nsHttpChannel::OnStartRequest [this=%x request=%x status=%x]\n",
this, request, mStatus));
// don't enter this block if we're reading from the cache...
if (NS_SUCCEEDED(mStatus) && !mCacheReadRequest && mTransaction) {
if (mTransaction) {
// grab the security info from the connection object; the transaction
// is guaranteed to own a reference to the connection.
mSecurityInfo = mTransaction->SecurityInfo();
@ -2756,23 +2578,6 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st
mPrevTransaction = nsnull;
}
if (mCachedContentIsPartial && NS_SUCCEEDED(status)) {
if (request == mTransaction) {
// byte-range transaction finished before we got around to streaming it.
NS_ASSERTION(mCacheReadRequest, "should be reading from cache right now");
NS_RELEASE(mTransaction);
mTransaction = nsnull;
return NS_OK;
}
if (request == mCacheReadRequest) {
PRBool streamDone;
status = OnDoneReadingPartialCacheEntry(&streamDone);
if (NS_SUCCEEDED(status) && !streamDone)
return status;
// otherwise, fall through and fire OnStopRequest...
}
}
// if the request is for something we no longer reference, then simply
// drop this event.
if ((request != mTransaction) && (request != mCacheReadRequest))
@ -2781,11 +2586,8 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st
mIsPending = PR_FALSE;
mStatus = status;
PRBool isPartial = PR_FALSE;
if (mTransaction) {
// find out if the transaction ran to completion...
isPartial = !mTransaction->ResponseIsComplete();
// at this point, we're done with the transaction
if (mTransaction) {
NS_RELEASE(mTransaction);
mTransaction = nsnull;
}
@ -2807,21 +2609,12 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st
}
if (mCacheEntry) {
nsresult closeStatus = status;
if (mCanceled) {
// we don't want to discard the cache entry if canceled and
// reading from the cache.
if (request == mCacheReadRequest)
closeStatus = NS_OK;
// we also don't want to discard the cache entry if the
// server supports byte range requests, because we could always
// complete the download at a later time.
else if (isPartial && mResponseHead && mResponseHead->IsResumable()) {
LOG(("keeping partial response that is resumable!\n"));
closeStatus = NS_OK;
}
}
CloseCacheEntry(closeStatus);
if (mCanceled && (request == mCacheReadRequest))
CloseCacheEntry(NS_OK);
else
CloseCacheEntry(status);
}
if (mLoadGroup)
@ -2842,11 +2635,6 @@ nsHttpChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
LOG(("nsHttpChannel::OnDataAvailable [this=%x request=%x offset=%u count=%u]\n",
this, request, offset, count));
if (mCachedContentIsPartial && (request == mTransaction)) {
// XXX we can eliminate this buffer once bug 93055 is resolved.
return BufferPartialContent(input, count);
}
// if the request is for something we no longer reference, then simply
// drop this event.
if ((request != mTransaction) && (request != mCacheReadRequest)) {
@ -2854,21 +2642,8 @@ nsHttpChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
return NS_BASE_STREAM_CLOSED;
}
if (mListener) {
//
// we have to manually keep the logical offset of the stream up-to-date.
// we cannot depend soley on the offset provided, since we may have
// already streamed some data from another source (see, for example,
// OnDoneReadingPartialCacheEntry).
//
nsresult rv = mListener->OnDataAvailable(this,
mListenerContext,
input,
mLogicalOffset,
count);
mLogicalOffset += count;
return rv;
}
if (mListener)
return mListener->OnDataAvailable(this, mListenerContext, input, offset, count);
return NS_BASE_STREAM_CLOSED;
}

Просмотреть файл

@ -40,12 +40,10 @@
#include "nsICacheListener.h"
#include "nsITransport.h"
#include "nsIUploadChannel.h"
#include "nsISimpleEnumerator.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsHttpConnection.h"
#include "nsISimpleEnumerator.h"
class nsHttpTransaction;
class nsHttpResponseHead;
@ -108,13 +106,7 @@ private:
nsresult InitCacheEntry();
nsresult StoreAuthorizationMetaData();
nsresult FinalizeCacheEntry();
nsresult InstallCacheListener(PRUint32 offset = 0);
// byte range request specific methods
nsresult SetupByteRangeRequest(PRUint32 partialLen);
nsresult ProcessPartialContent();
nsresult BufferPartialContent(nsIInputStream *, PRUint32 count);
nsresult OnDoneReadingPartialCacheEntry(PRBool *streamDone);
nsresult InstallCacheListener();
// auth specific methods
nsresult GetCredentials(const char *challenges, PRBool proxyAuth, nsAFlatCString &creds);
@ -157,7 +149,6 @@ private:
PRUint32 mLoadFlags;
PRUint32 mStatus;
PRUint32 mLogicalOffset;
PRUint8 mCapabilities;
PRUint8 mReferrerType;
@ -170,10 +161,6 @@ private:
PRUint32 mPostID;
PRUint32 mRequestTime;
// byte-range specific data
nsCOMPtr<nsIInputStream> mBufferIn;
nsCOMPtr<nsIOutputStream> mBufferOut;
// auth specific data
nsXPIDLString mUser;
nsXPIDLString mPass;
@ -187,7 +174,6 @@ private:
PRPackedBool mApplyConversion;
PRPackedBool mFromCacheOnly;
PRPackedBool mCachedContentIsValid;
PRPackedBool mCachedContentIsPartial;
PRPackedBool mResponseHeadersModified;
PRPackedBool mCanceled;
PRPackedBool mUploadStreamHasHeaders;

Просмотреть файл

@ -363,17 +363,6 @@ nsHttpResponseHead::MustValidateIfExpired()
return val && PL_strcasestr(val, "must-revalidate");
}
PRBool
nsHttpResponseHead::IsResumable()
{
// even though some HTTP/1.0 servers may support byte range requests, we're not
// going to bother with them, since those servers wouldn't understand If-Range.
return mVersion >= NS_HTTP_VERSION_1_1 &&
PeekHeader(nsHttp::Content_Length) &&
(PeekHeader(nsHttp::ETag) || PeekHeader(nsHttp::Last_Modified)) &&
PL_strcasestr(PeekHeader(nsHttp::Accept_Ranges), "bytes");
}
PRBool
nsHttpResponseHead::ExpiresInPast()
{

Просмотреть файл

@ -87,9 +87,6 @@ public:
PRBool MustValidate();
PRBool MustValidateIfExpired();
// returns true if the server appears to support byte range requests.
PRBool IsResumable();
// returns true if the Expires header has a value in the past relative to the
// value of the Date header.
PRBool ExpiresInPast();

Просмотреть файл

@ -95,7 +95,6 @@ nsHttpTransaction::nsHttpTransaction(nsIStreamListener *listener,
, mCapabilities(caps)
, mHaveStatusLine(PR_FALSE)
, mHaveAllHeaders(PR_FALSE)
, mResponseIsComplete(PR_FALSE)
, mFiredOnStart(PR_FALSE)
, mNoContent(PR_FALSE)
, mPrematureEOF(PR_FALSE)
@ -618,7 +617,6 @@ nsHttpTransaction::HandleContent(char *buf,
// OnTransactionComplete is fired only once!
PRInt32 priorVal = PR_AtomicSet(&mTransactionDone, 1);
if (priorVal == 0) {
mResponseIsComplete = PR_TRUE;
// let the connection know that we are done with it; this should
// result in OnStopTransaction being fired.
return mConnection->OnTransactionComplete(this, NS_OK);

Просмотреть файл

@ -78,9 +78,6 @@ public:
// will drop any reference to the response headers after this call.
nsHttpResponseHead *TakeResponseHead();
// Called to find out if the transaction generated a complete response.
PRBool ResponseIsComplete() { return mResponseIsComplete; }
// nsAHttpTransaction methods:
void SetConnection(nsAHttpConnection *conn) { NS_IF_ADDREF(mConnection = conn); }
void SetSecurityInfo(nsISupports *info) { mSecurityInfo = info; }
@ -136,7 +133,6 @@ private:
PRPackedBool mHaveStatusLine;
PRPackedBool mHaveAllHeaders;
PRPackedBool mResponseIsComplete;
PRPackedBool mFiredOnStart;
PRPackedBool mNoContent; // expecting an empty entity body?
PRPackedBool mPrematureEOF;

Просмотреть файл

@ -339,7 +339,7 @@ nsJARChannel::AsyncReadJARElement()
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> jarTransport;
rv = fts->CreateTransportFromStreamIO(this, PR_TRUE, getter_AddRefs(jarTransport));
rv = fts->CreateTransportFromStreamIO(this, getter_AddRefs(jarTransport));
if (NS_FAILED(rv)) return rv;
if (mCallbacks) {

Просмотреть файл

@ -366,7 +366,7 @@ ParallelReadTest(char* dirName, nsIFileTransportService* fts)
NS_ASSERTION(listener, "QI failed");
nsITransport* trans;
rv = fts->CreateTransport(file, PR_RDONLY, 0, PR_TRUE, &trans);
rv = fts->CreateTransport(file, PR_RDONLY, 0, &trans);
NS_ASSERTION(NS_SUCCEEDED(rv), "create failed");
nsCOMPtr<nsIRequest> request;
rv = trans->AsyncRead(nsnull, listener, 0, -1, 0, getter_AddRefs(request));

Просмотреть файл

@ -204,7 +204,7 @@ TestAsyncRead(const char* fileName, PRUint32 offset, PRInt32 length)
nsCOMPtr<nsILocalFile> file;
rv = NS_NewLocalFile(fileName, PR_FALSE, getter_AddRefs(file));
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransport(file, PR_RDONLY, 0, PR_TRUE, &fileTrans);
rv = fts->CreateTransport(file, PR_RDONLY, 0, &fileTrans);
if (NS_FAILED(rv)) return rv;
MyListener* listener = new MyListener();
@ -260,7 +260,7 @@ TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length)
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransport(file,
PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
0664, PR_TRUE, &fileTrans);
0664, &fileTrans);
if (NS_FAILED(rv)) return rv;
MyListener* listener = new MyListener();

Просмотреть файл

@ -133,7 +133,7 @@ TestSyncWrite(char* filename, PRUint32 startPosition, PRInt32 length)
if (NS_FAILED(rv)) return rv ;
nsCOMPtr<nsITransport> transport;
rv = fts->CreateTransport(fs, PR_RDWR | PR_CREATE_FILE, 0664, PR_TRUE,
rv = fts->CreateTransport(fs, PR_RDWR | PR_CREATE_FILE, 0664,
getter_AddRefs(transport)) ;
if (NS_FAILED(rv)) return rv ;

Просмотреть файл

@ -1030,14 +1030,10 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> fileTransport;
rv = fts->CreateTransport(mTempFile,
PR_WRONLY | PR_CREATE_FILE,
0600,
PR_TRUE,
getter_AddRefs(fileTransport));
rv = fts->CreateTransport(mTempFile, PR_WRONLY | PR_CREATE_FILE, 0600, getter_AddRefs(fileTransport));
if (NS_FAILED(rv)) return rv;
rv = fileTransport->OpenOutputStream(0, PRUint32(-1), 0, getter_AddRefs(mOutStream));
rv = fileTransport->OpenOutputStream(0, -1, 0, getter_AddRefs(mOutStream));
#ifdef XP_MAC
nsXPIDLCString contentType;

Просмотреть файл

@ -168,7 +168,6 @@ nsStreamXferOp::Start( void ) {
rv = fts->CreateTransport( mOutputFile,
PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
0664,
PR_TRUE,
getter_AddRefs( mOutputTransport ) );
if ( NS_SUCCEEDED( rv ) ) {

Просмотреть файл

@ -777,7 +777,6 @@ nsXPInstallManager::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
rv = fts->CreateTransport(mItem->mFile,
PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
0664,
PR_TRUE,
getter_AddRefs( outTransport));
if (NS_SUCCEEDED(rv))