netwerk/streamconv/test/Converters.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 #ifndef Converters_h___
     2 #define Converters_h___
     4 #include "nsIStreamConverter.h"
     5 #include "nsIFactory.h"
     6 #include "nsCOMPtr.h"
     7 #include "nsStringAPI.h"
     9 #include <algorithm>
    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  */
    16 ///////////////////////////////////////////////
    17 // TestConverter
    19 extern const nsCID kTestConverterCID;
    21 class TestConverter : public nsIStreamConverter {
    22 public:
    23     NS_DECL_ISUPPORTS
    24     NS_DECL_NSIREQUESTOBSERVER
    25     NS_DECL_NSISTREAMLISTENER
    27     TestConverter();
    28     virtual ~TestConverter() {}
    30     // nsIStreamConverter methods
    31     NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, 
    32                        const char *aToType, nsISupports *ctxt, nsIInputStream **_retval);
    35     NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, 
    36                                 nsIStreamListener *aListener, nsISupports *ctxt);
    38     // member data
    39     nsCOMPtr<nsIStreamListener> mListener;
    40     nsCString fromType;
    41     nsCString toType;
    42 };
    44 nsresult CreateTestConverter(nsISupports* aOuter, REFNSIID aIID, void** aResult);
    46 static inline uint32_t
    47 saturated(uint64_t aValue)
    48 {
    49     return (uint32_t) std::min(aValue, (uint64_t) UINT32_MAX);
    50 }
    52 #endif /* !Converters_h___ */

mercurial