Changeset 39725 in webkit


Ignore:
Timestamp:
Jan 8, 2009 3:44:59 PM (15 years ago)
Author:
Antti Koivisto
Message:

2009-01-08 Antti Koivisto <Antti Koivisto>

Reviewed by Oliver Hunt.

Fix <rdar://problem/6467206>
Resources loaded from the memory cache do not get correctly inserted into the DocLoader resource map (22994)


Use CachedResourceHandle in document resource map so resources get updated correctly when using
using cache validation conditionals.

  • loader/Cache.cpp: (WebCore::Cache::evict):
  • loader/DocLoader.cpp: (WebCore::DocLoader::~DocLoader): (WebCore::DocLoader::requestResource): (WebCore::DocLoader::setAutoLoadImages): (WebCore::DocLoader::removeCachedResource):
  • loader/DocLoader.h: (WebCore::DocLoader::cachedResource): (WebCore::DocLoader::allCachedResources):
  • loader/DocumentLoader.cpp: (WebCore::DocumentLoader::getSubresources):
  • loader/ImageLoader.cpp: (WebCore::ImageLoader::updateFromElement):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r39719 r39725  
     12009-01-08  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Fix <rdar://problem/6467206>
     6        Resources loaded from the memory cache do not get correctly inserted into the DocLoader resource map (22994)
     7       
     8        Use CachedResourceHandle in document resource map so resources get updated correctly when using
     9        using cache validation conditionals.
     10
     11        * loader/Cache.cpp:
     12        (WebCore::Cache::evict):
     13        * loader/DocLoader.cpp:
     14        (WebCore::DocLoader::~DocLoader):
     15        (WebCore::DocLoader::requestResource):
     16        (WebCore::DocLoader::setAutoLoadImages):
     17        (WebCore::DocLoader::removeCachedResource):
     18        * loader/DocLoader.h:
     19        (WebCore::DocLoader::cachedResource):
     20        (WebCore::DocLoader::allCachedResources):
     21        * loader/DocumentLoader.cpp:
     22        (WebCore::DocumentLoader::getSubresources):
     23        * loader/ImageLoader.cpp:
     24        (WebCore::ImageLoader::updateFromElement):
     25
    1262009-01-08  Dimitri Glazkov  <dglazkov@chromium.org>
    227
  • trunk/WebCore/loader/Cache.cpp

    r39228 r39725  
    398398    // who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bug.cgi?id=12479#c6>.
    399399    if (resource->inCache()) {
     400        if (!resource->isCacheValidator()) {
     401            // Notify all doc loaders that might be observing this object still that it has been
     402            // extracted from the set of resources.
     403            // No need to do this for cache validator resources, they are replaced automatically by using CachedResourceHandles.
     404            HashSet<DocLoader*>::iterator end = m_docLoaders.end();
     405            for (HashSet<DocLoader*>::iterator itr = m_docLoaders.begin(); itr != end; ++itr)
     406                (*itr)->removeCachedResource(resource);
     407        }
     408       
    400409        // Remove from the resource map.
    401410        m_resources.remove(resource->url());
     
    405414        removeFromLRUList(resource);
    406415        removeFromLiveDecodedResourcesList(resource);
    407        
    408         // Notify all doc loaders that might be observing this object still that it has been
    409         // extracted from the set of resources.
    410         HashSet<DocLoader*>::iterator end = m_docLoaders.end();
    411         for (HashSet<DocLoader*>::iterator itr = m_docLoaders.begin(); itr != end; ++itr)
    412             (*itr)->removeCachedResource(resource);
    413416
    414417        // Subtract from our size totals.
  • trunk/WebCore/loader/DocLoader.cpp

    r39304 r39725  
    6161{
    6262    clearPreloads();
    63     HashMap<String, CachedResource*>::iterator end = m_docResources.end();
    64     for (HashMap<String, CachedResource*>::iterator it = m_docResources.begin(); it != end; ++it)
     63    DocumentResourceMap::iterator end = m_documentResources.end();
     64    for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it)
    6565        it->second->setDocLoader(0);
    6666    m_cache->removeDocLoader(this);
     
    196196
    197197    if (cache()->disabled()) {
    198         HashMap<String, CachedResource*>::iterator it = m_docResources.find(fullURL.string());
     198        DocumentResourceMap::iterator it = m_documentResources.find(fullURL.string());
    199199       
    200         if (it != m_docResources.end()) {
     200        if (it != m_documentResources.end()) {
    201201            it->second->setDocLoader(0);
    202             m_docResources.remove(it);
     202            m_documentResources.remove(it);
    203203        }
    204204    }
     
    213213            return 0;
    214214
    215         m_docResources.set(resource->url(), resource);
     215        m_documentResources.set(resource->url(), resource);
    216216        checkCacheObjectStatus(resource);
    217217    }
     
    253253        return;
    254254
    255     HashMap<String, CachedResource*>::iterator end = m_docResources.end();
    256     for (HashMap<String, CachedResource*>::iterator it = m_docResources.begin(); it != end; ++it) {
    257         CachedResource* resource = it->second;
     255    DocumentResourceMap::iterator end = m_documentResources.end();
     256    for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it) {
     257        CachedResource* resource = it->second.get();
    258258        if (resource->type() == CachedResource::ImageResource) {
    259259            CachedImage* image = const_cast<CachedImage*>(static_cast<const CachedImage*>(resource));
     
    272272void DocLoader::removeCachedResource(CachedResource* resource) const
    273273{
    274     m_docResources.remove(resource->url());
     274    m_documentResources.remove(resource->url());
    275275}
    276276
  • trunk/WebCore/loader/DocLoader.h

    r39304 r39725  
    2727
    2828#include "CachedResource.h"
     29#include "CachedResourceHandle.h"
    2930#include "CachePolicy.h"
    3031#include "StringHash.h"
     
    7172    void printAccessDeniedMessage(const KURL& url) const;
    7273
    73     CachedResource* cachedResource(const String& url) const { return m_docResources.get(url); }
    74     const HashMap<String, CachedResource*>& allCachedResources() const { return m_docResources; }
     74    CachedResource* cachedResource(const String& url) const { return m_documentResources.get(url).get(); }
     75   
     76    typedef HashMap<String, CachedResourceHandle<CachedResource> > DocumentResourceMap;
     77    const DocumentResourceMap& allCachedResources() const { return m_documentResources; }
    7578
    7679    bool autoLoadImages() const { return m_autoLoadImages; }
     
    112115    Cache* m_cache;
    113116    HashSet<String> m_reloadedURLs;
    114     mutable HashMap<String, CachedResource*> m_docResources;
     117    mutable DocumentResourceMap m_documentResources;
    115118    Document* m_doc;
    116119   
  • trunk/WebCore/loader/DocumentLoader.cpp

    r39548 r39725  
    565565        return;
    566566
    567     const HashMap<String, CachedResource*>& allResources = document->docLoader()->allCachedResources();
    568     HashMap<String, CachedResource*>::const_iterator end = allResources.end();
    569     for (HashMap<String, CachedResource*>::const_iterator it = allResources.begin(); it != end; ++it) {
     567    const DocLoader::DocumentResourceMap& allResources = document->docLoader()->allCachedResources();
     568    DocLoader::DocumentResourceMap::const_iterator end = allResources.end();
     569    for (DocLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
    570570        RefPtr<ArchiveResource> subresource = this->subresource(KURL(it->second->url()));
    571571        if (subresource)
  • trunk/WebCore/loader/ImageLoader.cpp

    r39601 r39725  
    102102            newImage->setLoading(true);
    103103            newImage->setDocLoader(doc->docLoader());
    104             doc->docLoader()->m_docResources.set(newImage->url(), newImage);
     104            doc->docLoader()->m_documentResources.set(newImage->url(), newImage);
    105105        } else
    106106            newImage = doc->docLoader()->requestImage(sourceURI(attr));
Note: See TracChangeset for help on using the changeset viewer.