1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsJARChannel_h__
7 #define nsJARChannel_h__
9 #include "mozilla/net/MemoryDownloader.h"
10 #include "nsIJARChannel.h"
11 #include "nsIJARURI.h"
12 #include "nsIEventTarget.h"
13 #include "nsIInputStreamPump.h"
14 #include "nsIInterfaceRequestor.h"
15 #include "nsIProgressEventSink.h"
16 #include "nsIStreamListener.h"
17 #include "nsIZipReader.h"
18 #include "nsILoadGroup.h"
19 #include "nsILoadInfo.h"
20 #include "nsIThreadRetargetableRequest.h"
21 #include "nsIThreadRetargetableStreamListener.h"
22 #include "nsHashPropertyBag.h"
27 #include "mozilla/Logging.h"
29 class nsJARInputThunk
;
30 class nsJARProtocolHandler
;
31 class nsInputStreamPump
;
33 //-----------------------------------------------------------------------------
35 class nsJARChannel final
: public nsIJARChannel
,
36 public nsIStreamListener
,
37 public nsIThreadRetargetableRequest
,
38 public nsIThreadRetargetableStreamListener
,
39 public nsHashPropertyBag
{
41 NS_DECL_ISUPPORTS_INHERITED
45 NS_DECL_NSIREQUESTOBSERVER
46 NS_DECL_NSISTREAMLISTENER
47 NS_DECL_NSITHREADRETARGETABLEREQUEST
48 NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
52 nsresult
Init(nsIURI
*uri
);
54 void SetFile(nsIFile
*file
);
57 virtual ~nsJARChannel();
59 nsresult
CreateJarInput(nsIZipReaderCache
*, nsJARInputThunk
**);
60 nsresult
LookupFile();
61 nsresult
OpenLocalFile();
62 nsresult
ContinueOpenLocalFile(nsJARInputThunk
*aInput
, bool aIsSyncCall
);
63 nsresult
OnOpenLocalFileComplete(nsresult aResult
, bool aIsSyncCall
);
64 nsresult
CheckPendingEvents();
65 void NotifyError(nsresult aError
);
66 void FireOnProgress(uint64_t aProgress
);
72 RefPtr
<nsJARProtocolHandler
> mJarHandler
;
73 nsCOMPtr
<nsIJARURI
> mJarURI
;
74 nsCOMPtr
<nsIURI
> mOriginalURI
;
75 nsCOMPtr
<nsISupports
> mOwner
;
76 nsCOMPtr
<nsILoadInfo
> mLoadInfo
;
77 nsCOMPtr
<nsIInterfaceRequestor
> mCallbacks
;
78 nsCOMPtr
<nsISupports
> mSecurityInfo
;
79 nsCOMPtr
<nsIProgressEventSink
> mProgressSink
;
80 nsCOMPtr
<nsILoadGroup
> mLoadGroup
;
81 nsCOMPtr
<nsIStreamListener
> mListener
;
82 nsCString mContentType
;
83 nsCString mContentCharset
;
84 int64_t mContentLength
;
87 bool mIsPending
; // the AsyncOpen is in progress.
90 // |Cancel()|, |Suspend()|, and |Resume()| might be called during AsyncOpen.
93 uint32_t suspendCount
;
96 nsCOMPtr
<nsIInputStreamPump
> mPump
;
97 // mRequest is only non-null during OnStartRequest, so we'll have a pointer
98 // to the request if we get called back via RetargetDeliveryTo.
99 nsCOMPtr
<nsIRequest
> mRequest
;
100 nsCOMPtr
<nsIFile
> mJarFile
;
101 nsCOMPtr
<nsIFile
> mJarFileOverride
;
102 nsCOMPtr
<nsIZipReader
> mPreCachedJarReader
;
103 nsCOMPtr
<nsIURI
> mJarBaseURI
;
105 nsCString mInnerJarEntry
;
107 // use StreamTransportService as background thread
108 nsCOMPtr
<nsIEventTarget
> mWorker
;
111 #endif // nsJARChannel_h__