michael@0: #ifndef Converters_h___ michael@0: #define Converters_h___ michael@0: michael@0: #include "nsIStreamConverter.h" michael@0: #include "nsIFactory.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsStringAPI.h" michael@0: michael@0: #include michael@0: michael@0: /* This file defines stream converter components, and their accompanying factory class. michael@0: * These converters implement the nsIStreamConverter interface and support both michael@0: * asynchronous and synchronous stream conversion. michael@0: */ michael@0: michael@0: /////////////////////////////////////////////// michael@0: // TestConverter michael@0: michael@0: extern const nsCID kTestConverterCID; michael@0: michael@0: class TestConverter : public nsIStreamConverter { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIREQUESTOBSERVER michael@0: NS_DECL_NSISTREAMLISTENER michael@0: michael@0: TestConverter(); michael@0: virtual ~TestConverter() {} michael@0: michael@0: // nsIStreamConverter methods michael@0: NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, michael@0: const char *aToType, nsISupports *ctxt, nsIInputStream **_retval); michael@0: michael@0: michael@0: NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, michael@0: nsIStreamListener *aListener, nsISupports *ctxt); michael@0: michael@0: // member data michael@0: nsCOMPtr mListener; michael@0: nsCString fromType; michael@0: nsCString toType; michael@0: }; michael@0: michael@0: nsresult CreateTestConverter(nsISupports* aOuter, REFNSIID aIID, void** aResult); michael@0: michael@0: static inline uint32_t michael@0: saturated(uint64_t aValue) michael@0: { michael@0: return (uint32_t) std::min(aValue, (uint64_t) UINT32_MAX); michael@0: } michael@0: michael@0: #endif /* !Converters_h___ */