Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #ifndef nsStreamListenerWrapper_h__
6 : #define nsStreamListenerWrapper_h__
7 :
8 : #include "nsCOMPtr.h"
9 : #include "nsIStreamListener.h"
10 : #include "nsIRequestObserver.h"
11 : #include "nsIThreadRetargetableStreamListener.h"
12 : #include "mozilla/Attributes.h"
13 :
14 : namespace mozilla {
15 : namespace net {
16 :
17 : // Wrapper class to make replacement of nsHttpChannel's listener
18 : // from JavaScript possible. It is workaround for bug 433711 and 682305.
19 : class nsStreamListenerWrapper final : public nsIStreamListener
20 : , public nsIThreadRetargetableStreamListener
21 : {
22 : public:
23 2 : explicit nsStreamListenerWrapper(nsIStreamListener *listener)
24 2 : : mListener(listener)
25 : {
26 2 : MOZ_ASSERT(mListener, "no stream listener specified");
27 2 : }
28 :
29 : NS_DECL_ISUPPORTS
30 4 : NS_FORWARD_SAFE_NSIREQUESTOBSERVER(mListener)
31 2 : NS_FORWARD_SAFE_NSISTREAMLISTENER(mListener)
32 : NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
33 :
34 : private:
35 2 : ~nsStreamListenerWrapper() {}
36 : nsCOMPtr<nsIStreamListener> mListener;
37 : };
38 :
39 : } // namespace net
40 : } // namespace mozilla
41 :
42 : #endif // nsStreamListenerWrapper_h__
43 :
|