bug# 21036: Change imglib reload policies to work with necko load attributes. pnunn, r:neeti,dp.

This commit is contained in:
pnunn%netscape.com 2000-02-12 01:51:57 +00:00
Родитель f73e73fc31
Коммит aa85daed4b
6 изменённых файлов: 45 добавлений и 26 удалений

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

@ -674,7 +674,26 @@ ImageNetContextImpl::GetURL (ilIURL * aURL,
if (bIsBackground) {
(void)channel->SetLoadAttributes(nsIChannel::LOAD_BACKGROUND);
}
switch(aLoadMethod){
case IMG_CACHE_ONLY:
/* should never get here, but don't fail if you do. */
case IMG_NTWK_SERVER:
(void)channel->SetLoadAttributes(nsIChannel::VALIDATE_NEVER);
break;
case TV_IMG_NTWK_SERVER:
case TV_NTWK_SERVER_ONLY:
(void)channel->SetLoadAttributes(nsIChannel::FORCE_VALIDATION);
break;
case SERVER_ONLY:
(void)channel->SetLoadAttributes(nsIChannel::FORCE_RELOAD);
break;
default:
break;
}
nsCOMPtr<nsISupports> window (do_QueryInterface(NS_STATIC_CAST(nsIStreamListener *, ic)));
// let's try uri dispatching...
@ -726,7 +745,7 @@ NS_NewImageNetContext(ilINetContext **aInstancePtrResult,
return NS_ERROR_NULL_POINTER;
}
ilINetContext *cx = new ImageNetContextImpl(NET_NORMAL_RELOAD,
ilINetContext *cx = new ImageNetContextImpl(TV_IMG_NTWK_SERVER,
aLoadGroup,
aReconnectCallback,
aReconnectArg);

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

@ -293,7 +293,7 @@ nsresult NS_NewImageNetContextSync(ilINetContext **aInstancePtrResult)
return NS_ERROR_NULL_POINTER;
}
ilINetContext *cx = new ImageNetContextSyncImpl(NET_NORMAL_RELOAD);
ilINetContext *cx = new ImageNetContextSyncImpl(TV_IMG_NTWK_SERVER);
if (cx == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}

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

@ -40,15 +40,22 @@ typedef struct _NET_StreamClass NET_StreamClass;
typedef struct OpaqueCCCDataObject *CCCDataObject;
typedef struct OpaqueINTL_CharSetInfo *INTL_CharSetInfo;
/* How to refill when there's a cache miss */
/* This lists the data input policies for the image lib.
Note that only the last 3 policies request server validation of
image data. These policies are very distinct from the netlib
cache attributes, but are used to set the netlib cache attributes
for a specific image request.
*/
typedef enum NET_ReloadMethod
{
NET_DONT_RELOAD, /* use the cache */
NET_RESIZE_RELOAD, /* use the cache -- special for resizing */
NET_NORMAL_RELOAD, /* use IMS gets for reload */
NET_SUPER_RELOAD, /* retransfer everything */
NET_CACHE_ONLY_RELOAD /* Don't do anything if we miss in the cache.
(For the image library) */
IMG_CACHE_ONLY, /* imgcache, no validation, don't go to netlib cache */
IMG_NTWK_SERVER, /* imgcache 1st, netcache 2nd, server 3rd, no initial validation */
TV_IMG_NTWK_SERVER, /* test validation, use imgcache first. This is now
implemented as TV_NTWK_SERVER_ONLY, since the image cache
is not saved once we know we have to check with the server anyway.
*/
TV_NTWK_SERVER_ONLY, /* test validation, use necko cache first */
SERVER_ONLY, /* server only, force_reload */
} NET_ReloadMethod;
/*

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

@ -1482,7 +1482,7 @@ il_image_complete(il_container *ic)
ILTRACE(1,("il: loop %s", ic->url_address));
if(ic->net_cx){ //ptn test
netRequest = ic->net_cx->CreateURL(ic->fetch_url, NET_DONT_RELOAD);
netRequest = ic->net_cx->CreateURL(ic->fetch_url, IMG_NTWK_SERVER);
if (!netRequest) { /* OOM */
il_container_complete(ic);
break;
@ -1542,8 +1542,7 @@ il_image_complete(il_container *ic)
/* Call to netlib for net cache data happens here. */
netRequest->SetBackgroundLoad(PR_TRUE);
reader = IL_NewNetReader(ic);
(void) ic->net_cx->GetURL(ic->url, NET_CACHE_ONLY_RELOAD /*NET_DONT_RELOAD*/,
reader);
(void) ic->net_cx->GetURL(ic->url, IMG_NTWK_SERVER, reader);
/* Release reader, GetURL will keep a ref to it. */
NS_RELEASE(reader);
} else {

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

@ -22,7 +22,7 @@
/* if.h --- Top-level image library internal routines
*
* $Id: if.h,v 3.17 1999/12/03 01:07:49 pnunn%netscape.com Exp $
* $Id: if.h,v 3.18 2000/02/12 01:49:35 pnunn%netscape.com Exp $
*/
#ifndef _if_h
@ -162,7 +162,7 @@ enum icstate {
/* Force memory cache to be flushed ? */
#define FORCE_RELOAD(reload_method) \
(((reload_method)==NET_NORMAL_RELOAD) || ((reload_method)==NET_SUPER_RELOAD))
(reload_method > IMG_NTWK_SERVER)
/* Simple list of image contexts. */
struct il_context_list {

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

@ -429,10 +429,9 @@ il_get_container(IL_GroupContext *img_cx,
ic = il_find_in_cache(img_cx->display_type, hash, image_url,
background_color, req_depth, req_width, req_height);
if (ic) {
if (ic) {
/* We already started to discard this image container.
Make a new one.*/
/* This ic is being destroyed. Need a new one */
if ((ic->state == IC_ABORT_PENDING))
ic = NULL;
@ -444,14 +443,9 @@ il_get_container(IL_GroupContext *img_cx,
/* 2) Their namespace crosses document boundaries, so caching */
/* could result in incorrect behavior. */
else if((cache_reload_policy == NET_SUPER_RELOAD) ||
((cache_reload_policy == NET_NORMAL_RELOAD) && (!ic->forced)) ||
(cache_reload_policy != NET_CACHE_ONLY_RELOAD &&
ic->expires && (time(NULL) > ic->expires))
) {
/* Get rid of the old copy of the image that we're replacing. */
if (!ic->is_in_use)
{
else if(cache_reload_policy > IMG_NTWK_SERVER){
/* Don't use old copy and purge it from cache.*/
if (!ic->is_in_use) {
il_removefromcache(ic);
il_delete_container(ic);
}