2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1999-09-17 20:12:41 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1999-09-17 20:12:41 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-09-17 20:12:41 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
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
|
|
|
* Contributor(s):
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-09-17 20:12:41 +04:00
|
|
|
|
|
|
|
#include "nsJARProtocolHandler.h"
|
|
|
|
#include "nsIIOService.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsIServiceManager.h"
|
1999-11-08 00:55:12 +03:00
|
|
|
#include "nsJARURI.h"
|
|
|
|
#include "nsIURL.h"
|
|
|
|
#include "nsJARChannel.h"
|
2000-05-06 03:39:25 +04:00
|
|
|
#include "nsXPIDLString.h"
|
2002-03-06 10:48:55 +03:00
|
|
|
#include "nsString.h"
|
2001-04-10 10:01:08 +04:00
|
|
|
#include "nsNetCID.h"
|
2001-11-30 01:29:00 +03:00
|
|
|
#include "nsCExternalHandlerService.h"
|
|
|
|
#include "nsIMIMEService.h"
|
|
|
|
#include "nsMimeTypes.h"
|
1999-09-17 20:12:41 +04:00
|
|
|
|
2000-05-25 12:32:09 +04:00
|
|
|
static NS_DEFINE_CID(kZipReaderCacheCID, NS_ZIPREADERCACHE_CID);
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
#define NS_JAR_CACHE_SIZE 32
|
1999-09-17 20:12:41 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsJARProtocolHandler *gJarHandler = nsnull;
|
1999-09-17 20:12:41 +04:00
|
|
|
|
|
|
|
nsJARProtocolHandler::nsJARProtocolHandler()
|
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
gJarHandler = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsJARProtocolHandler::~nsJARProtocolHandler()
|
|
|
|
{
|
|
|
|
gJarHandler = nsnull;
|
1999-09-17 20:12:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsJARProtocolHandler::Init()
|
|
|
|
{
|
2000-05-25 12:32:09 +04: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
|
|
|
rv = nsComponentManager::CreateInstance(kZipReaderCacheCID,
|
2000-05-25 12:32:09 +04:00
|
|
|
nsnull,
|
|
|
|
NS_GET_IID(nsIZipReaderCache),
|
|
|
|
getter_AddRefs(mJARCache));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = mJARCache->Init(NS_JAR_CACHE_SIZE);
|
|
|
|
return rv;
|
1999-09-17 20:12:41 +04:00
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsIMIMEService *
|
|
|
|
nsJARProtocolHandler::MimeService()
|
2001-11-30 01:29:00 +03:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
if (!mMimeService)
|
2001-11-30 01:29:00 +03:00
|
|
|
mMimeService = do_GetService(NS_MIMESERVICE_CONTRACTID);
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
return mMimeService.get();
|
1999-09-17 20:12:41 +04:00
|
|
|
}
|
|
|
|
|
2001-12-20 06:46:21 +03:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS3(nsJARProtocolHandler,
|
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
|
|
|
nsIJARProtocolHandler,
|
2001-12-20 06:46:21 +03:00
|
|
|
nsIProtocolHandler,
|
|
|
|
nsISupportsWeakReference)
|
1999-09-17 20:12:41 +04:00
|
|
|
|
|
|
|
NS_METHOD
|
|
|
|
nsJARProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
|
|
|
{
|
|
|
|
if (aOuter)
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
|
|
|
nsJARProtocolHandler* ph = new nsJARProtocolHandler();
|
|
|
|
if (ph == nsnull)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
NS_ADDREF(ph);
|
|
|
|
nsresult rv = ph->Init();
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = ph->QueryInterface(aIID, aResult);
|
|
|
|
}
|
|
|
|
NS_RELEASE(ph);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-05-25 12:32:09 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARProtocolHandler::GetJARCache(nsIZipReaderCache* *result)
|
|
|
|
{
|
|
|
|
*result = mJARCache;
|
|
|
|
NS_ADDREF(*result);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-17 20:12:41 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIProtocolHandler methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 10:48:55 +03:00
|
|
|
nsJARProtocolHandler::GetScheme(nsACString &result)
|
1999-09-17 20:12:41 +04:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
result = NS_LITERAL_CSTRING("jar");
|
1999-09-17 20:12:41 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARProtocolHandler::GetDefaultPort(PRInt32 *result)
|
|
|
|
{
|
|
|
|
*result = -1; // no port for JAR: URLs
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-08-08 00:42:57 +04:00
|
|
|
NS_IMETHODIMP
|
2001-09-13 06:21:05 +04:00
|
|
|
nsJARProtocolHandler::GetProtocolFlags(PRUint32 *result)
|
2001-08-08 00:42:57 +04:00
|
|
|
{
|
|
|
|
*result = URI_NORELATIVE | URI_NOAUTH;
|
|
|
|
/* Although jar uris have their own concept of relative urls
|
|
|
|
it is very different from the standard behaviour, so we
|
|
|
|
have to say norelative here! */
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-17 20:12:41 +04:00
|
|
|
NS_IMETHODIMP
|
2002-03-06 10:48:55 +03:00
|
|
|
nsJARProtocolHandler::NewURI(const nsACString &aSpec,
|
|
|
|
const char *aCharset,
|
|
|
|
nsIURI *aBaseURI,
|
1999-11-08 00:55:12 +03:00
|
|
|
nsIURI **result)
|
1999-09-17 20:12:41 +04:00
|
|
|
{
|
2000-05-06 03:39:25 +04:00
|
|
|
nsresult rv = NS_OK;
|
1999-11-08 00:55:12 +03:00
|
|
|
nsIURI* url;
|
2000-05-06 03:39:25 +04:00
|
|
|
|
2002-03-06 10:48:55 +03:00
|
|
|
nsJARURI *jarURI = new nsJARURI();
|
|
|
|
if (!jarURI)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF(url = jarURI);
|
|
|
|
|
|
|
|
rv = jarURI->Init(aCharset);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_RELEASE(url);
|
|
|
|
return rv;
|
|
|
|
}
|
2000-05-06 03:39:25 +04:00
|
|
|
|
2002-03-06 10:48:55 +03:00
|
|
|
if (aBaseURI) {
|
|
|
|
nsCAutoString aResolvedURI;
|
|
|
|
rv = aBaseURI->Resolve(aSpec, aResolvedURI);
|
1999-11-08 00:55:12 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-05-06 03:39:25 +04:00
|
|
|
rv = url->SetSpec(aResolvedURI);
|
1999-11-08 00:55:12 +03:00
|
|
|
}
|
2002-03-06 10:48:55 +03:00
|
|
|
else
|
|
|
|
rv = url->SetSpec(aSpec);
|
1999-11-08 00:55:12 +03:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_RELEASE(url);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
*result = url;
|
|
|
|
return rv;
|
1999-09-17 20:12:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2003-01-18 05:15:14 +03:00
|
|
|
nsJARProtocolHandler::NewChannel(nsIURI *uri, nsIChannel **result)
|
1999-09-17 20:12:41 +04:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
nsJARChannel *chan = new nsJARChannel();
|
|
|
|
if (!chan)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
NS_ADDREF(chan);
|
1999-11-08 00:55:12 +03:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsresult rv = chan->Init(uri);
|
1999-11-08 00:55:12 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2003-01-18 05:15:14 +03:00
|
|
|
NS_RELEASE(chan);
|
1999-11-08 00:55:12 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
*result = chan;
|
1999-11-08 00:55:12 +03:00
|
|
|
return NS_OK;
|
1999-09-17 20:12:41 +04:00
|
|
|
}
|
|
|
|
|
2001-06-06 04:10:09 +04:00
|
|
|
|
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_IMETHODIMP
|
2001-06-06 04:10:09 +04:00
|
|
|
nsJARProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_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
|
|
|
// don't override anything.
|
2001-06-06 04:10:09 +04:00
|
|
|
*_retval = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-17 20:12:41 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|