Title: [170320] trunk/Source/WebKit2
Revision
170320
Author
[email protected]
Date
2014-06-23 14:32:43 -0700 (Mon, 23 Jun 2014)

Log Message

[Cocoa] No way to grant storage quotas for web application cache
https://bugs.webkit.org/show_bug.cgi?id=134213

Reviewed by Anders Carlsson.

* UIProcess/API/APIUIClient.h:
(API::UIClient::reachedApplicationCacheOriginQuota): Added this new client function, with
a default implementation that calls the completion handler with the current quota.

* UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Declared a new delegate method.

* UIProcess/API/Cocoa/_WKSecurityOrigin.mm:
(-[_WKSecurityOrigin _initWithSecurityOrigin:WebCore::]): Changed the parameter into a const
reference, since we copy it.
* UIProcess/API/Cocoa/_WKSecurityOriginInternal.h:

* UIProcess/Cocoa/UIDelegate.h: Override API::UIClient::reachedApplicationCacheOriginQuota.
Added flag to m_delegateMethods struct for new delegate method.
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate): Set new flag in m_delegateMethods struct.
(WebKit::UIDelegate::UIClient::exceededDatabaseQuota): Updated for change in
_WKSecurityOrigin initializer.
(WebKit::UIDelegate::UIClient::reachedApplicationCacheOriginQuota): Added. Calls the new
delegate method.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::reachedApplicationCacheOriginQuota): Added. Forwards the message to
the UI client.
* UIProcess/WebPageProxy.h:

* UIProcess/WebPageProxy.messages.in: Added ReachedApplicationCacheOriginQuota message.

* WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h:
(API::InjectedBundle::PageUIClient::didReachApplicationCacheOriginQuota): Changed the return
type to bool, indicating whether the client handled the callback.

* WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
(WebKit::InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota): Return the
appropriate value.
* WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::reachedApplicationCacheOriginQuota): If the bundle client didn’t
handle the callback, send a message the the UI process, and update the quota with the reply.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (170319 => 170320)


--- trunk/Source/WebKit2/ChangeLog	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-23 21:32:43 UTC (rev 170320)
@@ -1,3 +1,50 @@
+2014-06-23  Dan Bernstein  <[email protected]>
+
+        [Cocoa] No way to grant storage quotas for web application cache
+        https://bugs.webkit.org/show_bug.cgi?id=134213
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::reachedApplicationCacheOriginQuota): Added this new client function, with
+        a default implementation that calls the completion handler with the current quota.
+
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Declared a new delegate method.
+
+        * UIProcess/API/Cocoa/_WKSecurityOrigin.mm:
+        (-[_WKSecurityOrigin _initWithSecurityOrigin:WebCore::]): Changed the parameter into a const
+        reference, since we copy it.
+        * UIProcess/API/Cocoa/_WKSecurityOriginInternal.h:
+
+        * UIProcess/Cocoa/UIDelegate.h: Override API::UIClient::reachedApplicationCacheOriginQuota.
+        Added flag to m_delegateMethods struct for new delegate method.
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::setDelegate): Set new flag in m_delegateMethods struct.
+        (WebKit::UIDelegate::UIClient::exceededDatabaseQuota): Updated for change in
+        _WKSecurityOrigin initializer.
+        (WebKit::UIDelegate::UIClient::reachedApplicationCacheOriginQuota): Added. Calls the new
+        delegate method.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::reachedApplicationCacheOriginQuota): Added. Forwards the message to
+        the UI client.
+        * UIProcess/WebPageProxy.h:
+
+        * UIProcess/WebPageProxy.messages.in: Added ReachedApplicationCacheOriginQuota message.
+
+        * WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h:
+        (API::InjectedBundle::PageUIClient::didReachApplicationCacheOriginQuota): Changed the return
+        type to bool, indicating whether the client handled the callback.
+
+        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
+        (WebKit::InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota): Return the
+        appropriate value.
+        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::reachedApplicationCacheOriginQuota): If the bundle client didn’t
+        handle the callback, send a message the the UI process, and update the quota with the reply.
+
 2014-06-23  Tim Horton  <[email protected]>
 
         [wk2] Synchronously wait a short time for a layer tree update after bringing a web view in-window

Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (170319 => 170320)


--- trunk/Source/WebKit2/UIProcess/API/APIUIClient.h	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/UIProcess/API/APIUIClient.h	2014-06-23 21:32:43 UTC (rev 170320)
@@ -115,6 +115,11 @@
         completionHandler(currentQuota);
     }
 
