Bug 1504467 [wpt PR 13888] - Add requirements_flake8.txt to .pyup.yml, a=testonly
[gecko.git] / modules / libjar / nsJARChannel.h
blob0d28d6065ef343538c4176afc6896960fa7049cf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
23 #include "nsIFile.h"
24 #include "nsIURI.h"
25 #include "nsCOMPtr.h"
26 #include "nsString.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 public:
42 NS_DECL_ISUPPORTS_INHERITED
43 NS_DECL_NSIREQUEST
44 NS_DECL_NSICHANNEL
45 NS_DECL_NSIJARCHANNEL
46 NS_DECL_NSIREQUESTOBSERVER
47 NS_DECL_NSISTREAMLISTENER
48 NS_DECL_NSITHREADRETARGETABLEREQUEST
49 NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
51 nsJARChannel();
53 nsresult Init(nsIURI *uri);
55 void SetFile(nsIFile *file);
57 private:
58 virtual ~nsJARChannel();
60 nsresult CreateJarInput(nsIZipReaderCache *, nsJARInputThunk **);
61 nsresult LookupFile();
62 nsresult OpenLocalFile();
63 nsresult ContinueOpenLocalFile(nsJARInputThunk* aInput, bool aIsSyncCall);
64 nsresult OnOpenLocalFileComplete(nsresult aResult, bool aIsSyncCall);
65 nsresult CheckPendingEvents();
66 void NotifyError(nsresult aError);
67 void FireOnProgress(uint64_t aProgress);
69 nsCString mSpec;
71 bool mOpened;
73 RefPtr<nsJARProtocolHandler> mJarHandler;
74 nsCOMPtr<nsIJARURI> mJarURI;
75 nsCOMPtr<nsIURI> mOriginalURI;
76 nsCOMPtr<nsISupports> mOwner;
77 nsCOMPtr<nsILoadInfo> mLoadInfo;
78 nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
79 nsCOMPtr<nsISupports> mSecurityInfo;
80 nsCOMPtr<nsIProgressEventSink> mProgressSink;
81 nsCOMPtr<nsILoadGroup> mLoadGroup;
82 nsCOMPtr<nsIStreamListener> mListener;
83 nsCOMPtr<nsISupports> mListenerContext;
84 nsCString mContentType;
85 nsCString mContentCharset;
86 int64_t mContentLength;
87 uint32_t mLoadFlags;
88 nsresult mStatus;
89 bool mIsPending; // the AsyncOpen is in progress.
91 bool mEnableOMT;
92 // |Cancel()|, |Suspend()|, and |Resume()| might be called during AsyncOpen.
93 struct {
94 bool isCanceled;
95 uint32_t suspendCount;
96 } mPendingEvent;
98 nsCOMPtr<nsIInputStreamPump> mPump;
99 // mRequest is only non-null during OnStartRequest, so we'll have a pointer
100 // to the request if we get called back via RetargetDeliveryTo.
101 nsCOMPtr<nsIRequest> mRequest;
102 nsCOMPtr<nsIFile> mJarFile;
103 nsCOMPtr<nsIFile> mJarFileOverride;
104 nsCOMPtr<nsIZipReader> mPreCachedJarReader;
105 nsCOMPtr<nsIURI> mJarBaseURI;
106 nsCString mJarEntry;
107 nsCString mInnerJarEntry;
109 // use StreamTransportService as background thread
110 nsCOMPtr<nsIEventTarget> mWorker;
113 #endif // nsJARChannel_h__