1999-11-08 00:55:12 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
2000-09-22 10:21:18 +04:00
|
|
|
* Copyright (C) 1998,2000 Netscape Communications Corporation. All Rights
|
1999-11-08 00:55:12 +03:00
|
|
|
* Reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-11-30 07:50:42 +03:00
|
|
|
#include "nsNetUtil.h"
|
1999-11-08 00:55:12 +03:00
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsJARChannel.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsIFileTransportService.h"
|
2000-09-22 10:21:18 +04:00
|
|
|
#include "nsIURI.h"
|
2000-09-08 04:24:13 +04:00
|
|
|
#include "nsCExternalHandlerService.h"
|
1999-11-08 00:55:12 +03:00
|
|
|
#include "nsIMIMEService.h"
|
2000-01-24 06:54:20 +03:00
|
|
|
#include "nsAutoLock.h"
|
2000-01-25 00:28:28 +03:00
|
|
|
#include "nsIFileStreams.h"
|
2000-02-09 08:04:52 +03:00
|
|
|
#include "nsMimeTypes.h"
|
2000-03-21 07:17:37 +03:00
|
|
|
#include "nsScriptSecurityManager.h"
|
|
|
|
#include "nsIAggregatePrincipal.h"
|
2001-02-21 23:38:08 +03:00
|
|
|
#include "nsIProgressEventSink.h"
|
2000-04-12 12:25:32 +04:00
|
|
|
#include "nsXPIDLString.h"
|
2001-02-23 03:15:04 +03:00
|
|
|
#include "nsIJAR.h"
|
2000-06-03 03:39:45 +04:00
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
1999-11-12 09:13:13 +03:00
|
|
|
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
|
2000-03-21 07:17:37 +03:00
|
|
|
static NS_DEFINE_CID(kScriptSecurityManagerCID, NS_SCRIPTSECURITYMANAGER_CID);
|
2000-02-01 02:43:09 +03:00
|
|
|
|
2000-03-30 11:39:31 +04:00
|
|
|
#if defined(PR_LOGGING)
|
|
|
|
//
|
2001-08-02 05:35:28 +04:00
|
|
|
// Log module for JarChannel logging...
|
2000-03-30 11:39:31 +04:00
|
|
|
//
|
|
|
|
// To enable logging (see prlog.h for full details):
|
|
|
|
//
|
|
|
|
// set NSPR_LOG_MODULES=nsJarProtocol:5
|
|
|
|
// set NSPR_LOG_FILE=nspr.log
|
|
|
|
//
|
|
|
|
// this enables PR_LOG_DEBUG level information and places all output in
|
|
|
|
// the file nspr.log
|
|
|
|
//
|
|
|
|
PRLogModuleInfo* gJarProtocolLog = nsnull;
|
|
|
|
|
|
|
|
#endif /* PR_LOGGING */
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2000-04-12 11:58:24 +04:00
|
|
|
#define NS_DEFAULT_JAR_BUFFER_SEGMENT_SIZE (16*1024)
|
|
|
|
#define NS_DEFAULT_JAR_BUFFER_MAX_SIZE (256*1024)
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
nsJARChannel::nsJARChannel()
|
2001-04-10 10:01:08 +04:00
|
|
|
: mLoadFlags(LOAD_NORMAL),
|
2000-04-26 18:31:01 +04:00
|
|
|
mContentType(nsnull),
|
|
|
|
mContentLength(-1),
|
2000-02-01 02:43:09 +03:00
|
|
|
mJAREntry(nsnull),
|
2000-04-26 18:31:01 +04:00
|
|
|
mStatus(NS_OK),
|
|
|
|
mMonitor(nsnull)
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
2000-03-30 11:39:31 +04:00
|
|
|
|
|
|
|
#if defined(PR_LOGGING)
|
|
|
|
//
|
|
|
|
// Initialize the global PRLogModule for socket transport logging
|
|
|
|
// if necessary...
|
|
|
|
//
|
|
|
|
if (nsnull == gJarProtocolLog) {
|
|
|
|
gJarProtocolLog = PR_NewLogModule("nsJarProtocol");
|
|
|
|
}
|
|
|
|
#endif /* PR_LOGGING */
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsJARChannel::~nsJARChannel()
|
|
|
|
{
|
|
|
|
if (mContentType)
|
|
|
|
nsCRT::free(mContentType);
|
|
|
|
if (mJAREntry)
|
|
|
|
nsCRT::free(mJAREntry);
|
2000-02-01 02:43:09 +03:00
|
|
|
if (mMonitor)
|
|
|
|
PR_DestroyMonitor(mMonitor);
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
2000-09-22 10:21:18 +04:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS7(nsJARChannel,
|
2000-04-12 11:58:24 +04:00
|
|
|
nsIJARChannel,
|
|
|
|
nsIChannel,
|
|
|
|
nsIRequest,
|
2001-04-10 10:01:08 +04:00
|
|
|
nsIRequestObserver,
|
2000-04-12 11:58:24 +04:00
|
|
|
nsIStreamListener,
|
2000-09-22 10:21:18 +04:00
|
|
|
nsIStreamIO,
|
|
|
|
nsIDownloadObserver)
|
1999-11-08 00:55:12 +03:00
|
|
|
|
|
|
|
NS_METHOD
|
|
|
|
nsJARChannel::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
|
|
|
{
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
nsresult rv;
|
1999-11-08 00:55:12 +03:00
|
|
|
|
|
|
|
if (aOuter)
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
|
|
|
nsJARChannel* jarChannel = new nsJARChannel();
|
|
|
|
if (jarChannel == nsnull)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF(jarChannel);
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
rv = jarChannel->QueryInterface(aIID, aResult);
|
1999-11-08 00:55:12 +03:00
|
|
|
NS_RELEASE(jarChannel);
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
return rv;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-03-29 07:58:50 +04:00
|
|
|
nsJARChannel::Init(nsIJARProtocolHandler* aHandler, nsIURI* uri)
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
mURI = do_QueryInterface(uri, &rv);
|
1999-11-17 11:14:52 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2000-02-01 02:43:09 +03:00
|
|
|
mMonitor = PR_NewMonitor();
|
|
|
|
if (mMonitor == nsnull)
|
2000-01-24 06:54:20 +03:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2000-05-25 12:32:09 +04:00
|
|
|
mJARProtocolHandler = aHandler;
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
return NS_OK;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIRequest methods
|
|
|
|
|
2000-08-21 12:23:54 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetName(PRUnichar* *result)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsXPIDLCString urlStr;
|
|
|
|
rv = mURI->GetSpec(getter_Copies(urlStr));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
nsString name;
|
|
|
|
name.AppendWithConversion(urlStr);
|
|
|
|
*result = name.ToNewUnicode();
|
|
|
|
return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::IsPending(PRBool* result)
|
|
|
|
{
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
NS_NOTREACHED("nsJARChannel::IsPending");
|
2000-03-29 07:58:50 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-03-29 07:58:50 +04:00
|
|
|
nsJARChannel::GetStatus(nsresult *status)
|
|
|
|
{
|
|
|
|
*status = mStatus;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::Cancel(nsresult status)
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
2000-04-12 11:58:24 +04:00
|
|
|
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
2000-11-16 01:21:46 +03:00
|
|
|
nsresult rv = NS_OK;
|
2000-02-01 02:43:09 +03:00
|
|
|
nsAutoMonitor monitor(mMonitor);
|
2000-01-24 06:54:20 +03:00
|
|
|
|
|
|
|
if (mJarExtractionTransport) {
|
2000-03-29 07:58:50 +04:00
|
|
|
rv = mJarExtractionTransport->Cancel(status);
|
2000-01-24 06:54:20 +03:00
|
|
|
mJarExtractionTransport = nsnull;
|
|
|
|
}
|
2001-02-21 23:38:08 +03:00
|
|
|
|
2000-03-29 07:58:50 +04:00
|
|
|
mStatus = status;
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
return rv;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::Suspend()
|
|
|
|
{
|
2001-02-21 23:38:08 +03:00
|
|
|
nsresult rv = NS_OK;
|
2000-02-01 02:43:09 +03:00
|
|
|
nsAutoMonitor monitor(mMonitor);
|
2000-01-24 06:54:20 +03:00
|
|
|
|
|
|
|
if (mJarExtractionTransport) {
|
|
|
|
rv = mJarExtractionTransport->Suspend();
|
|
|
|
}
|
|
|
|
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
return rv;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::Resume()
|
|
|
|
{
|
2001-02-21 23:38:08 +03:00
|
|
|
nsresult rv = NS_OK;
|
2000-02-01 02:43:09 +03:00
|
|
|
nsAutoMonitor monitor(mMonitor);
|
2000-01-24 06:54:20 +03:00
|
|
|
|
|
|
|
if (mJarExtractionTransport) {
|
|
|
|
rv = mJarExtractionTransport->Resume();
|
|
|
|
}
|
|
|
|
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
return rv;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIChannel methods
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetOriginalURI(nsIURI* *aOriginalURI)
|
|
|
|
{
|
2000-09-22 10:21:18 +04:00
|
|
|
if (mOriginalURI)
|
|
|
|
*aOriginalURI = mOriginalURI;
|
|
|
|
else
|
|
|
|
*aOriginalURI = NS_STATIC_CAST(nsIURI*, mURI);
|
|
|
|
|
|
|
|
NS_IF_ADDREF(*aOriginalURI);
|
1999-11-08 00:55:12 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-29 07:58:50 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::SetOriginalURI(nsIURI* aOriginalURI)
|
|
|
|
{
|
|
|
|
mOriginalURI = aOriginalURI;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetURI(nsIURI* *aURI)
|
|
|
|
{
|
|
|
|
*aURI = mURI;
|
|
|
|
NS_ADDREF(*aURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-09-22 10:21:18 +04:00
|
|
|
nsresult
|
|
|
|
nsJARChannel::OpenJARElement()
|
2000-03-30 11:39:31 +04:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-09-22 10:21:18 +04:00
|
|
|
nsAutoCMonitor mon(this);
|
|
|
|
rv = Open(nsnull, nsnull);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
rv = GetInputStream(getter_AddRefs(mSynchronousInputStream));
|
2001-02-21 23:38:08 +03:00
|
|
|
mon.Notify(); // wake up nsIChannel::Open
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
return rv;
|
2000-03-30 11:39:31 +04:00
|
|
|
}
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsJARChannel::Open(nsIInputStream* *result)
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
2000-03-30 11:39:31 +04:00
|
|
|
nsAutoCMonitor mon(this);
|
|
|
|
nsresult rv;
|
2000-09-22 10:21:18 +04:00
|
|
|
mSynchronousRead = PR_TRUE;
|
|
|
|
rv = EnsureJARFileAvailable();
|
2000-03-30 11:39:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-09-22 10:21:18 +04:00
|
|
|
if (mSynchronousInputStream == nsnull)
|
2000-09-18 06:18:00 +04:00
|
|
|
mon.Wait();
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
if (!mSynchronousInputStream)
|
2000-09-22 10:21:18 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
|
|
|
|
*result = mSynchronousInputStream; // Result of GetInputStream called on transport thread
|
|
|
|
NS_ADDREF(*result);
|
|
|
|
mSynchronousInputStream = 0;
|
|
|
|
return NS_OK;
|
2000-03-29 07:58:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsJARChannel::AsyncOpen(nsIStreamListener* listener, nsISupports* ctxt)
|
2000-03-30 11:39:31 +04:00
|
|
|
{
|
2000-08-25 02:35:46 +04:00
|
|
|
nsresult rv;
|
2001-09-15 01:19:41 +04:00
|
|
|
|
2000-03-30 11:39:31 +04:00
|
|
|
mUserContext = ctxt;
|
|
|
|
mUserListener = listener;
|
2001-09-15 01:19:41 +04:00
|
|
|
mSynchronousRead = PR_FALSE;
|
2000-08-25 02:35:46 +04:00
|
|
|
|
|
|
|
if (mLoadGroup) {
|
2001-02-21 23:38:08 +03:00
|
|
|
rv = mLoadGroup->AddRequest(this, nsnull);
|
2000-08-25 02:35:46 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
|
|
|
|
2001-09-15 01:19:41 +04:00
|
|
|
rv = EnsureJARFileAvailable();
|
|
|
|
if (NS_FAILED(rv) && mLoadGroup)
|
|
|
|
mLoadGroup->RemoveRequest(this, nsnull, rv);
|
|
|
|
return rv;
|
2000-03-30 11:39:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-09-22 10:21:18 +04:00
|
|
|
nsJARChannel::EnsureJARFileAvailable()
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-03-30 11:39:31 +04:00
|
|
|
|
|
|
|
#ifdef PR_LOGGING
|
2001-09-15 01:19:41 +04:00
|
|
|
if (PR_LOG_TEST(gJarProtocolLog, PR_LOG_DEBUG)) {
|
|
|
|
nsXPIDLCString jarURLStr;
|
|
|
|
mURI->GetSpec(getter_Copies(jarURLStr));
|
|
|
|
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
|
|
|
("nsJarProtocol: EnsureJARFileAvailable %s", (const char*)jarURLStr));
|
|
|
|
}
|
2000-03-30 11:39:31 +04:00
|
|
|
#endif
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
rv = mURI->GetJARFile(getter_AddRefs(mJARBaseURI));
|
2001-09-15 01:19:41 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-11-08 00:55:12 +03:00
|
|
|
|
|
|
|
rv = mURI->GetJAREntry(&mJAREntry);
|
2001-09-15 01:19:41 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2001-09-10 04:42:50 +04:00
|
|
|
|
2001-09-15 01:19:41 +04:00
|
|
|
// try to get a nsIFile directly from the url, which will often succeed.
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mJARBaseURI);
|
|
|
|
if (fileURL)
|
|
|
|
fileURL->GetFile(getter_AddRefs(mDownloadedJARFile));
|
|
|
|
}
|
2000-09-21 12:26:07 +04:00
|
|
|
|
2001-09-15 01:19:41 +04:00
|
|
|
if (mDownloadedJARFile) {
|
|
|
|
// after successfully downloading the jar file to the cache,
|
|
|
|
// start the extraction process:
|
|
|
|
if (mSynchronousRead)
|
|
|
|
rv = OpenJARElement();
|
|
|
|
else
|
|
|
|
rv = AsyncReadJARElement();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rv = NS_NewDownloader(getter_AddRefs(mDownloader),
|
|
|
|
mJARBaseURI, this, nsnull, mSynchronousRead,
|
|
|
|
mLoadGroup, mCallbacks, mLoadFlags);
|
|
|
|
|
|
|
|
// if DownloadComplete() was called early, need to release the reference.
|
|
|
|
if (mSynchronousRead && mSynchronousInputStream)
|
|
|
|
mDownloader = 0;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-03-30 11:39:31 +04:00
|
|
|
nsJARChannel::AsyncReadJARElement()
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2000-02-01 02:43:09 +03:00
|
|
|
nsAutoMonitor monitor(mMonitor);
|
2000-01-24 06:54:20 +03:00
|
|
|
|
2001-07-25 11:54:28 +04:00
|
|
|
nsCOMPtr<nsIFileTransportService> fts =
|
|
|
|
do_GetService(kFileTransportServiceCID, &rv);
|
1999-11-08 00:55:12 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
nsCOMPtr<nsITransport> jarTransport;
|
|
|
|
rv = fts->CreateTransportFromStreamIO(this, getter_AddRefs(jarTransport));
|
2000-04-12 11:58:24 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-11-17 11:14:52 +03:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
if (mCallbacks) {
|
|
|
|
nsCOMPtr<nsIProgressEventSink> sink = do_GetInterface(mCallbacks);
|
|
|
|
if (sink) {
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
// XXX don't think that this is needed anymore
|
2001-02-21 23:38:08 +03:00
|
|
|
// jarTransport->SetProgressEventSink(sink);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-30 11:39:31 +04:00
|
|
|
#ifdef PR_LOGGING
|
2001-09-15 01:19:41 +04:00
|
|
|
if (PR_LOG_TEST(gJarProtocolLog, PR_LOG_DEBUG)) {
|
|
|
|
nsXPIDLCString jarURLStr;
|
|
|
|
mURI->GetSpec(getter_Copies(jarURLStr));
|
|
|
|
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
|
|
|
("nsJarProtocol: AsyncRead jar entry %s", (const char*)jarURLStr));
|
|
|
|
}
|
2000-03-30 11:39:31 +04:00
|
|
|
#endif
|
2000-04-12 11:58:24 +04:00
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
rv = jarTransport->AsyncRead(this, nsnull, 0, PRUint32(-1), 0,
|
|
|
|
getter_AddRefs(mJarExtractionTransport));
|
2001-02-21 23:38:08 +03:00
|
|
|
mJarExtractionTransport = 0;
|
|
|
|
jarTransport = 0;
|
1999-11-08 00:55:12 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-04-10 10:01:08 +04:00
|
|
|
nsJARChannel::GetLoadFlags(PRUint32* aLoadFlags)
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
*aLoadFlags = mLoadFlags;
|
1999-11-08 00:55:12 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-04-10 10:01:08 +04:00
|
|
|
nsJARChannel::SetLoadFlags(PRUint32 aLoadFlags)
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
mLoadFlags = aLoadFlags;
|
1999-11-08 00:55:12 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetContentType(char* *aContentType)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (mContentType == nsnull) {
|
2000-09-07 23:31:10 +04:00
|
|
|
if (!mJAREntry)
|
2000-09-08 08:39:17 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
char* fileName = nsCRT::strdup(mJAREntry);
|
1999-11-08 00:55:12 +03:00
|
|
|
if (fileName != nsnull) {
|
|
|
|
PRInt32 len = nsCRT::strlen(fileName);
|
|
|
|
const char* ext = nsnull;
|
2000-09-08 13:36:35 +04:00
|
|
|
for (PRInt32 i = len-1; i >= 0; i--) {
|
1999-11-08 00:55:12 +03:00
|
|
|
if (fileName[i] == '.') {
|
|
|
|
ext = &fileName[i + 1];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ext) {
|
2000-09-14 03:57:52 +04:00
|
|
|
nsCOMPtr<nsIMIMEService> mimeServ (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
|
1999-11-08 00:55:12 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = mimeServ->GetTypeFromExtension(ext, &mContentType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2000-09-08 08:39:17 +04:00
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
|
2000-09-08 13:36:35 +04:00
|
|
|
nsCRT::free(fileName);
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
else {
|
2000-09-12 09:11:11 +04:00
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
2000-02-09 08:04:52 +03:00
|
|
|
mContentType = nsCRT::strdup(UNKNOWN_CONTENT_TYPE);
|
1999-11-08 00:55:12 +03:00
|
|
|
if (mContentType == nsnull)
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
else
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
*aContentType = nsCRT::strdup(mContentType);
|
|
|
|
if (*aContentType == nsnull)
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-01-08 09:26:04 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::SetContentType(const char *aContentType)
|
|
|
|
{
|
|
|
|
if (mContentType) {
|
|
|
|
nsCRT::free(mContentType);
|
|
|
|
}
|
|
|
|
|
|
|
|
mContentType = nsCRT::strdup(aContentType);
|
|
|
|
if (!mContentType) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetContentLength(PRInt32* aContentLength)
|
|
|
|
{
|
|
|
|
if (mContentLength == -1)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
*aContentLength = mContentLength;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-29 07:58:50 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::SetContentLength(PRInt32 aContentLength)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("nsJARChannel::SetContentLength");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
|
|
|
{
|
|
|
|
*aLoadGroup = mLoadGroup;
|
|
|
|
NS_IF_ADDREF(*aLoadGroup);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-17 11:14:52 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
|
|
|
{
|
|
|
|
mLoadGroup = aLoadGroup;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetOwner(nsISupports* *aOwner)
|
|
|
|
{
|
2000-08-23 07:17:42 +04:00
|
|
|
nsresult rv;
|
|
|
|
if (mOwner == nsnull) {
|
|
|
|
//-- Verify signature, if one is present, and set owner accordingly
|
2000-08-24 11:36:53 +04:00
|
|
|
rv = EnsureZipReader();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2001-02-23 03:15:04 +03:00
|
|
|
nsCOMPtr<nsIJAR> jar = do_QueryInterface(mJAR, &rv);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Zip reader is not an nsIJAR");
|
2000-08-23 07:17:42 +04:00
|
|
|
nsCOMPtr<nsIPrincipal> certificate;
|
2001-02-23 03:15:04 +03:00
|
|
|
rv = jar->GetCertificatePrincipal(mJAREntry,
|
2000-08-23 07:17:42 +04:00
|
|
|
getter_AddRefs(certificate));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
if (certificate)
|
|
|
|
{ // Get the codebase principal
|
2001-07-25 11:54:28 +04:00
|
|
|
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
|
|
|
do_GetService(kScriptSecurityManagerCID, &rv);
|
2000-08-23 07:17:42 +04:00
|
|
|
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
|
|
|
nsCOMPtr<nsIPrincipal> codebase;
|
|
|
|
rv = secMan->GetCodebasePrincipal(mJARBaseURI,
|
|
|
|
getter_AddRefs(codebase));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// Join the certificate and the codebase
|
|
|
|
nsCOMPtr<nsIAggregatePrincipal> agg;
|
|
|
|
agg = do_QueryInterface(certificate, &rv);
|
|
|
|
rv = agg->SetCodebase(codebase);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
mOwner = do_QueryInterface(agg, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
|
|
|
}
|
2000-03-21 07:17:37 +03:00
|
|
|
*aOwner = mOwner;
|
|
|
|
NS_IF_ADDREF(*aOwner);
|
1999-11-08 00:55:12 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::SetOwner(nsISupports* aOwner)
|
|
|
|
{
|
2000-03-21 07:17:37 +03:00
|
|
|
mOwner = aOwner;
|
|
|
|
return NS_OK;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
1999-11-17 11:14:52 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-18 10:36:41 +03:00
|
|
|
nsJARChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
|
1999-11-17 11:14:52 +03:00
|
|
|
{
|
|
|
|
*aNotificationCallbacks = mCallbacks.get();
|
|
|
|
NS_IF_ADDREF(*aNotificationCallbacks);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-18 10:36:41 +03:00
|
|
|
nsJARChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
1999-11-17 11:14:52 +03:00
|
|
|
{
|
|
|
|
mCallbacks = aNotificationCallbacks;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-18 01:06:32 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
|
|
|
|
{
|
|
|
|
*aSecurityInfo = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-08-24 11:36:53 +04:00
|
|
|
|
2000-09-22 10:21:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIDownloadObserver methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosure,
|
|
|
|
nsresult aStatus, nsIFile* aFile)
|
|
|
|
{
|
|
|
|
nsresult rv=aStatus;
|
|
|
|
if(NS_SUCCEEDED(aStatus)) {
|
|
|
|
NS_ASSERTION(!mDownloader ||(aDownloader == mDownloader.get()), "wrong downloader");
|
|
|
|
mDownloadedJARFile = aFile;
|
|
|
|
// after successfully downloading the jar file to the cache,
|
|
|
|
// start the extraction process:
|
|
|
|
if (mSynchronousRead)
|
|
|
|
rv = OpenJARElement();
|
|
|
|
else
|
|
|
|
rv = AsyncReadJARElement();
|
|
|
|
}
|
2001-02-21 23:38:08 +03:00
|
|
|
mDownloader = 0;
|
2000-09-22 10:21:18 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-04-10 10:01:08 +04:00
|
|
|
// nsIRequestObserver methods:
|
1999-11-08 00:55:12 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsJARChannel::OnStartRequest(nsIRequest* jarExtractionTransport,
|
1999-11-08 00:55:12 +03:00
|
|
|
nsISupports* context)
|
|
|
|
{
|
|
|
|
return mUserListener->OnStartRequest(this, mUserContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* context,
|
2001-04-10 10:01:08 +04:00
|
|
|
nsresult aStatus)
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
2000-01-24 06:54:20 +03:00
|
|
|
nsresult rv;
|
2000-03-30 11:39:31 +04:00
|
|
|
#ifdef PR_LOGGING
|
2001-09-15 01:19:41 +04:00
|
|
|
if (PR_LOG_TEST(gJarProtocolLog, PR_LOG_DEBUG)) {
|
|
|
|
nsCOMPtr<nsIURI> jarURI;
|
|
|
|
nsXPIDLCString jarURLStr;
|
|
|
|
rv = mURI->GetSpec(getter_Copies(jarURLStr));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
|
|
|
("nsJarProtocol: jar extraction complete %s status=%x",
|
|
|
|
(const char*)jarURLStr, aStatus));
|
|
|
|
}
|
2000-03-30 11:39:31 +04:00
|
|
|
}
|
|
|
|
#endif
|
2000-09-08 04:24:13 +04:00
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
rv = mUserListener->OnStopRequest(this, mUserContext, aStatus);
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "OnStopRequest failed");
|
2000-03-30 11:39:31 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
if (mLoadGroup)
|
2001-04-10 10:01:08 +04:00
|
|
|
mLoadGroup->RemoveRequest(this, context, aStatus);
|
2000-03-30 11:39:31 +04:00
|
|
|
|
|
|
|
mUserListener = nsnull;
|
|
|
|
mUserContext = nsnull;
|
2000-01-24 06:54:20 +03:00
|
|
|
mJarExtractionTransport = nsnull;
|
|
|
|
return rv;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIStreamListener methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsJARChannel::OnDataAvailable(nsIRequest* jarCacheTransport,
|
1999-11-08 00:55:12 +03:00
|
|
|
nsISupports* context,
|
|
|
|
nsIInputStream *inStr,
|
|
|
|
PRUint32 sourceOffset,
|
|
|
|
PRUint32 count)
|
|
|
|
{
|
|
|
|
return mUserListener->OnDataAvailable(this, mUserContext,
|
|
|
|
inStr, sourceOffset, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2000-04-13 13:20:50 +04:00
|
|
|
// nsIStreamIO methods:
|
1999-11-08 00:55:12 +03:00
|
|
|
|
2000-08-24 11:36:53 +04:00
|
|
|
nsresult
|
|
|
|
nsJARChannel::EnsureZipReader()
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
2000-08-24 11:36:53 +04:00
|
|
|
if (mJAR == nsnull) {
|
|
|
|
nsresult rv;
|
2000-09-22 10:21:18 +04:00
|
|
|
if (mDownloadedJARFile == nsnull)
|
2000-08-24 11:36:53 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2000-03-30 11:39:31 +04:00
|
|
|
|
2000-08-24 11:36:53 +04:00
|
|
|
nsCOMPtr<nsIZipReaderCache> jarCache;
|
|
|
|
rv = mJARProtocolHandler->GetJARCache(getter_AddRefs(jarCache));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2000-09-22 10:21:18 +04:00
|
|
|
rv = jarCache->GetZip(mDownloadedJARFile, getter_AddRefs(mJAR));
|
2000-08-24 11:36:53 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::Open(char* *contentType, PRInt32 *contentLength)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
rv = EnsureZipReader();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-11-12 09:13:13 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIZipEntry> entry;
|
2000-08-24 11:36:53 +04:00
|
|
|
rv = mJAR->GetEntry(mJAREntry, getter_AddRefs(entry));
|
1999-11-12 09:13:13 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-11-08 00:55:12 +03:00
|
|
|
|
2000-03-30 11:39:31 +04:00
|
|
|
if (contentLength) {
|
|
|
|
rv = entry->GetRealSize((PRUint32*)contentLength);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
1999-11-08 00:55:12 +03:00
|
|
|
|
2000-03-30 11:39:31 +04:00
|
|
|
if (contentType) {
|
|
|
|
rv = GetContentType(contentType);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
|
|
|
return rv;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::Close(nsresult status)
|
|
|
|
{
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
return NS_OK;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetInputStream(nsIInputStream* *aInputStream)
|
|
|
|
{
|
2000-03-30 11:39:31 +04:00
|
|
|
#ifdef PR_LOGGING
|
2001-09-15 01:19:41 +04:00
|
|
|
if (PR_LOG_TEST(gJarProtocolLog, PR_LOG_DEBUG)) {
|
|
|
|
nsXPIDLCString jarURLStr;
|
|
|
|
mURI->GetSpec(getter_Copies(jarURLStr));
|
|
|
|
PR_LOG(gJarProtocolLog, PR_LOG_DEBUG,
|
|
|
|
("nsJarProtocol: GetInputStream jar entry %s", (const char*)jarURLStr));
|
|
|
|
}
|
2000-03-30 11:39:31 +04:00
|
|
|
#endif
|
2000-07-12 07:10:33 +04:00
|
|
|
NS_ENSURE_TRUE(mJAR, NS_ERROR_NULL_POINTER);
|
|
|
|
return mJAR->GetInputStream(mJAREntry, aInputStream);
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetOutputStream(nsIOutputStream* *aOutputStream)
|
|
|
|
{
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
NS_NOTREACHED("nsJARChannel::GetOutputStream");
|
2000-03-29 07:58:50 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
2000-04-13 13:20:50 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::GetName(char* *aName)
|
|
|
|
{
|
|
|
|
return mURI->GetSpec(aName);
|
|
|
|
}
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIJARChannel methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARChannel::EnumerateEntries(const char *aRoot, nsISimpleEnumerator **_retval)
|
|
|
|
{
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-22 00:51:34 +04:00
|
|
|
NS_NOTREACHED("nsJARChannel::EnumerateEntries");
|
2000-03-29 07:58:50 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|