|
1 #ifndef Converters_h___ |
|
2 #define Converters_h___ |
|
3 |
|
4 #include "nsIStreamConverter.h" |
|
5 #include "nsIFactory.h" |
|
6 #include "nsCOMPtr.h" |
|
7 #include "nsStringAPI.h" |
|
8 |
|
9 #include <algorithm> |
|
10 |
|
11 /* This file defines stream converter components, and their accompanying factory class. |
|
12 * These converters implement the nsIStreamConverter interface and support both |
|
13 * asynchronous and synchronous stream conversion. |
|
14 */ |
|
15 |
|
16 /////////////////////////////////////////////// |
|
17 // TestConverter |
|
18 |
|
19 extern const nsCID kTestConverterCID; |
|
20 |
|
21 class TestConverter : public nsIStreamConverter { |
|
22 public: |
|
23 NS_DECL_ISUPPORTS |
|
24 NS_DECL_NSIREQUESTOBSERVER |
|
25 NS_DECL_NSISTREAMLISTENER |
|
26 |
|
27 TestConverter(); |
|
28 virtual ~TestConverter() {} |
|
29 |
|
30 // nsIStreamConverter methods |
|
31 NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, |
|
32 const char *aToType, nsISupports *ctxt, nsIInputStream **_retval); |
|
33 |
|
34 |
|
35 NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, |
|
36 nsIStreamListener *aListener, nsISupports *ctxt); |
|
37 |
|
38 // member data |
|
39 nsCOMPtr<nsIStreamListener> mListener; |
|
40 nsCString fromType; |
|
41 nsCString toType; |
|
42 }; |
|
43 |
|
44 nsresult CreateTestConverter(nsISupports* aOuter, REFNSIID aIID, void** aResult); |
|
45 |
|
46 static inline uint32_t |
|
47 saturated(uint64_t aValue) |
|
48 { |
|
49 return (uint32_t) std::min(aValue, (uint64_t) UINT32_MAX); |
|
50 } |
|
51 |
|
52 #endif /* !Converters_h___ */ |