netwerk/streamconv/test/Converters.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/streamconv/test/Converters.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +#ifndef Converters_h___
     1.5 +#define Converters_h___
     1.6 +
     1.7 +#include "nsIStreamConverter.h"
     1.8 +#include "nsIFactory.h"
     1.9 +#include "nsCOMPtr.h"
    1.10 +#include "nsStringAPI.h"
    1.11 +
    1.12 +#include <algorithm>
    1.13 +
    1.14 +/* This file defines stream converter components, and their accompanying factory class.
    1.15 + * These converters implement the nsIStreamConverter interface and support both
    1.16 + * asynchronous and synchronous stream conversion.
    1.17 + */
    1.18 +
    1.19 +///////////////////////////////////////////////
    1.20 +// TestConverter
    1.21 +
    1.22 +extern const nsCID kTestConverterCID;
    1.23 +
    1.24 +class TestConverter : public nsIStreamConverter {
    1.25 +public:
    1.26 +    NS_DECL_ISUPPORTS
    1.27 +    NS_DECL_NSIREQUESTOBSERVER
    1.28 +    NS_DECL_NSISTREAMLISTENER
    1.29 +
    1.30 +    TestConverter();
    1.31 +    virtual ~TestConverter() {}
    1.32 +
    1.33 +    // nsIStreamConverter methods
    1.34 +    NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, 
    1.35 +                       const char *aToType, nsISupports *ctxt, nsIInputStream **_retval);
    1.36 +
    1.37 +
    1.38 +    NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, 
    1.39 +                                nsIStreamListener *aListener, nsISupports *ctxt);
    1.40 +
    1.41 +    // member data
    1.42 +    nsCOMPtr<nsIStreamListener> mListener;
    1.43 +    nsCString fromType;
    1.44 +    nsCString toType;
    1.45 +};
    1.46 +
    1.47 +nsresult CreateTestConverter(nsISupports* aOuter, REFNSIID aIID, void** aResult);
    1.48 +
    1.49 +static inline uint32_t
    1.50 +saturated(uint64_t aValue)
    1.51 +{
    1.52 +    return (uint32_t) std::min(aValue, (uint64_t) UINT32_MAX);
    1.53 +}
    1.54 +
    1.55 +#endif /* !Converters_h___ */

mercurial