Changeset 20178 in webkit


Ignore:
Timestamp:
Mar 13, 2007 8:59:08 PM (17 years ago)
Author:
beidson
Message:

Reviewed by Anders

<rdar://problem/5048818> - REGRESSION: Incompletely loaded resources being saved to the object cache

Due to a subtle change in loader behavior back in 10904, we would stop all loaders before calling
didFail() on them in the Cache loader. As a result, we basically cleared all of the Subresource Loaders
out of the Cache loader before more properly failing them as errored out. The result? Partially loaded
resources being cached.


Since Loader::didFail() both calls error() on the object *and* removes the loader, the solution is to call
didFail() for all cancelled loaders instead of *only* removing them from the set of active loaders.


In addition, pages that didn't completely load were being saved to the back/forward cache. To fix that,
I added a null check on the DocumentLoader's error to see if the page ended in an error, or did indeed
completely load.

Note that the layout test for this - if possible - will require other enhancements including possibly adding
support for window.stop(). That task is documented in <rdar://problem/5061826>

  • loader/FrameLoader.cpp: (WebCore::FrameLoader::provisionalLoadStarted): Fixed a few bugs relating to my original BFCache rewrite to more perfectly restore the original behavior - including only caching HTML documents via the m_client->canCachePage() call (WebCore::FrameLoader::canCachePage): Don't make the call to m_client->canCachePage() as that serves a different purpose
    • Check the mainDocumentError to see if the load ended in error as a further criteria in determining the cachability of a page
  • loader/loader.cpp: (WebCore::Loader::cancelRequests): Call didFail(cancelledError()) instead of just removing the loaders from the loaders-in-progress set. This adds the effect of properly cleaning up the cached object.
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r20177 r20178  
     12007-03-13  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Anders
     4
     5        <rdar://problem/5048818> - REGRESSION: Incompletely loaded resources being saved to the object cache
     6
     7        Due to a subtle change in loader behavior back in 10904, we would stop all loaders before calling
     8        didFail() on them in the Cache loader.  As a result, we basically cleared all of the Subresource Loaders
     9        out of the Cache loader before more properly failing them as errored out.  The result?  Partially loaded
     10        resources being cached.
     11       
     12        Since Loader::didFail() both calls error() on the object *and* removes the loader, the solution is to call
     13        didFail() for all cancelled loaders instead of *only* removing them from the set of active loaders.
     14       
     15        In addition, pages that didn't completely load were being saved to the back/forward cache.  To fix that,
     16        I added a null check on the DocumentLoader's error to see if the page ended in an error, or did indeed
     17        completely load.
     18
     19        Note that the layout test for this - if possible - will require other enhancements including possibly adding
     20        support for window.stop().  That task is documented in <rdar://problem/5061826>
     21
     22        * loader/FrameLoader.cpp:
     23        (WebCore::FrameLoader::provisionalLoadStarted): Fixed a few bugs relating to my original BFCache rewrite to
     24          more perfectly restore the original behavior - including only caching HTML documents via the
     25          m_client->canCachePage() call
     26        (WebCore::FrameLoader::canCachePage): Don't make the call to m_client->canCachePage() as that serves a different
     27          purpose
     28          - Check the mainDocumentError to see if the load ended in error as a further criteria in determining the
     29          cachability of a page
     30
     31        * loader/loader.cpp:
     32        (WebCore::Loader::cancelRequests): Call didFail(cancelledError()) instead of just removing the loaders from the
     33          loaders-in-progress set.  This adds the effect of properly cleaning up the cached object.
     34
    1352007-03-13  Beth Dakin  <bdakin@apple.com>
    236
  • trunk/WebCore/loader/FrameLoader.cpp

    r20132 r20178  
    14791479        && loadType != FrameLoadTypeReloadAllowingStaleData
    14801480        && loadType != FrameLoadTypeSame
    1481         && !documentLoader()->isLoading()
     1481        && !documentLoader()->isLoadingInAPISense()
    14821482        && !documentLoader()->isStopping()) {
    1483        
    1484         if (!m_currentHistoryItem->pageCache()) {
    1485             // Add the items to this page's cache.
    1486             if (createPageCache(m_currentHistoryItem.get())) {
    1487                 // See if any page caches need to be purged after the addition of this new page cache.
    1488                 purgePageCache();
     1483        if (m_client->canCachePage()) {
     1484            if (!m_currentHistoryItem->pageCache()) {
     1485                // Add the items to this page's cache.
     1486                if (createPageCache(m_currentHistoryItem.get())) {
     1487                    // See if any page caches need to be purged after the addition of this new page cache.
     1488                    purgePageCache();
     1489                }
    14891490            }
     1491        } else {
     1492            // Put the document into a null state, so it can be restored correctly.
     1493            clear();
    14901494        }
    14911495    }
     
    15321536
    15331537bool FrameLoader::canCachePage()
    1534 {
    1535     if (!m_client->canCachePage())
     1538{   
     1539    if (documentLoader() && !documentLoader()->mainDocumentError().isNull())
    15361540        return false;
    1537        
     1541
    15381542    return m_frame->document()
    15391543        && !m_frame->tree()->childCount()
  • trunk/WebCore/loader/loader.cpp

    r19977 r20178  
    224224    for (unsigned i = 0; i < loadersToCancel.size(); ++i) {
    225225        SubresourceLoader* loader = loadersToCancel[i];
    226         Request* r = m_requestsLoading.get(loader);
    227         m_requestsLoading.remove(loader);
    228         cache()->remove(r->cachedResource());
     226        didFail(loader, loader->cancelledError());
    229227    }
    230228}
Note: See TracChangeset for help on using the changeset viewer.