Bug 514033 - Error recovery for imagelib - part 12 - Make Decoder API methods return void.r=joe,a=blocker

This commit is contained in:
Bobby Holley 2010-09-12 08:22:31 -07:00
parent 3908bca6f8
commit 00e08f5d34
3 changed files with 11 additions and 19 deletions

View File

@ -62,7 +62,7 @@ Decoder::~Decoder()
* Common implementation of the decoder interface.
*/
nsresult
void
Decoder::Init(RasterImage* aImage, imgIDecoderObserver* aObserver)
{
// We should always have an image
@ -82,10 +82,9 @@ Decoder::Init(RasterImage* aImage, imgIDecoderObserver* aObserver)
// Implementation-specific initialization
InitInternal();
mInitialized = true;
return IsError() ? NS_ERROR_FAILURE : NS_OK;
}
nsresult
void
Decoder::Write(const char* aBuffer, PRUint32 aCount)
{
// We're strict about decoder errors
@ -94,14 +93,13 @@ Decoder::Write(const char* aBuffer, PRUint32 aCount)
// If a data error occured, just ignore future data
if (IsDataError())
return NS_OK;
return;
// Pass the data along to the implementation
WriteInternal(aBuffer, aCount);
return IsError() ? NS_ERROR_FAILURE : NS_OK;
}
nsresult
void
Decoder::Finish()
{
// Implementation-specific finalization
@ -129,8 +127,6 @@ Decoder::Finish()
mObserver->OnStopDecode(nsnull, salvage ? NS_OK : NS_ERROR_FAILURE, nsnull);
}
}
return NS_OK;
}
void

View File

@ -53,10 +53,6 @@ public:
Decoder();
virtual ~Decoder();
/**
* XXX - These methods will stop returning nsresults in a later patch.
*/
/**
* Initialize an image decoder. Decoders may not be re-initialized.
*
@ -65,7 +61,7 @@ public:
*
* Notifications Sent: TODO
*/
nsresult Init(RasterImage* aImage, imgIDecoderObserver* aObserver);
void Init(RasterImage* aImage, imgIDecoderObserver* aObserver);
/**
* Writes data to the decoder.
@ -77,14 +73,14 @@ public:
*
* Notifications Sent: TODO
*/
nsresult Write(const char* aBuffer, PRUint32 aCount);
void Write(const char* aBuffer, PRUint32 aCount);
/**
* Informs the decoder that all the data has been written.
*
* Notifications Sent: TODO
*/
nsresult Finish();
void Finish();
/**
* Tells the decoder to flush any pending invalidations. This informs the image

View File

@ -2150,8 +2150,8 @@ RasterImage::InitDecoder(bool aDoSizeDecode)
// Initialize the decoder
nsCOMPtr<imgIDecoderObserver> observer(do_QueryReferent(mObserver));
mDecoder->SetSizeDecode(aDoSizeDecode);
nsresult result = mDecoder->Init(this, observer);
CONTAINER_ENSURE_SUCCESS(result);
mDecoder->Init(this, observer);
CONTAINER_ENSURE_SUCCESS(mDecoder->GetDecoderError());
// Create a decode worker
mWorker = new imgDecodeWorker(this);
@ -2235,7 +2235,7 @@ RasterImage::WriteToDecoder(const char *aBuffer, PRUint32 aCount)
// Write
mInDecoder = PR_TRUE;
nsresult rv = mDecoder->Write(aBuffer, aCount);
mDecoder->Write(aBuffer, aCount);
mInDecoder = PR_FALSE;
// We unlock the current frame, even if that frame is different from the
@ -2245,7 +2245,7 @@ RasterImage::WriteToDecoder(const char *aBuffer, PRUint32 aCount)
curframe->UnlockImageData();
}
CONTAINER_ENSURE_SUCCESS(rv);
CONTAINER_ENSURE_SUCCESS(mDecoder->GetDecoderError());
// Keep track of the total number of bytes written over the lifetime of the
// decoder