ApplicationCache update should not immediately fail when reaching per-origin quota
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jul 2011 22:00:45 +0000 (22:00 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jul 2011 22:00:45 +0000 (22:00 +0000)
commit3b7d807ab51c74788d10e5e09975aa30003aa902
treee037326d31e5803f95a8f8db9e69ae11da6b5972
parent25f2d7c33d8d80c08bc87191bd360b2123fe57bf
ApplicationCache update should not immediately fail when reaching per-origin quota
https://bugs.webkit.org/show_bug.cgi?id=64177

Reviewed by Alexey Proskuryakov.

2011-07-12  Joseph Pecoraro  <joepeck@webkit.org>

        Include spaceNeeded information in the output dumped for appcache quota delegates.
        Add and update tests related to handling of per-origin quotas.

        * http/tests/appcache/origin-quota-continued-download-expected.txt: Added.
        * http/tests/appcache/origin-quota-continued-download.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download.manifest: Added.
        New test which checks that there will still be a successful cache
        when the per-origin quota is reached and increased at the end of downloading.

        * http/tests/appcache/origin-quota-continued-download-multiple-manifests-expected.txt: Added.
        * http/tests/appcache/origin-quota-continued-download-multiple-manifests.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-1.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-1.manifest: Added.
        * http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-2.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-2.manifest: Added.
        * http/tests/appcache/resources/quota-origin-continued-download.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download.manifest: Added.
        New test which checks that the spaceNeeded appropriately lists enough space for
        multiple manifests across multiple frames for the same origin.

        * http/tests/appcache/resources/quota-origin-iframe-3.manifest: Fix a typo.
        * http/tests/appcache/origin-quota.html:
        Update the old test to disallow automatic increase of the quota,
        which is the default handling of DRT when reaching the quota.

        * platform/chromium/test_expectations.txt:
        * platform/gtk/Skipped:
        * platform/qt/Skipped:
        * platform/win/Skipped:
        * platform/wk2/Skipped:
        Skip the test on ports that don't implement ApplicationCache per-origin quotas.

2011-07-12  Joseph Pecoraro  <joepeck@webkit.org>

        New behavior of handling ApplicationCache per-origin quotas. Previously,
        if the quota was reached while downloading we would fail the download
        and then prompt the user for a storage increase. This required a refresh,
        a redownload of resources, and the total storage was not known so the
        process could be repeated multiple times before an acceptable quota
        was found or the user disallowed an increase.

        The new behavior is to complete the download of the entire appcache.
        When the cache completes downloading and it is greater than the origin
        quota, prompt the user to allow a quota increase with the known space
        needed. If the quota is increased, the cache will succeed, otherwise
        it will fail with the normal failure steps.

        An alternative behavior is prompting while downloading immediately
        when the origin quota is reached, however at that point the entire
        space needed is unknown and so quota increases might not be enough
        and could result in multiple prompts to the user.

        Tests: http/tests/appcache/origin-quota-continued-download-multiple-manifests.html
               http/tests/appcache/origin-quota-continued-download.html

        * loader/appcache/ApplicationCacheGroup.h:
        * loader/appcache/ApplicationCacheGroup.cpp:
        (WebCore::ApplicationCacheGroup::ApplicationCacheGroup):
        Rename instance variable to be more clear on its intent.

        (WebCore::ApplicationCacheGroup::didFinishLoading):
        Check the quota limit while downloading so we can fail early
        if the user already denied a quota increase.

        (WebCore::ApplicationCacheGroup::didReachOriginQuota):
        Pass the space needed information to the chrome client.

        (WebCore::ApplicationCacheGroup::cacheUpdateFailedDueToOriginQuota):
        Removed. Instead convert the callers to update state and console
        log when the per-origin quota is reached. This allows us to follow
        the normal failure steps if the quota is reached at the end of a
        download, and the alternative short path when we fail during downloading.

        (WebCore::ApplicationCacheGroup::recalculateAvailableSpaceInQuota):
        Extract to a helper function.

        (WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
        Allow for a quota increase at the end of the download now that
        we know the space needed. Then proceed to fail or succeed
        as we normally would.

        * loader/appcache/ApplicationCacheStorage.h:
        * loader/appcache/ApplicationCacheStorage.cpp:
        (WebCore::ApplicationCacheStorage::checkOriginQuota):
        (WebCore::ApplicationCacheStorage::storeNewestCache):
        Extract checking the origin quota for when an ApplicationCacheGroup
        will be replacing an ApplicationCacheGroup into a helper function.
        The helper also provides an out parameter for the space needed
        to properly fit the new cache group if it wouldn't fit.

        * page/ChromeClient.h:
        * loader/EmptyClients.h:
        (WebCore::EmptyChromeClient::reachedApplicationCacheOriginQuota):
        Add a space needed parameter when reaching the per-origin quota.

2011-07-12  Joseph Pecoraro  <joepeck@webkit.org>

        * WebView/WebUIDelegatePrivate.h:
        * DefaultDelegates/WebDefaultUIDelegate.m:
        (-[WebDefaultUIDelegate webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:spaceNeeded:]):
        Update the delegate to include a space needed parameter.

        * WebCoreSupport/WebChromeClient.h:
        * WebCoreSupport/WebChromeClient.mm:
        (WebChromeClient::reachedApplicationCacheOriginQuota):
        Call the delegate with the new space needed information.

2011-07-12  Joseph Pecoraro  <joepeck@webkit.org>

        * Api/qwebpage.cpp:
        * Api/qwebpage.h:
        * WebCoreSupport/ChromeClientQt.cpp:
        (WebCore::ChromeClientQt::reachedApplicationCacheOriginQuota):
        * WebCoreSupport/ChromeClientQt.h:
        Pass the spaceNeeded value through to the applicationCacheQuotaExceeded signal.

2011-07-12  Joseph Pecoraro  <joepeck@webkit.org>

        Add layoutTestController.disallowIncreaseForApplicationCacheQuota()
        to disable the default behavior of raising the default per-origin
        quota to 5MB when reached. This allows us to test what happens
        when the quota is reached and not increased.

        * DumpRenderTree/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (disallowIncreaseForApplicationCacheQuotaCallback):
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h:
        (LayoutTestController::disallowIncreaseForApplicationCacheQuota):
        (LayoutTestController::setDisallowIncreaseForApplicationCacheQuota):
        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
        (LayoutTestController::reset):
        * DumpRenderTree/qt/LayoutTestControllerQt.h:
        (LayoutTestController::disallowIncreaseForApplicationCacheQuota):
        (LayoutTestController::dumpApplicationCacheDelegateCallbacks):
        Expose a function to prevent automatically increasing the per-origin
        quota when the quota is reached. This allows us to test what happens
        when a user would "disallow" a quota increase.

        * DumpRenderTree/mac/UIDelegate.mm:
        (-[UIDelegate webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:spaceNeeded:]):
        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
        (WebCore::DumpRenderTree::dumpApplicationCacheQuota):
        Respect the new disallowIncrease flag and dump the spaceNeeded values
        for ports that implement application cache quotas.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@90856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
68 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/appcache/origin-quota-continued-download-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/appcache/origin-quota-continued-download-multiple-manifests-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/appcache/origin-quota-continued-download-multiple-manifests.html [new file with mode: 0644]
LayoutTests/http/tests/appcache/origin-quota-continued-download.html [new file with mode: 0644]
LayoutTests/http/tests/appcache/origin-quota-expected.txt
LayoutTests/http/tests/appcache/origin-quota.html
LayoutTests/http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-1.html [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-1.manifest [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-2.html [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-2.manifest [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/quota-origin-continued-download.html [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/quota-origin-continued-download.manifest [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/quota-origin-iframe-3.manifest
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
LayoutTests/platform/wk2/Skipped
Source/WebCore/ChangeLog
Source/WebCore/loader/EmptyClients.h
Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
Source/WebCore/loader/appcache/ApplicationCacheGroup.h
Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp
Source/WebCore/loader/appcache/ApplicationCacheStorage.h
Source/WebCore/page/ChromeClient.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/ChromeClientImpl.cpp
Source/WebKit/chromium/src/ChromeClientImpl.h
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp
Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
Source/WebKit/haiku/ChangeLog
Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.cpp
Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/DefaultDelegates/WebDefaultUIDelegate.m
Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKit/mac/WebView/WebUIDelegatePrivate.h
Source/WebKit/qt/Api/qwebpage.cpp
Source/WebKit/qt/Api/qwebpage.h
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/win/WebCoreSupport/WebChromeClient.h
Source/WebKit/wince/ChangeLog
Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.cpp
Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h
Source/WebKit/wx/ChangeLog
Source/WebKit/wx/WebKitSupport/ChromeClientWx.cpp
Source/WebKit/wx/WebKitSupport/ChromeClientWx.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
Tools/ChangeLog
Tools/DumpRenderTree/LayoutTestController.cpp
Tools/DumpRenderTree/LayoutTestController.h
Tools/DumpRenderTree/mac/UIDelegate.mm
Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
Tools/DumpRenderTree/qt/DumpRenderTreeQt.h
Tools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
Tools/DumpRenderTree/qt/LayoutTestControllerQt.h