+    virtual void reachedApplicationCacheOriginQuota(WebKit::WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function<void (unsigned long long)> completionHandler)
+    {
+        completionHandler(currentQuota);
+    }
+
     virtual bool runOpenPanel(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebKit::WebOpenPanelParameters*, WebKit::WebOpenPanelResultListenerProxy*) { return false; }
     virtual bool decidePolicyForGeolocationPermissionRequest(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebKit::WebSecurityOrigin*, WebKit::GeolocationPermissionRequestProxy*) { return false; }
     virtual bool decidePolicyForNotificationPermissionRequest(WebKit::WebPageProxy*, WebKit::WebSecurityOrigin*, WebKit::NotificationPermissionRequest*) { return false; }

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (170319 => 170320)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h	2014-06-23 21:32:43 UTC (rev 170320)
@@ -39,6 +39,9 @@
 // FIXME: This should be handled by the WKWebsiteDataStore delegate.
 - (void)_webView:(WKWebView *)webView decideDatabaseQuotaForSecurityOrigin:(_WKSecurityOrigin *)securityOrigin currentQuota:(unsigned long long)currentQuota currentOriginUsage:(unsigned long long)currentOriginUsage currentDatabaseUsage:(unsigned long long)currentUsage expectedUsage:(unsigned long long)expectedUsage decisionHandler:(void (^)(unsigned long long newQuota))decisionHandler;
 
+// FIXME: This should be handled by the WKWebsiteDataStore delegate.
+- (void)_webView:(WKWebView *)webView decideWebApplicationCacheQuotaForSecurityOrigin:(_WKSecurityOrigin *)securityOrigin currentQuota:(unsigned long long)currentQuota totalBytesNeeded:(unsigned long long)totalBytesNeeded decisionHandler:(void (^)(unsigned long long newQuota))decisionHandler;
+
 - (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame;
 
 #if TARGET_OS_IPHONE

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKSecurityOrigin.mm (170319 => 170320)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKSecurityOrigin.mm	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKSecurityOrigin.mm	2014-06-23 21:32:43 UTC (rev 170320)
@@ -35,17 +35,12 @@
     RefPtr<WebCore::SecurityOrigin> _origin;
 }
 
-- (instancetype)_initWithSecurityOrigin:(PassRefPtr<WebCore::SecurityOrigin>)origin
+- (instancetype)_initWithSecurityOrigin:(const WebCore::SecurityOrigin&)origin
 {
     if (!(self = [super init]))
         return nil;
 
-    if (!origin) {
-        [self release];
-        return nil;
-    }
-
-    _origin = origin->isolatedCopy();
+    _origin = origin.isolatedCopy();
     return self;
 }
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKSecurityOriginInternal.h (170319 => 170320)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKSecurityOriginInternal.h	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKSecurityOriginInternal.h	2014-06-23 21:32:43 UTC (rev 170320)
@@ -35,7 +35,7 @@
 
 @interface _WKSecurityOrigin ()
 
-- (instancetype)_initWithSecurityOrigin:(PassRefPtr<WebCore::SecurityOrigin>)origin;
+- (instancetype)_initWithSecurityOrigin:(const WebCore::SecurityOrigin&)origin;
 
 @end
 

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h (170319 => 170320)


--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h	2014-06-23 21:32:43 UTC (rev 170320)
@@ -63,6 +63,7 @@
         virtual void runJavaScriptConfirm(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, std::function<void (bool)> completionHandler) override;
         virtual void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*, std::function<void (const WTF::String&)> completionHandler) override;
         virtual void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, const WTF::String& databaseName, const WTF::String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentUsage, unsigned long long expectedUsage, std::function<void (unsigned long long)>) override;
+        virtual void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function<void (unsigned long long)> completionHandler) override;
         virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) override;
     #if PLATFORM(IOS)
         virtual RetainPtr<NSArray> actionsForElement(_WKActivatedElementInfo *, RetainPtr<NSArray> defaultActions) override;
@@ -82,6 +83,7 @@
         bool webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler : 1;
         bool webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler : 1;
         bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
+        bool webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded : 1;
         bool webViewPrintFrame : 1;
 #if PLATFORM(IOS)
         bool webViewActionsForElementDefaultActions : 1;

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm (170319 => 170320)


--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm	2014-06-23 21:32:43 UTC (rev 170320)
@@ -69,6 +69,7 @@
     m_delegateMethods.webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)];
     m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)];
     m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
