2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsJARChannel_h__
|
|
|
|
#define nsJARChannel_h__
|
|
|
|
|
2015-03-10 17:00:01 -07:00
|
|
|
#include "mozilla/net/MemoryDownloader.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIJARChannel.h"
|
|
|
|
#include "nsIJARURI.h"
|
|
|
|
#include "nsIInputStreamPump.h"
|
2015-05-22 00:32:25 -07:00
|
|
|
#include "InterceptedJARChannel.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
|
|
|
#include "nsIProgressEventSink.h"
|
|
|
|
#include "nsIStreamListener.h"
|
2012-12-22 05:56:21 -08:00
|
|
|
#include "nsIRemoteOpenFileListener.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIZipReader.h"
|
|
|
|
#include "nsILoadGroup.h"
|
2014-07-09 23:56:36 -07:00
|
|
|
#include "nsILoadInfo.h"
|
2014-06-17 09:39:23 -07:00
|
|
|
#include "nsIThreadRetargetableRequest.h"
|
|
|
|
#include "nsIThreadRetargetableStreamListener.h"
|
2009-02-19 12:25:18 -08:00
|
|
|
#include "nsHashPropertyBag.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIFile.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsString.h"
|
2015-05-19 11:15:34 -07:00
|
|
|
#include "mozilla/Logging.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsJARInputThunk;
|
2015-05-22 00:32:25 -07:00
|
|
|
class nsInputStreamPump;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
class InterceptedJARChannel;
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class nsJARChannel final : public nsIJARChannel
|
2015-03-27 11:52:19 -07:00
|
|
|
, public mozilla::net::MemoryDownloader::IObserver
|
|
|
|
, public nsIStreamListener
|
|
|
|
, public nsIRemoteOpenFileListener
|
|
|
|
, public nsIThreadRetargetableRequest
|
|
|
|
, public nsIThreadRetargetableStreamListener
|
|
|
|
, public nsHashPropertyBag
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-07-14 12:21:34 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIREQUEST
|
|
|
|
NS_DECL_NSICHANNEL
|
|
|
|
NS_DECL_NSIJARCHANNEL
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
2012-12-22 05:56:21 -08:00
|
|
|
NS_DECL_NSIREMOTEOPENFILELISTENER
|
2014-06-17 09:39:23 -07:00
|
|
|
NS_DECL_NSITHREADRETARGETABLEREQUEST
|
|
|
|
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsJARChannel();
|
|
|
|
|
|
|
|
nsresult Init(nsIURI *uri);
|
|
|
|
|
2015-05-25 11:21:05 -07:00
|
|
|
nsresult OverrideSecurityInfo(nsISupports* aSecurityInfo);
|
2015-06-02 14:59:30 -07:00
|
|
|
void OverrideURI(nsIURI* aRedirectedURI);
|
2015-05-25 11:21:05 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2014-06-17 09:39:23 -07:00
|
|
|
virtual ~nsJARChannel();
|
|
|
|
|
2012-11-28 10:12:56 -08:00
|
|
|
nsresult CreateJarInput(nsIZipReaderCache *, nsJARInputThunk **);
|
2014-09-15 10:00:08 -07:00
|
|
|
nsresult LookupFile(bool aAllowAsync);
|
2013-02-15 14:27:21 -08:00
|
|
|
nsresult OpenLocalFile();
|
|
|
|
void NotifyError(nsresult aError);
|
2014-06-17 09:39:23 -07:00
|
|
|
void FireOnProgress(uint64_t aProgress);
|
2014-08-21 04:09:35 -07:00
|
|
|
nsresult SetRemoteNSPRFileDesc(PRFileDesc *fd);
|
2015-03-10 17:00:01 -07:00
|
|
|
virtual void OnDownloadComplete(mozilla::net::MemoryDownloader* aDownloader,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsISupports* aCtxt,
|
|
|
|
nsresult aStatus,
|
|
|
|
mozilla::net::MemoryDownloader::Data aData)
|
2015-03-21 09:28:04 -07:00
|
|
|
override;
|
2014-06-17 09:39:23 -07:00
|
|
|
|
2015-05-22 00:32:25 -07:00
|
|
|
// Returns true if this channel should intercept the network request and
|
|
|
|
// prepare for a possible synthesized response instead.
|
|
|
|
bool ShouldIntercept();
|
2015-06-03 01:41:44 -07:00
|
|
|
|
2015-05-22 00:32:25 -07:00
|
|
|
nsresult ContinueAsyncOpen();
|
2015-06-03 01:41:44 -07:00
|
|
|
void FinishAsyncOpen();
|
|
|
|
|
2015-05-22 00:32:25 -07:00
|
|
|
// Discard the prior interception and continue with the original network
|
|
|
|
// request.
|
|
|
|
void ResetInterception();
|
|
|
|
// Override this channel's pending response with a synthesized one. The
|
|
|
|
// content will be asynchronously read from the pump.
|
2015-06-05 03:53:58 -07:00
|
|
|
void OverrideWithSynthesizedResponse(nsIInputStream* aSynthesizedInput,
|
|
|
|
const nsACString& aContentType);
|
2015-05-22 00:32:25 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCString mSpec;
|
|
|
|
|
2012-08-27 16:34:30 -07:00
|
|
|
bool mOpened;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIJARURI> mJarURI;
|
|
|
|
nsCOMPtr<nsIURI> mOriginalURI;
|
2012-07-11 08:38:36 -07:00
|
|
|
nsCOMPtr<nsIURI> mAppURI;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsISupports> mOwner;
|
2014-07-09 23:56:36 -07:00
|
|
|
nsCOMPtr<nsILoadInfo> mLoadInfo;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
|
|
|
nsCOMPtr<nsISupports> mSecurityInfo;
|
|
|
|
nsCOMPtr<nsIProgressEventSink> mProgressSink;
|
|
|
|
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
|
|
|
nsCOMPtr<nsIStreamListener> mListener;
|
|
|
|
nsCOMPtr<nsISupports> mListenerContext;
|
|
|
|
nsCString mContentType;
|
|
|
|
nsCString mContentCharset;
|
2011-09-09 15:41:04 -07:00
|
|
|
nsCString mContentDispositionHeader;
|
|
|
|
/* mContentDisposition is uninitialized if mContentDispositionHeader is
|
|
|
|
* empty */
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mContentDisposition;
|
2012-10-22 10:51:07 -07:00
|
|
|
int64_t mContentLength;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mLoadFlags;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult mStatus;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsPending;
|
|
|
|
bool mIsUnsafe;
|
2012-12-22 05:56:21 -08:00
|
|
|
bool mOpeningRemote;
|
2014-07-17 19:46:22 -07:00
|
|
|
bool mEnsureChildFd;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2015-03-10 17:00:01 -07:00
|
|
|
mozilla::net::MemoryDownloader::Data mTempMem;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIInputStreamPump> mPump;
|
2014-06-17 09:39:23 -07: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;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIFile> mJarFile;
|
|
|
|
nsCOMPtr<nsIURI> mJarBaseURI;
|
|
|
|
nsCString mJarEntry;
|
2010-09-08 20:38:34 -07:00
|
|
|
nsCString mInnerJarEntry;
|
2015-05-22 00:32:25 -07:00
|
|
|
|
|
|
|
nsRefPtr<nsInputStreamPump> mSynthesizedResponsePump;
|
|
|
|
int64_t mSynthesizedStreamLength;
|
|
|
|
|
|
|
|
friend class mozilla::net::InterceptedJARChannel;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsJARChannel_h__
|