SuspendableChannelWrapper.h (1664B)
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/. */ 5 6 #ifndef SuspendableChannelWrapper_h__ 7 #define SuspendableChannelWrapper_h__ 8 9 #include "nsISuspendableChannelWrapper.h" 10 11 class nsIStreamListener; 12 13 namespace mozilla { 14 namespace net { 15 16 class BaseSuspendableChannelWrapper : public nsISuspendableChannelWrapper { 17 public: 18 NS_DECL_ISUPPORTS 19 NS_DECL_NSISUSPENDABLECHANNELWRAPPER 20 NS_FORWARD_SAFE_NSIREQUEST(mInnerChannel) 21 NS_FORWARD_SAFE_NSICHANNEL(mInnerChannel) 22 23 explicit BaseSuspendableChannelWrapper(nsIChannel* aInnerChannel) 24 : mInnerChannel(aInnerChannel) {} 25 26 protected: 27 virtual ~BaseSuspendableChannelWrapper() = default; 28 nsCOMPtr<nsIChannel> mInnerChannel; 29 }; 30 31 class SuspendableChannelWrapper final : public BaseSuspendableChannelWrapper { 32 public: 33 NS_DECL_ISUPPORTS_INHERITED 34 35 NS_IMETHOD Suspend() override; 36 NS_IMETHOD Resume() override; 37 NS_IMETHOD IsPending(bool*) override; 38 39 NS_IMETHOD AsyncOpen(nsIStreamListener* aListener) override; 40 NS_IMETHOD Open(nsIInputStream** _retval) override; 41 42 explicit SuspendableChannelWrapper(nsIChannel* aInnerChannel) 43 : BaseSuspendableChannelWrapper(aInnerChannel) {} 44 45 private: 46 ~SuspendableChannelWrapper() override = default; 47 48 nsCOMPtr<nsIStreamListener> mListener; 49 uint32_t mSuspendCount = 0; 50 bool mOuterOpened = false; 51 bool mInnerOpened = false; 52 }; 53 54 } // namespace net 55 } // namespace mozilla 56 57 #endif // SuspendableChannelWrapper_h__