+    m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded = [delegate respondsToSelector:@selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:)];
     m_delegateMethods.webViewPrintFrame = [delegate respondsToSelector:@selector(_webView:printFrame:)];
 #if PLATFORM(IOS)
     m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)];
@@ -187,12 +188,32 @@
     }
 
     RefPtr<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:));
-    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView decideDatabaseQuotaForSecurityOrigin:adoptNS([[_WKSecurityOrigin alloc] _initWithSecurityOrigin:&securityOrigin->securityOrigin()]).get() currentQuota:currentQuota currentOriginUsage:currentOriginUsage currentDatabaseUsage:currentUsage expectedUsage:expectedUsage decisionHandler:[completionHandler, checker](unsigned long long newQuota) {
+    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView decideDatabaseQuotaForSecurityOrigin:adoptNS([[_WKSecurityOrigin alloc] _initWithSecurityOrigin:securityOrigin->securityOrigin()]).get() currentQuota:currentQuota currentOriginUsage:currentOriginUsage currentDatabaseUsage:currentUsage expectedUsage:expectedUsage decisionHandler:[completionHandler, checker](unsigned long long newQuota) {
         checker->didCallCompletionHandler();
         completionHandler(newQuota);
     }];
 }
 
+void UIDelegate::UIClient::reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin& securityOrigin, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function<void (unsigned long long)> completionHandler)
+{
+    if (!m_uiDelegate.m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded) {
+        completionHandler(currentQuota);
+        return;
+    }
+
+    auto delegate = m_uiDelegate.m_delegate.get();
+    if (!delegate) {
+        completionHandler(currentQuota);
+        return;
+    }
+
+    RefPtr<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:));
+    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView decideWebApplicationCacheQuotaForSecurityOrigin:adoptNS([[_WKSecurityOrigin alloc] _initWithSecurityOrigin:securityOrigin]).get() currentQuota:currentQuota totalBytesNeeded:totalBytesNeeded decisionHandler:[completionHandler, checker](unsigned long long newQuota) {
+        checker->didCallCompletionHandler();
+        completionHandler(newQuota);
+    }];
+}
+
 void UIDelegate::UIClient::printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy* webFrameProxy)
 {
     ASSERT_ARG(webFrameProxy, webFrameProxy);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (170319 => 170320)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-06-23 21:32:43 UTC (rev 170320)
@@ -4464,6 +4464,14 @@
     }
 }
 
+void WebPageProxy::reachedApplicationCacheOriginQuota(const String& originIdentifier, uint64_t currentQuota, uint64_t totalBytesNeeded, PassRefPtr<Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::DelayedReply> reply)
+{
+    RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
+    MESSAGE_CHECK(securityOrigin);
+
+    m_uiClient->reachedApplicationCacheOriginQuota(this, *securityOrigin.get(), currentQuota, totalBytesNeeded, [reply](unsigned long long newQuota) { reply->send(newQuota); });
+}
+
 void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier)
 {
     WebFrameProxy* frame = m_process->webFrame(frameID);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (170319 => 170320)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-06-23 21:32:43 UTC (rev 170320)
@@ -1001,6 +1001,7 @@
     void runOpenPanel(uint64_t frameID, const WebCore::FileChooserSettings&);
     void printFrame(uint64_t frameID);
     void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply>);
+    void reachedApplicationCacheOriginQuota(const String& originIdentifier, uint64_t currentQuota, uint64_t totalBytesNeeded, PassRefPtr<Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::DelayedReply>);
     void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier);
     void runModal();
     void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (170319 => 170320)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2014-06-23 21:32:43 UTC (rev 170320)
@@ -241,6 +241,9 @@
     # Database messages
     ExceededDatabaseQuota(uint64_t frameID, String originIdentifier, String databaseName, String databaseDisplayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage) -> (uint64_t newQuota) Delayed
 
+    # Application cache messages
+    ReachedApplicationCacheOriginQuota(String originIdentifier, uint64_t currentQuota, uint64_t totalBytesNeeded) -> (uint64_t newQuota) Delayed
+
     # Geolocation messages
     RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier)
     

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h (170319 => 170320)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h	2014-06-23 21:32:43 UTC (rev 170320)
@@ -69,7 +69,7 @@
     virtual UIElementVisibility menuBarIsVisible(WebKit::WebPage*) { return UIElementVisibility::Unknown; }
     virtual UIElementVisibility toolbarsAreVisible(WebKit::WebPage*) { return UIElementVisibility::Unknown; }
 
