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