WebKit Bugzilla
Attachment 358810 Details for
Bug 193323
: Add a new SPI to request for cache storage quota increase
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193323-20190110112242.patch (text/plain), 34.42 KB, created by
youenn fablet
on 2019-01-10 11:22:43 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-01-10 11:22:43 PST
Size:
34.42 KB
patch
obsolete
>Subversion Revision: 239787 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 561f8543621eee097bb9f3fe3b4a07242d8d9c84..e3cec7c5ed64bb1d528944e374485abdd73ccf8b 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,37 @@ >+2019-01-10 Youenn Fablet <youenn@apple.com> >+ >+ Add a new SPI to request for cache storage quota increase >+ https://bugs.webkit.org/show_bug.cgi?id=193323 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a delegate on the WebSiteDataStore for WebKit to ask for quota update. >+ The current SPI is currently CacheStorage specific but future work should >+ make it so that other storage like IDB use the same mechanism. >+ By default, quota remains unchanged if delegate is not implemented. >+ >+ * NetworkProcess/NetworkProcess.cpp: >+ * UIProcess/API/Cocoa/WKStorageQuotaDelegatePrivate.h: Added. >+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: >+ (WebsiteDataStoreQuotaManager::WebsiteDataStoreQuotaManager): >+ (-[WKWebsiteDataStore _quotaDelegate]): >+ (-[WKWebsiteDataStore set_quotaDelegate:]): >+ * UIProcess/API/Cocoa/WKWebsiteDataStoreInternal.h: >+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h: >+ * UIProcess/Network/NetworkProcessProxy.cpp: >+ (WebKit::NetworkProcessProxy::requestCacheStorageSpace): >+ * UIProcess/WebsiteData/DataStoreQuotaManager.h: Added. >+ (WebKit::DataStoreQuotaManager::requestCacheStorageSpace): >+ * UIProcess/WebsiteData/WebsiteDataStore.cpp: >+ (WebKit::WebsiteDataStore::WebsiteDataStore): >+ * UIProcess/WebsiteData/WebsiteDataStore.h: >+ (WebKit::WebsiteDataStore::quotaManager): >+ (WebKit::WebsiteDataStore::setQuotaManager): >+ * UIProcess/WebsiteData/WebsiteDataStoreQuotaManager.h: Added. >+ (WebKit::WebsiteDataStoreQuotaManager::~WebsiteDataStoreQuotaManager): >+ (WebKit::WebsiteDataStoreQuotaManager::requestCacheStorageSpace): >+ * WebKit.xcodeproj/project.pbxproj: >+ > 2019-01-09 Youenn Fablet <youenn@apple.com> > > Pipe cache quota request from Network Process to UIProcess >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index b076bd0727a6929fac7df8ed622de80151a57df7..66be83f7e84ce89a8f4b86b9887488c5d981f1c7 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -63,7 +63,6 @@ > #include "WebsiteDataStore.h" > #include "WebsiteDataStoreParameters.h" > #include "WebsiteDataType.h" >-#include <WebCore/ClientOrigin.h> > #include <WebCore/DNS.h> > #include <WebCore/DeprecatedGlobalSettings.h> > #include <WebCore/DiagnosticLoggingClient.h> >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKStorageQuotaDelegatePrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKStorageQuotaDelegatePrivate.h >new file mode 100644 >index 0000000000000000000000000000000000000000..92e1f0cf42fa7866f48da7d7810271641f21ac47 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKStorageQuotaDelegatePrivate.h >@@ -0,0 +1,40 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import <WebKit/WKFoundation.h> >+ >+#if WK_API_ENABLED >+ >+#import <Foundation/Foundation.h> >+ >+@protocol WKStorageQuotaDelegatePrivate <NSObject> >+ >+@optional >+ >+- (void)_requestCacheStorageSpace:(NSURL *)mainFrameURL frameOrigin:(NSURL *)frameURL quota:(NSUInteger)quota currentSize:(NSUInteger)currentSize spaceRequired:(NSUInteger)spaceRequired decisionHandler:(void (^)(unsigned long long quota))decisionHandler; >+ >+@end >+ >+#endif >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >index 2d160ea3b1288fe84dc1d8293c0a328381feb26a..b08800d43e4ef6186f6e4f1546341d19c161473d 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >@@ -29,8 +29,10 @@ > #if WK_API_ENABLED > > #import "APIString.h" >+#import "CompletionHandlerCallChecker.h" > #import "WKHTTPCookieStoreInternal.h" > #import "WKNSArray.h" >+#import "WKStorageQuotaDelegatePrivate.h" > #import "WKWebViewInternal.h" > #import "WKWebsiteDataRecordInternal.h" > #import "WebPageProxy.h" >@@ -42,6 +44,39 @@ > #import <wtf/BlockPtr.h> > #import <wtf/URL.h> > >+class WebsiteDataStoreQuotaManager : public WebKit::WebsiteDataStoreQuotaManager { >+public: >+ explicit WebsiteDataStoreQuotaManager(id <WKStorageQuotaDelegatePrivate> delegate) >+ : m_quotaDelegate(delegate) >+ { >+ m_hasRequestCacheStorageSpaceSelector = [m_quotaDelegate.get() respondsToSelector:@selector(_requestCacheStorageSpace: frameOrigin: quota: currentSize: spaceRequired: decisionHandler:)]; >+ } >+private: >+ void requestCacheStorageSpace(const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& frameOrigin, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired, WTF::CompletionHandler<void(Optional<uint64_t>)>&& completionHandler) final >+ { >+ if (!m_hasRequestCacheStorageSpaceSelector) { >+ completionHandler({ }); >+ return; >+ } >+ >+ auto checker = WebKit::CompletionHandlerCallChecker::create(m_quotaDelegate.get(), @selector(_requestCacheStorageSpace: frameOrigin: quota: currentSize: spaceRequired: decisionHandler:)); >+ auto decisionHandler = makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)](unsigned long long quota) mutable { >+ if (checker->completionHandlerHasBeenCalled()) >+ return; >+ checker->didCallCompletionHandler(); >+ completionHandler(quota); >+ }); >+ >+ URL mainFrameURL(URL(), topOrigin.toString()); >+ URL frameURL(URL(), frameOrigin.toString()); >+ >+ [m_quotaDelegate.get() _requestCacheStorageSpace:mainFrameURL frameOrigin:frameURL quota:quota currentSize:currentSize spaceRequired:spaceRequired decisionHandler:decisionHandler.get()]; >+ } >+ >+ RetainPtr<id <WKStorageQuotaDelegatePrivate> > m_quotaDelegate; >+ bool m_hasRequestCacheStorageSpaceSelector { false }; >+}; >+ > @implementation WKWebsiteDataStore > > + (WKWebsiteDataStore *)defaultDataStore >@@ -383,6 +418,17 @@ - (bool)_hasRegisteredServiceWorker > return WebKit::ServiceWorkerProcessProxy::hasRegisteredServiceWorkers(_websiteDataStore->websiteDataStore().serviceWorkerRegistrationDirectory()); > } > >+- (id <WKStorageQuotaDelegatePrivate>)_quotaDelegate >+{ >+ return _quotaDelegate.get(); >+} >+ >+- (void)set_quotaDelegate:(id <WKStorageQuotaDelegatePrivate>)quotaDelegate >+{ >+ _quotaDelegate = quotaDelegate; >+ _websiteDataStore->websiteDataStore().setQuotaManager(makeUniqueRef<WebsiteDataStoreQuotaManager>(quotaDelegate)); >+} >+ > @end > > #endif // WK_API_ENABLED >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStoreInternal.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStoreInternal.h >index d861875273ba7df67e2866d1455b96b7f3dc47f6..e31f3b67fb3890b92e3cb92a506a1ee92118443e 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStoreInternal.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStoreInternal.h >@@ -41,6 +41,7 @@ template<> struct WrapperTraits<API::WebsiteDataStore> { > @interface WKWebsiteDataStore () <WKObject> { > @package > API::ObjectStorage<API::WebsiteDataStore> _websiteDataStore; >+ RetainPtr<id <WKStorageQuotaDelegatePrivate> > _quotaDelegate; > } > @end > >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h >index 74a8a02f2f1d9ee95c97af9a96e3c60131920161..ad04ce88a9b445a2048178bd951e7da0a2a61663 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h >@@ -32,6 +32,8 @@ NS_ASSUME_NONNULL_BEGIN > @class _WKWebsiteDataStoreConfiguration; > @class WKWebView; > >+@protocol WKStorageQuotaDelegatePrivate; >+ > typedef NS_OPTIONS(NSUInteger, _WKWebsiteDataStoreFetchOptions) { > _WKWebsiteDataStoreFetchOptionComputeSizes = 1 << 0, > } WK_API_AVAILABLE(macosx(10.12), ios(10.0)); >@@ -62,6 +64,9 @@ typedef NS_OPTIONS(NSUInteger, _WKWebsiteDataStoreFetchOptions) { > + (void)_allowWebsiteDataRecordsForAllOrigins WK_API_AVAILABLE(macosx(10.13.4), ios(11.3)); > - (bool)_hasRegisteredServiceWorker WK_API_AVAILABLE(macosx(10.14), ios(12.0)); > >+/*! @abstract The storage quota delegate. */ >+@property (nullable, nonatomic, weak) id <WKStorageQuotaDelegatePrivate> _quotaDelegate WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+ > @end > > NS_ASSUME_NONNULL_END >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >index 147db552d8d763a6b620b636b85570c9fc714a1c..fb427a1607978bf1ebbf3d06ac539c01f2de3c87 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >@@ -43,6 +43,8 @@ > #include "WebProcessPool.h" > #include "WebUserContentControllerProxy.h" > #include "WebsiteData.h" >+#include "WebsiteDataStoreQuotaManager.h" >+#include <WebCore/ClientOrigin.h> > #include <wtf/CompletionHandler.h> > > #if ENABLE(SEC_ITEM_SHIM) >@@ -728,7 +730,7 @@ void NetworkProcessProxy::establishWorkerContextConnectionToNetworkProcessForExp > } > #endif > >-void NetworkProcessProxy::requestCacheStorageSpace(PAL::SessionID sessionID, WebCore::DOMCacheQuotaExtensionRequestIdentifier requestIdentifier, const WebCore::ClientOrigin&, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired) >+void NetworkProcessProxy::requestCacheStorageSpace(PAL::SessionID sessionID, WebCore::DOMCacheQuotaExtensionRequestIdentifier requestIdentifier, const WebCore::ClientOrigin& origin, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired) > { > auto* store = websiteDataStoreFromSessionID(sessionID); > >@@ -737,8 +739,9 @@ void NetworkProcessProxy::requestCacheStorageSpace(PAL::SessionID sessionID, Web > return; > } > >- // FIXME: Ask WebsiteDataStore about updating the quota for this origin. >- send(Messages::NetworkProcess::RequestCacheStorageSpaceCompleted { sessionID, requestIdentifier, quota }, 0); >+ store->quotaManager().requestCacheStorageSpace(origin.topOrigin, origin.clientOrigin, quota, currentSize, spaceRequired, [connection = makeRef(*connection()), sessionID, requestIdentifier] (Optional<uint64_t> quota) mutable { >+ connection->send(Messages::NetworkProcess::RequestCacheStorageSpaceCompleted { sessionID, requestIdentifier, quota }, 0); >+ }); > } > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/WebsiteData/DataStoreQuotaManager.h b/Source/WebKit/UIProcess/WebsiteData/DataStoreQuotaManager.h >new file mode 100644 >index 0000000000000000000000000000000000000000..82900397e3d318b7dd71580b2e6e71793c2d8c3e >--- /dev/null >+++ b/Source/WebKit/UIProcess/WebsiteData/DataStoreQuotaManager.h >@@ -0,0 +1,46 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/CompletionHandler.h> >+ >+namespace WebCore { >+class SecurityOriginData; >+} >+ >+namespace WebKit { >+ >+class DataStoreQuotaManager { >+public: >+private: >+ class WebsiteDat >+ virtual void requestCacheStorageSpace(const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& frameOrigin, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired, WTF::CompletionHandler<void(Optional<uint64_t>)>&& completionHandler) >+ { >+ completionHandler({ }); >+ } >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >index 4d7f5114f828cbf3e50e2e5138709b276bcb5262..659aee1b23a62cf6ef04274d99fd26af629abce1 100644 >--- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >+++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >@@ -33,6 +33,7 @@ > #include "DeviceIdHashSaltStorage.h" > #include "MockAuthenticatorManager.h" > #include "NetworkProcessMessages.h" >+#include "WebsiteDataStoreQuotaManager.h" > #include "StorageManager.h" > #include "WebCookieManagerProxy.h" > #include "WebProcessMessages.h" >@@ -97,6 +98,7 @@ WebsiteDataStore::WebsiteDataStore(Ref<WebsiteDataStoreConfiguration>&& configur > #if ENABLE(WEB_AUTHN) > , m_authenticatorManager(makeUniqueRef<AuthenticatorManager>()) > #endif >+ , m_quotaManager(makeUniqueRef<WebsiteDataStoreQuotaManager>()) > { > WTF::setProcessPrivileges(allPrivileges()); > maybeRegisterWithSessionIDMap(); >@@ -113,6 +115,7 @@ WebsiteDataStore::WebsiteDataStore(PAL::SessionID sessionID) > #if ENABLE(WEB_AUTHN) > , m_authenticatorManager(makeUniqueRef<AuthenticatorManager>()) > #endif >+ , m_quotaManager(makeUniqueRef<WebsiteDataStoreQuotaManager>()) > { > maybeRegisterWithSessionIDMap(); > platformInitialize(); >diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >index 7c5343e2158594079c2086829c09bbf7bd13cc2d..4994e8951fceea74ba104e65bce0f5290f2eb61b 100644 >--- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >+++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >@@ -28,6 +28,7 @@ > #include "NetworkSessionCreationParameters.h" > #include "WebProcessLifetimeObserver.h" > #include "WebsiteDataStoreConfiguration.h" >+#include "WebsiteDataStoreQuotaManager.h" > #include <WebCore/Cookie.h> > #include <WebCore/SecurityOriginData.h> > #include <WebCore/SecurityOriginHash.h> >@@ -58,6 +59,7 @@ class SecurityOrigin; > namespace WebKit { > > class AuthenticatorManager; >+class WebsiteDataStoreQuotaManager; > class SecKeyProxyStore; > class StorageManager; > class DeviceIdHashSaltStorage; >@@ -188,6 +190,9 @@ public: > > const WebsiteDataStoreConfiguration& configuration() { return m_configuration.get(); } > >+ WebsiteDataStoreQuotaManager& quotaManager() { return m_quotaManager.get(); } >+ void setQuotaManager(UniqueRef<WebsiteDataStoreQuotaManager>&& manager) { m_quotaManager = WTFMove(manager); } >+ > private: > explicit WebsiteDataStore(PAL::SessionID); > explicit WebsiteDataStore(Ref<WebsiteDataStoreConfiguration>&&, PAL::SessionID); >@@ -256,6 +261,8 @@ private: > #if ENABLE(WEB_AUTHN) > UniqueRef<AuthenticatorManager> m_authenticatorManager; > #endif >+ >+ UniqueRef<WebsiteDataStoreQuotaManager> m_quotaManager; > }; > > } >diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreQuotaManager.h b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreQuotaManager.h >new file mode 100644 >index 0000000000000000000000000000000000000000..204ab4a7cf62cbf8bd824ea5d0b6f5bbdf18ee4b >--- /dev/null >+++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreQuotaManager.h >@@ -0,0 +1,46 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/CompletionHandler.h> >+ >+namespace WebCore { >+struct SecurityOriginData; >+} >+ >+namespace WebKit { >+ >+class WebsiteDataStoreQuotaManager { >+public: >+ virtual ~WebsiteDataStoreQuotaManager() { } >+ >+ virtual void requestCacheStorageSpace(const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& frameOrigin, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired, WTF::CompletionHandler<void(Optional<uint64_t>)>&& completionHandler) >+ { >+ completionHandler({ }); >+ } >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 9c8251783263418a871e5e9b3387454391567e00..3d24851cce3bdecbdd559c06ef47f574f4864f8e 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -862,6 +862,7 @@ > 4112EDDE20E407A500BEA92A /* com.cfca.npSecEditCtl.MAC.BOC.plugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 4112EDD320E4077400BEA92A /* com.cfca.npSecEditCtl.MAC.BOC.plugin.sb */; }; > 4112EDDF20E407A500BEA92A /* com.cmbchina.CMBSecurity.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 4112EDD520E4077400BEA92A /* com.cmbchina.CMBSecurity.sb */; }; > 4112EDE020E407A500BEA92A /* com.ftsafe.NPAPI-Core-Safe-SoftKeybaord.plugin.rfc1034identifier.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 4112EDD220E4077300BEA92A /* com.ftsafe.NPAPI-Core-Safe-SoftKeybaord.plugin.rfc1034identifier.sb */; }; >+ 4118DC1F21E7BF5D00DE04C7 /* WKStorageQuotaDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 4118DC1D21E6DD2700DE04C7 /* WKStorageQuotaDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 411A8DDB20DDD1AC0060D34F /* WKMockMediaDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 411A8DD920DDB6050060D34F /* WKMockMediaDevice.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 411B22641E371BA6004F7363 /* LibWebRTCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 411B22621E371244004F7363 /* LibWebRTCNetwork.h */; }; > 413075AB1DE85F330039EC69 /* NetworkRTCSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075991DE84FB00039EC69 /* NetworkRTCSocket.h */; }; >@@ -3012,6 +3013,9 @@ > 4112EDD720E4077500BEA92A /* com.apple.NPSafeSubmit.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.NPSafeSubmit.sb; sourceTree = "<group>"; }; > 4112EDD820E4077500BEA92A /* com.apple.NPSafeInput.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.NPSafeInput.sb; sourceTree = "<group>"; }; > 4112EDD920E4077500BEA92A /* com.apple.BocomSubmitCtrl.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.BocomSubmitCtrl.sb; sourceTree = "<group>"; }; >+ 4118DC1B21E6D11A00DE04C7 /* WebsiteDataStoreQuotaManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsiteDataStoreQuotaManager.h; sourceTree = "<group>"; }; >+ 4118DC1C21E6D35B00DE04C7 /* DataStoreQuotaManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataStoreQuotaManager.h; sourceTree = "<group>"; }; >+ 4118DC1D21E6DD2700DE04C7 /* WKStorageQuotaDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKStorageQuotaDelegatePrivate.h; sourceTree = "<group>"; }; > 411A8DD920DDB6050060D34F /* WKMockMediaDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKMockMediaDevice.h; sourceTree = "<group>"; }; > 411A8DDA20DDB6050060D34F /* WKMockMediaDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKMockMediaDevice.cpp; sourceTree = "<group>"; }; > 411B22621E371244004F7363 /* LibWebRTCNetwork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCNetwork.h; path = Network/webrtc/LibWebRTCNetwork.h; sourceTree = "<group>"; }; >@@ -4870,6 +4874,8 @@ > isa = PBXGroup; > children = ( > 1A4832C01A965A33008B4DFE /* Cocoa */, >+ 4118DC1C21E6D35B00DE04C7 /* DataStoreQuotaManager.h */, >+ 4118DC1B21E6D11A00DE04C7 /* WebsiteDataStoreQuotaManager.h */, > 1A4832D81A9D1FD2008B4DFE /* WebsiteDataRecord.cpp */, > 1A4832CF1A9BD821008B4DFE /* WebsiteDataRecord.h */, > 1A53C2A41A32569F004E8C70 /* WebsiteDataStore.cpp */, >@@ -6164,6 +6170,7 @@ > 51CD1C611B34B9C900142CA5 /* WKSecurityOriginInternal.h */, > 93F549B31E3174B7000E7239 /* WKSnapshotConfiguration.h */, > 93F549B51E3174DA000E7239 /* WKSnapshotConfiguration.mm */, >+ 4118DC1D21E6DD2700DE04C7 /* WKStorageQuotaDelegatePrivate.h */, > 1AD8790918B6C38A006CAFD7 /* WKUIDelegate.h */, > 3743925718BC4C60001C8675 /* WKUIDelegatePrivate.h */, > 51D1242D1E6DDDD7002B2820 /* WKURLSchemeHandler.h */, >@@ -9929,6 +9936,7 @@ > 1F7506B51859165400EC0FF7 /* WKWebProcessPlugInScriptWorldInternal.h in Headers */, > 1A4832CC1A9BC465008B4DFE /* WKWebsiteDataRecord.h in Headers */, > 1A4832CE1A9BC484008B4DFE /* WKWebsiteDataRecordInternal.h in Headers */, >+ 4118DC1F21E7BF5D00DE04C7 /* WKStorageQuotaDelegatePrivate.h in Headers */, > 1AA654D11B14F71400BF1D3E /* WKWebsiteDataRecordPrivate.h in Headers */, > 75A8D2C8187CCFAB00C39C9E /* WKWebsiteDataStore.h in Headers */, > 75A8D2D6187D1C0E00C39C9E /* WKWebsiteDataStoreInternal.h in Headers */, >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index dac4e62334e49a9551de4736118084ab527250bd..dff614e17a094eb68c27cbf912f3ff33c2f97337 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,30 @@ >+2019-01-10 Youenn Fablet <youenn@apple.com> >+ >+ Add a new SPI to request for cache storage quota increase >+ https://bugs.webkit.org/show_bug.cgi?id=193323 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement WebsiteDataStore quota delegate to handle quota requests. >+ By default, do not update quota. >+ Update quota if test calls the new testRunner.allowCacheStorageQuotaIncrease method. >+ >+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: >+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp: >+ (WTR::TestRunner::allowCacheStorageQuotaIncrease): >+ * WebKitTestRunner/InjectedBundle/TestRunner.h: >+ * WebKitTestRunner/TestController.cpp: >+ (WTR::TestController::allowCacheStorageQuotaIncrease): >+ * WebKitTestRunner/TestController.h: >+ * WebKitTestRunner/TestInvocation.cpp: >+ (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): >+ * WebKitTestRunner/cocoa/TestControllerCocoa.mm: >+ (-[CacheStorageQuotaManager init]): >+ (-[CacheStorageQuotaManager _requestCacheStorageSpace:frameOrigin:quota:currentSize:spaceRequired:decisionHandler:]): >+ (WTR::initializeWebViewConfiguration): >+ (WTR::TestController::cocoaResetStateToConsistentValues): >+ (WTR::TestController::allowCacheStorageQuotaIncrease): >+ > 2019-01-09 Aakash Jain <aakash_jain@apple.com> > > [ews-build] Add link to bug along with bug title >diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >index da022c4f0c7692e7c6df4d62e4596f189eadbc5e..24748772f02325628967e5dde106859dec422255 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >+++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >@@ -62,6 +62,7 @@ interface TestRunner { > void clearDOMCache(DOMString origin); > boolean hasDOMCache(DOMString origin); > unsigned long domCacheSize(DOMString origin); >+ void allowCacheStorageQuotaIncrease(); > > // Special options. > void keepWebHistory(); >diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >index 24d340f006ed58c30f5c7138901186658a152c23..9aa7be8cb7f22496aebdb93c027edc158f4518c1 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >@@ -2358,6 +2358,12 @@ uint64_t TestRunner::domCacheSize(JSStringRef origin) > return WKUInt64GetValue(static_cast<WKUInt64Ref>(returnData)); > } > >+void TestRunner::allowCacheStorageQuotaIncrease() >+{ >+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("AllowCacheStorageQuotaIncrease")); >+ WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr); >+} >+ > void TestRunner::getApplicationManifestThen(JSValueRef callback) > { > cacheTestRunnerCallback(GetApplicationManifestCallbackID, callback); >diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >index 120efc8263ec77249b3b0d7da61476a3c8a7af17..0e513d3e839c201f9d48604a762df10c241efb46 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >@@ -175,6 +175,7 @@ public: > void clearDOMCaches(); > bool hasDOMCache(JSStringRef origin); > uint64_t domCacheSize(JSStringRef origin); >+ void allowCacheStorageQuotaIncrease(); > > // IndexedDB > void setIDBPerOriginQuota(uint64_t); >diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp >index 6d4dffb49656524c64d962e79fe238384c69c0c6..dc84b95df387bdadfd9b516ede16dc06c6e2f355 100644 >--- a/Tools/WebKitTestRunner/TestController.cpp >+++ b/Tools/WebKitTestRunner/TestController.cpp >@@ -2828,6 +2828,13 @@ uint64_t TestController::domCacheSize(WKStringRef origin) > return context.result; > } > >+#if !PLATFORM(COCOA) >+void TestController::allowCacheStorageQuotaIncrease() >+{ >+ // FIXME: To implement. >+} >+#endif >+ > struct ResourceStatisticsCallbackContext { > explicit ResourceStatisticsCallbackContext(TestController& controller) > : testController(controller) >diff --git a/Tools/WebKitTestRunner/TestController.h b/Tools/WebKitTestRunner/TestController.h >index 13a39c6905f0d87ba87b9db57f8dad5c17ac71bc..1425cbfd51a7604ae10c57944557aa06a20eac80 100644 >--- a/Tools/WebKitTestRunner/TestController.h >+++ b/Tools/WebKitTestRunner/TestController.h >@@ -248,6 +248,7 @@ public: > void clearDOMCaches(); > bool hasDOMCache(WKStringRef origin); > uint64_t domCacheSize(WKStringRef origin); >+ void allowCacheStorageQuotaIncrease(); > > void setIDBPerOriginQuota(uint64_t); > >diff --git a/Tools/WebKitTestRunner/TestInvocation.cpp b/Tools/WebKitTestRunner/TestInvocation.cpp >index 1a91eb28434d4ed7d1b961220063850540ad782b..be5dda39732cd856487e2abd04555fa33dbb9f42 100644 >--- a/Tools/WebKitTestRunner/TestInvocation.cpp >+++ b/Tools/WebKitTestRunner/TestInvocation.cpp >@@ -1420,6 +1420,11 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB > return result; > } > >+ if (WKStringIsEqualToUTF8CString(messageName, "AllowCacheStorageQuotaIncrease")) { >+ TestController::singleton().allowCacheStorageQuotaIncrease(); >+ return nullptr; >+ } >+ > if (WKStringIsEqualToUTF8CString(messageName, "SetIDBPerOriginQuota")) { > ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID()); > WKUInt64Ref quota = static_cast<WKUInt64Ref>(messageBody); >diff --git a/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm b/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm >index 11b0e3ae34fbbe7e1ba9e1721a4d118d33026796..ab76d5b52963abecf33f8916e5d2d1b874132661 100644 >--- a/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm >+++ b/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm >@@ -37,6 +37,7 @@ > #import <WebKit/WKCookieManager.h> > #import <WebKit/WKPreferencesRefPrivate.h> > #import <WebKit/WKProcessPoolPrivate.h> >+#import <WebKit/WKStorageQuotaDelegatePrivate.h> > #import <WebKit/WKStringCF.h> > #import <WebKit/WKUserContentControllerPrivate.h> > #import <WebKit/WKWebView.h> >@@ -51,10 +52,40 @@ > #import <WebKit/_WKUserContentExtensionStorePrivate.h> > #import <wtf/MainThread.h> > >+ >+#if WK_API_ENABLED >+ >+@interface CacheStorageQuotaManager: NSObject <WKStorageQuotaDelegatePrivate> { >+@public >+ BOOL shouldAllowRaisingQuota; >+} >+- (instancetype)init; >+@end >+ >+@implementation CacheStorageQuotaManager { } >+- (instancetype)init >+{ >+ shouldAllowRaisingQuota = false; >+ return self; >+} >+ >+- (void)_requestCacheStorageSpace:(NSURL *)mainFrameURL frameOrigin:(NSURL *)frameURL quota:(NSUInteger)quota currentSize:(NSUInteger)currentSize spaceRequired:(NSUInteger)spaceRequired decisionHandler:(void (^)(unsigned long long quota))decisionHandler >+{ >+ decisionHandler(shouldAllowRaisingQuota ? 2 * quota : quota); >+} >+ >+@end >+ >+#endif >+ > namespace WTR { > > static WKWebViewConfiguration *globalWebViewConfiguration; > >+#if WK_API_ENABLED >+static CacheStorageQuotaManager *globalCacheStorageQuotaManager; >+#endif >+ > void initializeWebViewConfiguration(const char* libraryPath, WKStringRef injectedBundlePath, WKContextRef context, WKContextConfigurationRef contextConfiguration) > { > #if WK_API_ENABLED >@@ -80,6 +111,12 @@ void initializeWebViewConfiguration(const char* libraryPath, WKStringRef injecte > [globalWebViewConfiguration.websiteDataStore _setResourceLoadStatisticsEnabled:YES]; > [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetShouldSubmitTelemetry:NO]; > >+#if WK_API_ENABLED >+ [globalCacheStorageQuotaManager release]; >+ globalCacheStorageQuotaManager = [[CacheStorageQuotaManager alloc] init]; >+ [globalWebViewConfiguration.websiteDataStore set_quotaDelegate:globalCacheStorageQuotaManager]; >+#endif >+ > #if PLATFORM(IOS_FAMILY) > globalWebViewConfiguration.allowsInlineMediaPlayback = YES; > globalWebViewConfiguration._inlineMediaPlaybackRequiresPlaysInlineAttribute = NO; >@@ -249,6 +286,8 @@ void TestController::cocoaResetStateToConsistentValues(const TestOptions& option > if (options.shouldShowSpellCheckingDots) > [platformView toggleContinuousSpellChecking:nil]; > } >+ >+ globalCacheStorageQuotaManager->shouldAllowRaisingQuota = false; > #endif > } > >@@ -382,4 +421,11 @@ bool TestController::keyExistsInKeychain(const String& attrLabel, const String& > return false; > } > >+void TestController::allowCacheStorageQuotaIncrease() >+{ >+#if WK_API_ENABLED >+ globalCacheStorageQuotaManager->shouldAllowRaisingQuota = true; >+#endif >+} >+ > } // namespace WTR >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 9c1c3ba62de4622d5de7e41ef7af961e7de5e138..ce6518df553c3256490af9f4f6f8dd6264df70f9 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2019-01-10 Youenn Fablet <youenn@apple.com> >+ >+ Add a new SPI to request for cache storage quota increase >+ https://bugs.webkit.org/show_bug.cgi?id=193323 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Use new testRunner method to bump the cache quota and verify adding a >+ cache entry works when bumping the cqche quota. >+ >+ * http/wpt/cache-storage/cache-quota.any.js: >+ (promise_test): >+ > 2019-01-09 Zalan Bujtas <zalan@apple.com> > > [Datalist] Crash when input with datalist is dynamically added. >diff --git a/LayoutTests/http/wpt/cache-storage/cache-quota.any.js b/LayoutTests/http/wpt/cache-storage/cache-quota.any.js >index 5a94d5b78f3b639ca70dcbf13ff288a5db2e2393..ca292dc9b549bc13e53c26d9e261e1ff0681b065 100644 >--- a/LayoutTests/http/wpt/cache-storage/cache-quota.any.js >+++ b/LayoutTests/http/wpt/cache-storage/cache-quota.any.js >@@ -114,7 +114,7 @@ promise_test((test) => { > return cache.put("1ko-v2", response1ko.clone()).then(assert_unreached, (e) => { > assert_equals(e.name, "QuotaExceededError"); > }); >- }).then(() => { >+ }).then(() => { > return cache.delete("1ko-v1"); > }).then(() => { > return cache.put("1ko-v2", response1ko.clone()); >@@ -151,6 +151,9 @@ promise_test((test) => { > return cache.put("1ko", response1ko.clone()).then(assert_unreached, (e) => { > assert_equals(e.name, "QuotaExceededError"); > }); >+ }).then(() => { >+ testRunner.allowCacheStorageQuotaIncrease(); >+ return cache.put("1ko", response1ko.clone()); > }).then(() => { > return cache.delete("1ko-padded-to-200ko"); > }).then(() => {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193323
:
358810
|
359292
|
359293
|
359386
|
359394
|
359400
|
359413
|
359428
|
359497