Bug 1803740 - Apply the minimum-scale for desktop mode. r=botond
[gecko.git] / modules / libjar / nsJARChannel.h
blob25c88060d82108cff79c333f94dee0d604018d19
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"
23 #include "nsIFile.h"
24 #include "nsIURI.h"
25 #include "nsCOMPtr.h"
26 #include "nsString.h"
27 #include "mozilla/Atomics.h"
28 #include "mozilla/Logging.h"
30 class nsJARInputThunk;
31 class nsJARProtocolHandler;
32 class nsInputStreamPump;
34 //-----------------------------------------------------------------------------
36 class nsJARChannel final : public nsIJARChannel,
37 public nsIStreamListener,
38 public nsIThreadRetargetableRequest,
39 public nsIThreadRetargetableStreamListener,
40 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 // Returns false if we don't know the content type of this channel, in which
70 // case we should use the content-type hint.
71 bool GetContentTypeGuess(nsACString&) const;
72 void SetOpened();
74 nsCString mSpec;
76 bool mOpened;
77 mozilla::Atomic<bool, mozilla::ReleaseAcquire> mCanceled;
78 bool mOnDataCalled = false;
80 RefPtr<nsJARProtocolHandler> mJarHandler;
81 nsCOMPtr<nsIJARURI> mJarURI;
82 nsCOMPtr<nsIURI> mOriginalURI;
83 nsCOMPtr<nsISupports> mOwner;
84 nsCOMPtr<nsILoadInfo> mLoadInfo;
85 nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
86 nsCOMPtr<nsIProgressEventSink> mProgressSink;
87 nsCOMPtr<nsILoadGroup> mLoadGroup;
88 nsCOMPtr<nsIStreamListener> mListener;
89 nsCString mContentType;
90 nsCString mContentCharset;
91 int64_t mContentLength;
92 uint32_t mLoadFlags;
93 mozilla::Atomic<nsresult, mozilla::ReleaseAcquire> mStatus;
94 bool mIsPending; // the AsyncOpen is in progress.
96 bool mEnableOMT;
97 // |Cancel()|, |Suspend()|, and |Resume()| might be called during AsyncOpen.
98 struct {
99 bool isCanceled;
100 mozilla::Atomic<uint32_t> suspendCount;
101 } mPendingEvent;
103 nsCOMPtr<nsIInputStreamPump> mPump;
104 // mRequest is only non-null during OnStartRequest, so we'll have a pointer
105 // to the request if we get called back via RetargetDeliveryTo.
106 nsCOMPtr<nsIRequest> mRequest;
107 nsCOMPtr<nsIFile> mJarFile;
108 nsCOMPtr<nsIFile> mJarFileOverride;
109 nsCOMPtr<nsIZipReader> mPreCachedJarReader;
110 nsCOMPtr<nsIURI> mJarBaseURI;
111 nsCString mJarEntry;
112 nsCString mInnerJarEntry;
114 // use StreamTransportService as background thread
115 nsCOMPtr<nsIEventTarget> mWorker;
118 #endif // nsJARChannel_h__