2018-11-30 19:52:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-09-17 16:12:41 +00:00
|
|
|
|
1999-11-07 21:55:12 +00:00
|
|
|
#ifndef nsJARChannel_h__
|
|
|
|
#define nsJARChannel_h__
|
1999-09-17 16:12:41 +00:00
|
|
|
|
2015-03-11 00:00:01 +00:00
|
|
|
#include "mozilla/net/MemoryDownloader.h"
|
1999-11-07 21:55:12 +00:00
|
|
|
#include "nsIJARChannel.h"
|
1999-11-12 06:13:13 +00:00
|
|
|
#include "nsIJARURI.h"
|
2018-03-01 08:12:00 +00:00
|
|
|
#include "nsIEventTarget.h"
|
2003-01-18 02:15:14 +00:00
|
|
|
#include "nsIInputStreamPump.h"
|
1999-11-24 08:31:06 +00:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2003-01-18 02:15:14 +00:00
|
|
|
#include "nsIProgressEventSink.h"
|
|
|
|
#include "nsIStreamListener.h"
|
2003-06-23 22:58:28 +00:00
|
|
|
#include "nsIZipReader.h"
|
2003-01-18 02:15:14 +00:00
|
|
|
#include "nsILoadGroup.h"
|
2014-07-10 06:56:36 +00:00
|
|
|
#include "nsILoadInfo.h"
|
2014-06-17 16:39:23 +00:00
|
|
|
#include "nsIThreadRetargetableRequest.h"
|
|
|
|
#include "nsIThreadRetargetableStreamListener.h"
|
2009-02-19 20:25:18 +00:00
|
|
|
#include "nsHashPropertyBag.h"
|
2003-01-18 02:15:14 +00:00
|
|
|
#include "nsIFile.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2002-03-06 07:48:55 +00:00
|
|
|
#include "nsString.h"
|
2015-05-19 18:15:34 +00:00
|
|
|
#include "mozilla/Logging.h"
|
1999-09-17 16:12:41 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
class nsJARInputThunk;
|
2017-10-29 23:02:40 +00:00
|
|
|
class nsJARProtocolHandler;
|
2015-05-22 07:32:25 +00:00
|
|
|
class nsInputStreamPump;
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
1999-11-07 21:55:12 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsJARChannel final : public nsIJARChannel,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsIStreamListener,
|
|
|
|
public nsIThreadRetargetableRequest,
|
|
|
|
public nsIThreadRetargetableStreamListener,
|
|
|
|
public nsHashPropertyBag {
|
1999-11-07 21:55:12 +00:00
|
|
|
public:
|
2014-07-14 19:21:34 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
1999-11-07 21:55:12 +00:00
|
|
|
NS_DECL_NSIREQUEST
|
|
|
|
NS_DECL_NSICHANNEL
|
1999-09-17 16:12:41 +00:00
|
|
|
NS_DECL_NSIJARCHANNEL
|
2001-04-10 06:01:08 +00:00
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
1999-11-07 21:55:12 +00:00
|
|
|
NS_DECL_NSISTREAMLISTENER
|
2014-06-17 16:39:23 +00:00
|
|
|
NS_DECL_NSITHREADRETARGETABLEREQUEST
|
|
|
|
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
|
2018-11-30 10:46:48 +00:00
|
|
|
|
1999-09-17 16:12:41 +00:00
|
|
|
nsJARChannel();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
nsresult Init(nsIURI* uri);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
void SetFile(nsIFile* file);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
private:
|
2014-06-17 16:39:23 +00:00
|
|
|
virtual ~nsJARChannel();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
nsresult CreateJarInput(nsIZipReaderCache*, nsJARInputThunk**);
|
2018-03-01 08:12:00 +00:00
|
|
|
nsresult LookupFile();
|
2013-02-15 22:27:21 +00:00
|
|
|
nsresult OpenLocalFile();
|
2019-05-01 08:47:10 +00:00
|
|
|
nsresult ContinueOpenLocalFile(nsJARInputThunk* aInput, bool aIsSyncCall);
|
2018-03-01 08:12:00 +00:00
|
|
|
nsresult OnOpenLocalFileComplete(nsresult aResult, bool aIsSyncCall);
|
|
|
|
nsresult CheckPendingEvents();
|
2013-02-15 22:27:21 +00:00
|
|
|
void NotifyError(nsresult aError);
|
2014-06-17 16:39:23 +00:00
|
|
|
void FireOnProgress(uint64_t aProgress);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCString mSpec;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-08-27 23:34:30 +00:00
|
|
|
bool mOpened;
|
2019-12-19 05:20:07 +00:00
|
|
|
bool mCanceled;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2017-10-29 23:02:40 +00:00
|
|
|
RefPtr<nsJARProtocolHandler> mJarHandler;
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCOMPtr<nsIJARURI> mJarURI;
|
|
|
|
nsCOMPtr<nsIURI> mOriginalURI;
|
|
|
|
nsCOMPtr<nsISupports> mOwner;
|
2014-07-10 06:56:36 +00:00
|
|
|
nsCOMPtr<nsILoadInfo> mLoadInfo;
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
2004-04-21 14:58:45 +00:00
|
|
|
nsCOMPtr<nsISupports> mSecurityInfo;
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCOMPtr<nsIProgressEventSink> mProgressSink;
|
|
|
|
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
|
|
|
nsCOMPtr<nsIStreamListener> mListener;
|
|
|
|
nsCString mContentType;
|
|
|
|
nsCString mContentCharset;
|
2012-10-22 17:51:07 +00:00
|
|
|
int64_t mContentLength;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mLoadFlags;
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult mStatus;
|
2018-03-01 08:12:00 +00:00
|
|
|
bool mIsPending; // the AsyncOpen is in progress.
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2018-03-01 08:12:00 +00:00
|
|
|
bool mEnableOMT;
|
|
|
|
// |Cancel()|, |Suspend()|, and |Resume()| might be called during AsyncOpen.
|
|
|
|
struct {
|
|
|
|
bool isCanceled;
|
|
|
|
uint32_t suspendCount;
|
|
|
|
} mPendingEvent;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCOMPtr<nsIInputStreamPump> mPump;
|
2014-06-17 16:39:23 +00:00
|
|
|
// mRequest is only non-null during OnStartRequest, so we'll have a pointer
|
|
|
|
// to the request if we get called back via RetargetDeliveryTo.
|
|
|
|
nsCOMPtr<nsIRequest> mRequest;
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCOMPtr<nsIFile> mJarFile;
|
2017-06-24 00:10:54 +00:00
|
|
|
nsCOMPtr<nsIFile> mJarFileOverride;
|
2017-07-21 22:19:09 +00:00
|
|
|
nsCOMPtr<nsIZipReader> mPreCachedJarReader;
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCOMPtr<nsIURI> mJarBaseURI;
|
|
|
|
nsCString mJarEntry;
|
2010-09-09 03:38:34 +00:00
|
|
|
nsCString mInnerJarEntry;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2018-03-01 08:12:00 +00:00
|
|
|
// use StreamTransportService as background thread
|
|
|
|
nsCOMPtr<nsIEventTarget> mWorker;
|
1999-09-17 16:12:41 +00:00
|
|
|
};
|
|
|
|
|
1999-11-07 21:55:12 +00:00
|
|
|
#endif // nsJARChannel_h__
|