Source code

Revision control

Other Tools

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
20
: public nsIStreamListener,
21
public nsIThreadRetargetableStreamListener {
22
public:
23
explicit nsStreamListenerWrapper(nsIStreamListener* listener)
24
: mListener(listener) {
25
MOZ_ASSERT(mListener, "no stream listener specified");
26
}
27
28
NS_DECL_THREADSAFE_ISUPPORTS
29
NS_FORWARD_SAFE_NSIREQUESTOBSERVER(mListener)
30
NS_FORWARD_SAFE_NSISTREAMLISTENER(mListener)
31
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
32
33
private:
34
~nsStreamListenerWrapper() = default;
35
nsCOMPtr<nsIStreamListener> mListener;
36
};
37
38
} // namespace net
39
} // namespace mozilla
40
41
#endif // nsStreamListenerWrapper_h__