Changeset 90947 in webkit


Ignore:
Timestamp:
Jul 13, 2011 2:40:40 PM (13 years ago)
Author:
Joseph Pecoraro
Message:

Some ApplicationCache Origin Cleanup
https://bugs.webkit.org/show_bug.cgi?id=64431

Reviewed by Alexey Proskuryakov.

2011-07-13 Joseph Pecoraro <Joseph Pecoraro>

  • m_loadedSize is inaccurate. This just replaces it with calls to ApplicationCache::estimatedSizeInStorage.
  • m_availableSpaceInQuota can get out of date, so we just recalculate it at the start of appcache downloads.
  • loader/appcache/ApplicationCacheGroup.h:
  • loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::ApplicationCacheGroup): (WebCore::ApplicationCacheGroup::didReceiveData): Remove references to m_loadedSize.

(WebCore::ApplicationCacheGroup::didFinishLoading):
Replace m_loadedSize with estimatedSizeInStorage after we
add the new cached resource to the cache. The calculation
already happened so this check is fast.

(WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
When we start the Downloading phase, recalculate the quota
so that we have an up to date quota value so that we can
break early if needed.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r90940 r90947  
     12011-07-13  Joseph Pecoraro  <joepeck@webkit.org>
     2
     3        Some ApplicationCache Origin Cleanup
     4        https://bugs.webkit.org/show_bug.cgi?id=64431
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        - m_loadedSize is inaccurate. This just replaces it with
     9        calls to ApplicationCache::estimatedSizeInStorage.
     10
     11        - m_availableSpaceInQuota can get out of date, so we just
     12        recalculate it at the start of appcache downloads.
     13
     14        * loader/appcache/ApplicationCacheGroup.h:
     15        * loader/appcache/ApplicationCacheGroup.cpp:
     16        (WebCore::ApplicationCacheGroup::ApplicationCacheGroup):
     17        (WebCore::ApplicationCacheGroup::didReceiveData):
     18        Remove references to m_loadedSize.
     19
     20        (WebCore::ApplicationCacheGroup::didFinishLoading):
     21        Replace m_loadedSize with estimatedSizeInStorage after we
     22        add the new cached resource to the cache. The calculation
     23        already happened so this check is fast.
     24
     25        (WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
     26        When we start the Downloading phase, recalculate the quota
     27        so that we have an up to date quota value so that we can
     28        break early if needed.
     29
    1302011-07-12  Brent Fulgham  <bfulgham@webkit.org>
    231
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp

    r90856 r90947  
    7171    , m_isCopy(isCopy)
    7272    , m_calledReachedMaxAppCacheSize(false)
    73     , m_loadedSize(0)
    7473    , m_availableSpaceInQuota(ApplicationCacheStorage::unknownQuota())
    7574    , m_originQuotaExceededPreviously(false)
     
    584583    ASSERT(m_currentResource);
    585584    m_currentResource->data()->append(data, length);
    586 
    587     m_loadedSize += length;
    588585}
    589586
     
    599596    }
    600597
    601     // After finishing the loading of any resource, we check if it will
    602     // fit in our last known quota limit.
    603     // FIXME: The quota could be changed by another appcache in the same origin.
    604     if (m_availableSpaceInQuota == ApplicationCacheStorage::unknownQuota())
    605         recalculateAvailableSpaceInQuota();
     598    ASSERT(m_currentHandle == handle);
     599    ASSERT(m_pendingEntries.contains(handle->firstRequest().url()));
     600   
     601    m_pendingEntries.remove(handle->firstRequest().url());
     602   
     603    ASSERT(m_cacheBeingUpdated);
     604
     605    m_cacheBeingUpdated->addResource(m_currentResource.release());
     606    m_currentHandle = 0;
    606607
    607608    // While downloading check to see if we have exceeded the available quota.
     
    610611    // of the quota being reached and decided not to increase it then.
    611612    // FIXME: Should we break earlier and prevent redownloading on later page loads?
    612     // We could then also get rid of m_loadedSize.
    613     if (m_originQuotaExceededPreviously && m_availableSpaceInQuota < m_loadedSize) {
     613    if (m_originQuotaExceededPreviously && m_availableSpaceInQuota < m_cacheBeingUpdated->estimatedSizeInStorage()) {
    614614        m_currentResource = 0;
    615615        m_frame->domWindow()->console()->addMessage(OtherMessageSource, LogMessageType, ErrorMessageLevel, "Application Cache update failed, because size quota was exceeded.", 0, String());
     
    617617        return;
    618618    }
    619 
    620     ASSERT(m_currentHandle == handle);
    621     ASSERT(m_pendingEntries.contains(handle->firstRequest().url()));
    622    
    623     m_pendingEntries.remove(handle->firstRequest().url());
    624    
    625     ASSERT(m_cacheBeingUpdated);
    626 
    627     m_cacheBeingUpdated->addResource(m_currentResource.release());
    628     m_currentHandle = 0;
    629619   
    630620    // Load the next resource, if any.
     
    787777    m_progressDone = 0;
    788778
     779    recalculateAvailableSpaceInQuota();
     780
    789781    startLoadingEntry();
    790782}
     
    984976    setUpdateStatus(Idle);
    985977    m_frame = 0;
    986     m_loadedSize = 0;
    987978    m_availableSpaceInQuota = ApplicationCacheStorage::unknownQuota();
    988979    m_calledReachedMaxAppCacheSize = false;
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h

    r90856 r90947  
    200200    RefPtr<ResourceHandle> m_manifestHandle;
    201201
    202     int64_t m_loadedSize;
    203202    int64_t m_availableSpaceInQuota;
    204203    bool m_originQuotaExceededPreviously;
Note: See TracChangeset for help on using the changeset viewer.