fix for 29853 in trunk, r=dp,Animated ads are stopping after one loop, and are then being reloaded from the server

This commit is contained in:
neeti%netscape.com 2000-03-17 21:51:31 +00:00
Родитель 0b8d285916
Коммит 3af932b178
5 изменённых файлов: 44 добавлений и 16 удалений

Просмотреть файл

@ -332,6 +332,13 @@ ImageConsumer::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, nsIIn
nsresult err = 0;
PRUint32 nb;
char* uriStr = NULL;
nsCOMPtr<nsIURI> uri;
err = channel->GetURI(getter_AddRefs(uri));
if (NS_SUCCEEDED(err)) {
err = uri->GetSpec(&uriStr);
}
do {
err = reader->WriteReady(&max_read); //max read is most decoder can handle
@ -371,7 +378,7 @@ ImageConsumer::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, nsIIn
bytes_read += nb;
if (mFirstRead == PR_TRUE) {
err = reader->FirstWrite((const unsigned char *)mBuffer, nb );
err = reader->FirstWrite((const unsigned char *)mBuffer, nb, uriStr);
mFirstRead = PR_FALSE; //? move after err chk?
/*
* If FirstWrite(...) fails then the image type
@ -395,6 +402,10 @@ ImageConsumer::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, nsIIn
}
} while(bytes_read < length);
if (uriStr) {
nsCRT::free(uriStr);
}
if (NS_FAILED(err)) {
mStatus = MK_IMAGE_LOSSAGE;
mInterrupted = PR_TRUE;

Просмотреть файл

@ -231,12 +231,14 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL,
nsresult result;
PRBool first = PR_TRUE;
char* uriStr = NULL;
uriStr = aURL->GetAddress();
result = stream->Read(buf, sizeof(buf), &count);
while (NS_SUCCEEDED(result) && (count > 0)) {
if (first == PR_TRUE) {
PRInt32 ilErr;
ilErr = aReader->FirstWrite((const unsigned char *)buf, (int32)count);
ilErr = aReader->FirstWrite((const unsigned char *)buf, (int32)count, uriStr);
first = PR_FALSE;
// If FirstWrite fails then the image type cannot be determined
if (ilErr != 0) {
@ -250,6 +252,8 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL,
// Get the next block
result = stream->Read(buf, sizeof(buf), &count);
}
nsCRT::free(uriStr);
if (NS_FAILED(result)) {
aReader->StreamAbort(-1);

Просмотреть файл

@ -40,7 +40,7 @@ public:
NS_IMETHOD WriteReady(PRUint32 *max_read)=0;
NS_IMETHOD FirstWrite(const unsigned char *str, int32 len)=0;
NS_IMETHOD FirstWrite(const unsigned char *str, int32 len, char* url)=0;
NS_IMETHOD Write(const unsigned char *str, int32 len)=0;

Просмотреть файл

@ -1026,19 +1026,24 @@ IL_StreamFirstWrite(il_container *ic, const unsigned char *str, int32 len)
ic->fetch_url keeps the actual url for you.
*/
/* ic->fetch_url is being set in NetReaderImpl::FirstWrite(..).
This is just a backup code to set ic->fetch_url, in the case
we do not set ic->fetch_url in NetReaderImpl::FirstWrite(..).*/
FREE_IF_NOT_NULL(ic->fetch_url);
// FREE_IF_NOT_NULL(ic->fetch_url);
if (!ic->fetch_url) {
if (ic->url) {
ic->fetch_url = ic->url->GetAddress();
}
else {
if(ic->url_address) // check needed because of mkicons.c
ic->fetch_url = PL_strdup(ic->url_address);
else
ic->fetch_url = NULL;
}
}
if (ic->url){
ic->fetch_url = ic->url->GetAddress();
}
else{
if(ic->url_address) /* check needed because of mkicons.c */
ic->fetch_url = PL_strdup(ic->url_address);
else
ic->fetch_url = NULL;
}
/* Grab the URL's expiration date */
if (ic->url)

Просмотреть файл

@ -22,6 +22,7 @@
#include "if.h"
#include "ilINetReader.h"
#include "nsCRT.h"
static NS_DEFINE_IID(kINetReaderIID, IL_INETREADER_IID);
@ -35,7 +36,7 @@ public:
NS_IMETHOD WriteReady(PRUint32 *max_read);
NS_IMETHOD FirstWrite(const unsigned char *str, int32 len);
NS_IMETHOD FirstWrite(const unsigned char *str, int32 len, char* url);
NS_IMETHOD Write(const unsigned char *str, int32 len);
@ -79,11 +80,18 @@ NetReaderImpl::WriteReady(PRUint32* max_read)
}
NS_IMETHODIMP
NetReaderImpl::FirstWrite(const unsigned char *str, int32 len)
NetReaderImpl::FirstWrite(const unsigned char *str, int32 len, char* url)
{
int ret = 0;
if (ilContainer != NULL) {
FREE_IF_NOT_NULL(ilContainer->fetch_url);
if (url) {
ilContainer->fetch_url = nsCRT::strdup(url);
}
else {
ilContainer->fetch_url = NULL;
}
ret = IL_StreamFirstWrite(ilContainer, str, len);
if(ret == 0)
return NS_OK;