-    virtual void didReachApplicationCacheOriginQuota(WebKit::WebPage*, WebKit::WebSecurityOrigin*, int64_t totalBytesNeeded) { UNUSED_PARAM(totalBytesNeeded); }
+    virtual bool didReachApplicationCacheOriginQuota(WebKit::WebPage*, WebKit::WebSecurityOrigin*, int64_t totalBytesNeeded) { UNUSED_PARAM(totalBytesNeeded); return false; }
     virtual uint64_t didExceedDatabaseQuota(WebKit::WebPage*, WebKit::WebSecurityOrigin*, const WTF::String& databaseName, const WTF::String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes)
     {
         UNUSED_PARAM(databaseName);

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp (170319 => 170320)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp	2014-06-23 21:32:43 UTC (rev 170320)
@@ -146,12 +146,13 @@
     return toUIElementVisibility(m_client.toolbarsAreVisible(toAPI(page), m_client.base.clientInfo));
 }
 
-void InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota(WebPage* page, WebSecurityOrigin* origin, int64_t totalBytesNeeded)
+bool InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota(WebPage* page, WebSecurityOrigin* origin, int64_t totalBytesNeeded)
 {
     if (!m_client.didReachApplicationCacheOriginQuota)
-        return;
+        return false;
 
     m_client.didReachApplicationCacheOriginQuota(toAPI(page), toAPI(origin), totalBytesNeeded, m_client.base.clientInfo);
+    return true;
 }
 
 uint64_t InjectedBundlePageUIClient::didExceedDatabaseQuota(WebPage* page, WebSecurityOrigin* origin, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes)

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h (170319 => 170320)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h	2014-06-23 21:32:43 UTC (rev 170320)
@@ -62,7 +62,7 @@
     UIElementVisibility menuBarIsVisible(WebPage*) override;
     UIElementVisibility toolbarsAreVisible(WebPage*) override;
 
-    void didReachApplicationCacheOriginQuota(WebPage*, WebSecurityOrigin*, int64_t totalBytesNeeded) override;
+    bool didReachApplicationCacheOriginQuota(WebPage*, WebSecurityOrigin*, int64_t totalBytesNeeded) override;
     uint64_t didExceedDatabaseQuota(WebPage*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes) override;
 
     String plugInStartLabelTitle(const String& mimeType) const override;

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (170319 => 170320)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2014-06-23 21:32:03 UTC (rev 170319)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2014-06-23 21:32:43 UTC (rev 170320)
@@ -49,6 +49,7 @@
 #include "WebProcessProxyMessages.h"
 #include "WebSearchPopupMenu.h"
 #include "WebSecurityOrigin.h"
+#include <WebCore/ApplicationCacheStorage.h>
 #include <WebCore/AXObjectCache.h>
 #include <WebCore/ColorChooser.h>
 #include <WebCore/DatabaseManager.h>
@@ -674,7 +675,23 @@
 void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin* origin, int64_t totalBytesNeeded)
 {
     RefPtr<WebSecurityOrigin> webSecurityOrigin = WebSecurityOrigin::createFromString(origin->toString());
-    m_page->injectedBundleUIClient().didReachApplicationCacheOriginQuota(m_page, webSecurityOrigin.get(), totalBytesNeeded);
+    if (m_page->injectedBundleUIClient().didReachApplicationCacheOriginQuota(m_page, webSecurityOrigin.get(), totalBytesNeeded))
+        return;
+
+    unsigned syncSendFlags = IPC::InformPlatformProcessWillSuspend;
+    if (WebPage::synchronousMessagesShouldSpinRunLoop())
+        syncSendFlags |= IPC::SpinRunLoopWhileWaitingForReply;
+
+    int64_t currentQuota = 0;
+    if (!cacheStorage().calculateQuotaForOrigin(origin, currentQuota))
+        return;
+
+    uint64_t newQuota = 0;
+    WebProcess::shared().parentProcessConnection()->sendSync(
+        Messages::WebPageProxy::ReachedApplicationCacheOriginQuota(origin->databaseIdentifier(), currentQuota, totalBytesNeeded),
+        Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::Reply(newQuota), m_page->pageID(), std::chrono::milliseconds::max(), syncSendFlags);
+
+    cacheStorage().storeUpdatedQuotaForOrigin(origin, newQuota);
 }
 
 #if ENABLE(DASHBOARD_SUPPORT)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to