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,2000
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
#ifndef nsJARChannel_h__
|
|
|
|
#define nsJARChannel_h__
|
1999-09-17 20:12:41 +04:00
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
#include "nsIJARChannel.h"
|
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIJARProtocolHandler.h"
|
1999-11-12 09:13:13 +03:00
|
|
|
#include "nsIJARURI.h"
|
2000-04-13 13:20:50 +04:00
|
|
|
#include "nsIStreamIO.h"
|
2000-01-25 00:28:28 +03:00
|
|
|
#include "nsIChannel.h"
|
1999-11-12 09:13:13 +03:00
|
|
|
#include "nsIZipReader.h"
|
2000-01-25 00:28:28 +03:00
|
|
|
#include "nsIChannel.h"
|
1999-11-24 10:40:54 +03:00
|
|
|
#include "nsILoadGroup.h"
|
1999-11-24 11:31:06 +03:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-06 01:28:38 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
1999-11-08 00:55:12 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2000-01-25 00:28:28 +03:00
|
|
|
#include "nsIFile.h"
|
2000-02-01 03:35:46 +03:00
|
|
|
#include "prmon.h"
|
2000-09-22 10:21:18 +04:00
|
|
|
#include "nsIDownloader.h"
|
|
|
|
#include "nsIInputStream.h"
|
2001-11-30 01:29:00 +03:00
|
|
|
#include "nsJARProtocolHandler.h"
|
1999-09-17 20:12:41 +04:00
|
|
|
|
2001-09-19 03:07:57 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
#include "prthread.h"
|
|
|
|
#endif
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
class nsIFileChannel;
|
2000-03-30 11:39:31 +04:00
|
|
|
class nsJARChannel;
|
1999-09-17 20:12:41 +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
|
|
|
#define NS_JARCHANNEL_CID \
|
1999-11-08 00:55:12 +03:00
|
|
|
{ /* 0xc7e410d5-0x85f2-11d3-9f63-006008a6efe9 */ \
|
|
|
|
0xc7e410d5, \
|
|
|
|
0x85f2, \
|
|
|
|
0x11d3, \
|
|
|
|
{0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \
|
|
|
|
}
|
|
|
|
|
|
|
|
class nsJARChannel : public nsIJARChannel,
|
|
|
|
public nsIStreamListener,
|
2000-09-22 10:21:18 +04:00
|
|
|
public nsIStreamIO,
|
|
|
|
public nsIDownloadObserver
|
1999-11-08 00:55:12 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIREQUEST
|
|
|
|
NS_DECL_NSICHANNEL
|
1999-09-17 20:12:41 +04:00
|
|
|
NS_DECL_NSIJARCHANNEL
|
2001-04-10 10:01:08 +04:00
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
1999-11-08 00:55:12 +03:00
|
|
|
NS_DECL_NSISTREAMLISTENER
|
2000-04-13 13:20:50 +04:00
|
|
|
NS_DECL_NSISTREAMIO
|
2000-09-22 10:21:18 +04:00
|
|
|
NS_DECL_NSIDOWNLOADOBSERVER
|
1999-09-17 20:12:41 +04:00
|
|
|
|
|
|
|
nsJARChannel();
|
|
|
|
virtual ~nsJARChannel();
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
// Define a Create method to be used with a factory:
|
|
|
|
static NS_METHOD
|
|
|
|
Create(nsISupports* aOuter, REFNSIID aIID, void **aResult);
|
|
|
|
|
2001-11-30 01:29:00 +03:00
|
|
|
nsresult Init(nsJARProtocolHandler* aHandler, nsIURI* uri);
|
2000-09-22 10:21:18 +04:00
|
|
|
nsresult EnsureJARFileAvailable();
|
|
|
|
nsresult OpenJARElement();
|
2000-03-30 11:39:31 +04:00
|
|
|
nsresult AsyncReadJARElement();
|
2000-08-24 11:36:53 +04:00
|
|
|
nsresult EnsureZipReader();
|
1999-11-08 00:55:12 +03:00
|
|
|
|
1999-12-04 13:01:32 +03:00
|
|
|
friend class nsJARDownloadObserver;
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
protected:
|
2001-11-30 01:29:00 +03:00
|
|
|
nsCOMPtr<nsJARProtocolHandler> mJARProtocolHandler;
|
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
|
|
|
nsCOMPtr<nsIJARURI> mURI;
|
|
|
|
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
|
|
|
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
|
|
|
nsCOMPtr<nsIURI> mOriginalURI;
|
2001-04-10 10:01:08 +04:00
|
|
|
nsLoadFlags mLoadFlags;
|
2000-03-21 07:17:37 +03:00
|
|
|
nsCOMPtr<nsISupports> mOwner;
|
1999-11-08 00:55:12 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mUserContext;
|
|
|
|
nsCOMPtr<nsIStreamListener> mUserListener;
|
|
|
|
|
|
|
|
char* mContentType;
|
|
|
|
PRInt32 mContentLength;
|
|
|
|
nsCOMPtr<nsIURI> mJARBaseURI;
|
|
|
|
char* mJAREntry;
|
1999-11-12 09:13:13 +03:00
|
|
|
nsCOMPtr<nsIZipReader> mJAR;
|
2000-09-22 10:21:18 +04:00
|
|
|
nsCOMPtr<nsIFile> mDownloadedJARFile;
|
2000-03-29 07:58:50 +04:00
|
|
|
nsresult mStatus;
|
2000-09-22 10:21:18 +04:00
|
|
|
PRBool mSynchronousRead;
|
|
|
|
nsCOMPtr<nsIInputStream> mSynchronousInputStream;
|
2000-01-24 06:54:20 +03:00
|
|
|
|
2000-09-22 10:21:18 +04:00
|
|
|
nsCOMPtr<nsIDownloader> mDownloader;
|
2001-02-21 23:38:08 +03:00
|
|
|
nsCOMPtr<nsIRequest> mJarExtractionTransport;
|
2001-09-19 03:07:57 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
PRThread* mInitiator;
|
|
|
|
#endif
|
1999-09-17 20:12:41 +04:00
|
|
|
};
|
|
|
|
|
1999-11-08 00:55:12 +03:00
|
|
|
#endif // nsJARChannel_h__
|