Bug 1178991 - smartptr for http converter r=hurley

This commit is contained in:
Patrick McManus 2015-06-30 17:17:10 -04:00
parent ffc6c89d10
commit d5bb133e67
2 changed files with 41 additions and 48 deletions

View File

@ -15,7 +15,6 @@
#include "nsThreadUtils.h"
#include "mozilla/Preferences.h"
// nsISupports implementation
NS_IMPL_ISUPPORTS(nsHTTPCompressConv,
nsIStreamConverter,
@ -24,8 +23,7 @@ NS_IMPL_ISUPPORTS(nsHTTPCompressConv,
// nsFTPDirListingConv methods
nsHTTPCompressConv::nsHTTPCompressConv()
: mListener(nullptr)
, mMode(HTTP_COMPRESS_IDENTITY)
: mMode(HTTP_COMPRESS_IDENTITY)
, mOutBuffer(nullptr)
, mInpBuffer(nullptr)
, mOutBufferLen(0)
@ -48,8 +46,6 @@ nsHTTPCompressConv::nsHTTPCompressConv()
nsHTTPCompressConv::~nsHTTPCompressConv()
{
NS_IF_RELEASE(mListener);
if (mInpBuffer)
free(mInpBuffer);
@ -69,19 +65,17 @@ nsHTTPCompressConv::AsyncConvertData(const char *aFromType,
nsISupports *aCtxt)
{
if (!PL_strncasecmp(aFromType, HTTP_COMPRESS_TYPE, sizeof(HTTP_COMPRESS_TYPE)-1) ||
!PL_strncasecmp(aFromType, HTTP_X_COMPRESS_TYPE, sizeof(HTTP_X_COMPRESS_TYPE)-1))
!PL_strncasecmp(aFromType, HTTP_X_COMPRESS_TYPE, sizeof(HTTP_X_COMPRESS_TYPE)-1)) {
mMode = HTTP_COMPRESS_COMPRESS;
else if (!PL_strncasecmp(aFromType, HTTP_GZIP_TYPE, sizeof(HTTP_GZIP_TYPE)-1) ||
!PL_strncasecmp(aFromType, HTTP_X_GZIP_TYPE, sizeof(HTTP_X_GZIP_TYPE)-1))
} else if (!PL_strncasecmp(aFromType, HTTP_GZIP_TYPE, sizeof(HTTP_GZIP_TYPE)-1) ||
!PL_strncasecmp(aFromType, HTTP_X_GZIP_TYPE, sizeof(HTTP_X_GZIP_TYPE)-1)) {
mMode = HTTP_COMPRESS_GZIP;
else if (!PL_strncasecmp(aFromType, HTTP_DEFLATE_TYPE, sizeof(HTTP_DEFLATE_TYPE)-1))
} else if (!PL_strncasecmp(aFromType, HTTP_DEFLATE_TYPE, sizeof(HTTP_DEFLATE_TYPE)-1)) {
mMode = HTTP_COMPRESS_DEFLATE;
}
// hook ourself up with the receiving listener.
mListener = aListener;
NS_ADDREF(mListener);
mAsyncConvContext = aCtxt;
return NS_OK;
@ -253,9 +247,9 @@ nsHTTPCompressConv::OnDataAvailable(nsIRequest* request,
// reset stream pointers to our original data
d_stream.next_in = mInpBuffer;
d_stream.avail_in = (uInt)streamLen;
}
else
} else {
return NS_ERROR_INVALID_CONTENT_ENCODING;
}
} /* for */
}
else

View File

@ -49,14 +49,13 @@ public:
// nsIStreamConverter methods
NS_DECL_NSISTREAMCONVERTER
nsHTTPCompressConv ();
private:
virtual ~nsHTTPCompressConv ();
nsIStreamListener *mListener; // this guy gets the converted data via his OnDataAvailable ()
nsCOMPtr<nsIStreamListener> mListener; // this guy gets the converted data via his OnDataAvailable ()
CompressMode mMode;
unsigned char *mOutBuffer;