WebKit Bugzilla
Attachment 358762 Details for
Bug 193296
: Pipe cache quota request from Network Process to UIProcess
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193296-20190109161831.patch (text/plain), 28.23 KB, created by
youenn fablet
on 2019-01-09 16:18:34 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-01-09 16:18:34 PST
Size:
28.23 KB
patch
obsolete
>Subversion Revision: 239787 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 25c58e6284f286583363a9767e0c23cf0cee3809..f16d4a1f404877b159cd14371d0affdf5f36b185 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,15 @@ >+2019-01-09 Youenn Fablet <youenn@apple.com> >+ >+ Pipe cache quota request from Network Process to UIProcess >+ https://bugs.webkit.org/show_bug.cgi?id=193296 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Covered by existing tests. >+ >+ * Modules/cache/DOMCacheQuotaExtensionRequestIdentifier.h: Added. >+ * WebCore.xcodeproj/project.pbxproj: >+ > 2019-01-09 Zalan Bujtas <zalan@apple.com> > > [Datalist] Crash when input with datalist is dynamically added. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index e1197ef54d65a5040dab010a48fba34029eb33c4..a8ed66fc7d5750043756b611452c4bffe29e1e9d 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,44 @@ >+2019-01-09 Youenn Fablet <youenn@apple.com> >+ >+ Pipe cache quota request from Network Process to UIProcess >+ https://bugs.webkit.org/show_bug.cgi?id=193296 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When cache storage hits quota for a given origin, pipe the request back to NetworkProcess. >+ No record will be put until the quota request is answered. >+ The request is sent from CacheStorage::Caches to CacheStorage::Engine and to NetworkProcess. >+ NetworkProcess then sends it to NetworkProcessProxy. >+ Currently NetworkProcessProxy just answers by keeping the quota as it is. >+ In the future, NetworkProcessProxy should make a delegate call to let the app using WebKit >+ make a decision on the quota. This will allow prompting user to bump it as done for other data. >+ >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::requestCacheStorageSpace): >+ (WebKit::NetworkProcess::answerToCacheStorageSpaceRequest): >+ * NetworkProcess/NetworkProcess.h: >+ * NetworkProcess/NetworkProcess.messages.in: >+ * NetworkProcess/cache/CacheStorageEngine.cpp: >+ (WebKit::CacheStorage::Engine::from): >+ (WebKit::CacheStorage::Engine::Engine): >+ (WebKit::CacheStorage::Engine::requestSpace): >+ (WebKit::CacheStorage::Engine::answerToSpaceRequest): >+ * NetworkProcess/cache/CacheStorageEngine.h: >+ * NetworkProcess/cache/CacheStorageEngineCache.cpp: >+ (WebKit::CacheStorage::Cache::put): >+ (WebKit::CacheStorage::Cache::retryPuttingPendingRecords): >+ * NetworkProcess/cache/CacheStorageEngineCache.h: >+ * NetworkProcess/cache/CacheStorageEngineCaches.cpp: >+ (WebKit::CacheStorage::Caches::requestSpace): >+ (WebKit::CacheStorage::Caches::notifyCachesOfRequestSpaceEnd): >+ * NetworkProcess/cache/CacheStorageEngineCaches.h: >+ (WebKit::CacheStorage::Caches::isRequestingSpace const): >+ * Scripts/webkit/messages.py: >+ * UIProcess/Network/NetworkProcessProxy.cpp: >+ (WebKit::NetworkProcessProxy::requestCacheStorageSpace): >+ * UIProcess/Network/NetworkProcessProxy.h: >+ * UIProcess/Network/NetworkProcessProxy.messages.in: >+ > 2019-01-09 Brent Fulgham <bfulgham@apple.com> > > [iOS] Update sandbox profile to use iconservices instead of lsdiconservice >diff --git a/Source/WebCore/Modules/cache/DOMCacheQuotaExtensionRequestIdentifier.h b/Source/WebCore/Modules/cache/DOMCacheQuotaExtensionRequestIdentifier.h >new file mode 100644 >index 0000000000000000000000000000000000000000..4f77a5f9b4c119b487a5d4b51421d69b24f2d44b >--- /dev/null >+++ b/Source/WebCore/Modules/cache/DOMCacheQuotaExtensionRequestIdentifier.h >@@ -0,0 +1,35 @@ >+/* >+ * 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/ObjectIdentifier.h> >+ >+namespace WebCore { >+ >+enum DOMCacheQuotaExtensionRequestIdentifierType { }; >+using DOMCacheQuotaExtensionRequestIdentifier = ObjectIdentifier<DOMCacheQuotaExtensionRequestIdentifierType>; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 3ec66782454401ef99f140eb997c306e70edcc50..e8e1a0245e7b9707019f328393cf2b11a9deb8c5 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -1066,6 +1066,7 @@ > 41103AAD1E39791000769F03 /* RealtimeIncomingAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 41103AA91E39790A00769F03 /* RealtimeIncomingAudioSource.h */; }; > 41103AAD1E39791000769F14 /* RealtimeIncomingAudioSourceCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 41103AA91E39790A00769F14 /* RealtimeIncomingAudioSourceCocoa.h */; }; > 4112B5431F9F9CA000E67875 /* ServiceWorkerThreadProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4112B53F1F9F9C9B00E67875 /* ServiceWorkerThreadProxy.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 4118DC1321E67E3B00DE04C7 /* DOMCacheQuotaExtensionRequestIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 4118DC1121E67E3400DE04C7 /* DOMCacheQuotaExtensionRequestIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F19B1A08245E5A001E9ABC /* WebCore.framework */; }; > 41230913138C42FF00BCCFCA /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* JavaScriptCore.framework */; }; > 4129C9971F59B963009D7403 /* FetchBodySource.h in Headers */ = {isa = PBXBuildFile; fileRef = 413015D61C7B570400091C6F /* FetchBodySource.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -7238,6 +7239,7 @@ > 41189EF71AD8232800B90A0D /* ReadableStreamDefaultController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamDefaultController.idl; sourceTree = "<group>"; }; > 41189EF71AD8232800B93F64 /* ReadableByteStreamController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableByteStreamController.idl; sourceTree = "<group>"; }; > 41189EF71AD8232800B95672 /* ReadableStreamBYOBRequest.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamBYOBRequest.idl; sourceTree = "<group>"; }; >+ 4118DC1121E67E3400DE04C7 /* DOMCacheQuotaExtensionRequestIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMCacheQuotaExtensionRequestIdentifier.h; sourceTree = "<group>"; }; > 41209E91216D593C00A73A12 /* RTCCertificate.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCCertificate.idl; sourceTree = "<group>"; }; > 41209E93216D5C7900A73A12 /* RTCCertificate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCCertificate.h; sourceTree = "<group>"; }; > 41209E94216EA69A00A73A12 /* RTCCertificate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCCertificate.cpp; sourceTree = "<group>"; }; >@@ -17356,6 +17358,7 @@ > 41380C231F34369400155FDA /* DOMCache.idl */, > 41FABD2E1F4E0251006A6C97 /* DOMCacheEngine.cpp */, > 41FABD2B1F4DFE42006A6C97 /* DOMCacheEngine.h */, >+ 4118DC1121E67E3400DE04C7 /* DOMCacheQuotaExtensionRequestIdentifier.h */, > 41380C211F34368D00155FDA /* DOMCacheStorage.cpp */, > 41380C221F34369000155FDA /* DOMCacheStorage.h */, > 41380C241F34369700155FDA /* DOMCacheStorage.idl */, >@@ -30129,6 +30132,7 @@ > 1A762C7A0A074F2600989F5B /* JSXPathResult.h in Headers */, > BCEFE1EB0DCA5F6400739219 /* JSXSLTProcessor.h in Headers */, > 83B74EF61F3E0BF200996BC7 /* KeepaliveRequestTracker.h in Headers */, >+ 4118DC1321E67E3B00DE04C7 /* DOMCacheQuotaExtensionRequestIdentifier.h in Headers */, > 85031B440A44EFC700F992E0 /* KeyboardEvent.h in Headers */, > 1AE00D59182DAC8D00087DD7 /* KeyedCoding.h in Headers */, > 517A63C51B74318F00E7DCDC /* KeyedDecoderCF.h in Headers */, >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index 16f9f7d0b17c32cdef895f309a06518e3ce7362f..98c8556de5c153bb0a4ceaf03e41cf7c228b96b4 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -30,6 +30,7 @@ > #include "ArgumentCoders.h" > #include "Attachment.h" > #include "AuthenticationManager.h" >+#include "CacheStorageEngine.h" > #include "ChildProcessMessages.h" > #include "DataReference.h" > #include "DownloadProxyMessages.h" >@@ -1375,6 +1376,18 @@ void NetworkProcess::addServiceWorkerSession(PAL::SessionID sessionID, String& s > } > #endif // ENABLE(SERVICE_WORKER) > >+void NetworkProcess::requestCacheStorageSpace(PAL::SessionID sessionID, DOMCacheQuotaExtensionRequestIdentifier requestIdentifier, const ClientOrigin& origin, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired) >+{ >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::RequestCacheStorageSpace(sessionID, requestIdentifier, origin, quota, currentSize, spaceRequired), 0); >+} >+ >+void NetworkProcess::requestCacheStorageSpaceCompleted(PAL::SessionID sessionID, DOMCacheQuotaExtensionRequestIdentifier identifier, Optional<uint64_t> newQuota) >+{ >+ CacheStorage::Engine::from(*this, sessionID, [identifier, newQuota](auto& engine) { >+ engine.answerToSpaceRequest(identifier, newQuota); >+ }); >+} >+ > #if !PLATFORM(COCOA) > void NetworkProcess::initializeProcess(const ChildProcessInitializationParameters&) > { >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.h b/Source/WebKit/NetworkProcess/NetworkProcess.h >index cec88ee5441b8f5d55774315932cbb49f591cfb3..d17a90d33a692cadddf6a3e73dbb97c72ccbfa4a 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.h >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.h >@@ -31,6 +31,8 @@ > #include "NetworkContentRuleListManager.h" > #include "NetworkHTTPSUpgradeChecker.h" > #include "SandboxExtension.h" >+#include <WebCore/ClientOrigin.h> >+#include <WebCore/DOMCacheQuotaExtensionRequestIdentifier.h> > #include <WebCore/DiagnosticLoggingClient.h> > #include <WebCore/FetchIdentifier.h> > #include <WebCore/IDBKeyData.h> >@@ -44,6 +46,7 @@ > #include <wtf/MemoryPressureHandler.h> > #include <wtf/NeverDestroyed.h> > #include <wtf/RetainPtr.h> >+#include <wtf/WeakPtr.h> > > namespace IPC { > class FormDataReference; >@@ -96,6 +99,7 @@ class NetworkProcess : public ChildProcess, private DownloadManager::Client, pub > #if ENABLE(INDEXED_DATABASE) > , public WebCore::IDBServer::IDBBackingStoreTemporaryFileHandler > #endif >+ , public CanMakeWeakPtr<NetworkProcess> > { > WTF_MAKE_NONCOPYABLE(NetworkProcess); > public: >@@ -216,11 +220,14 @@ public: > > void ref() const override { ThreadSafeRefCounted<NetworkProcess>::ref(); } > void deref() const override { ThreadSafeRefCounted<NetworkProcess>::deref(); } >- >+ > CacheStorage::Engine* findCacheEngine(const PAL::SessionID&); > CacheStorage::Engine& ensureCacheEngine(const PAL::SessionID&, Function<Ref<CacheStorage::Engine>()>&&); > void removeCacheEngine(const PAL::SessionID&); >- >+ >+ void requestCacheStorageSpace(PAL::SessionID, WebCore::DOMCacheQuotaExtensionRequestIdentifier, const WebCore::ClientOrigin&, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired); >+ void requestCacheStorageSpaceCompleted(PAL::SessionID, WebCore::DOMCacheQuotaExtensionRequestIdentifier, Optional<uint64_t> newQuota); >+ > private: > NetworkProcess(); > >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >index 8d87224bf311e77e55a210873a4a7a543d1e1f02..c9a4688779e2c554e280aa99dce712fdaabcfd87 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >@@ -125,4 +125,6 @@ messages -> NetworkProcess LegacyReceiver { > #if ENABLE(INDEXED_DATABASE) > SetIDBPerOriginQuota(uint64_t quota) > #endif >+ >+ RequestCacheStorageSpaceCompleted(PAL::SessionID sessionID, WebCore::DOMCacheQuotaExtensionRequestIdentifier requestIdentifier, Optional<uint64_t> newQuota) > } >diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp b/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp >index 801d22e2ade82e85d9b85c0d5a5274b78aea8709..48f97751d6b2b5d5a5c2f70382e2f6b118d6d5dc 100644 >--- a/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp >+++ b/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp >@@ -85,7 +85,7 @@ void Engine::from(NetworkProcess& networkProcess, PAL::SessionID sessionID, Func > > networkProcess.cacheStorageParameters(sessionID, [networkProcess = makeRef(networkProcess), sessionID, callback = WTFMove(callback)] (auto&& rootPath, auto quota) mutable { > callback(networkProcess->ensureCacheEngine(sessionID, [&] { >- return adoptRef(*new Engine { String { rootPath }, quota }); >+ return adoptRef(*new Engine { sessionID, networkProcess.get(), String { rootPath }, quota }); > })); > }); > } >@@ -188,8 +188,10 @@ void Engine::clearCachesForOrigin(NetworkProcess& networkProcess, PAL::SessionID > }); > } > >-Engine::Engine(String&& rootPath, uint64_t quota) >- : m_rootPath(WTFMove(rootPath)) >+Engine::Engine(PAL::SessionID sessionID, NetworkProcess& process, String&& rootPath, uint64_t quota) >+ : m_sessionID(sessionID) >+ , m_networkProcess(makeWeakPtr(&process)) >+ , m_rootPath(WTFMove(rootPath)) > , m_quota(quota) > { > if (!m_rootPath.isNull()) >@@ -651,6 +653,18 @@ String Engine::representation() > return builder.toString(); > } > >+void Engine::requestSpace(const ClientOrigin& origin, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired, CompletionHandler<void(Optional<uint64_t>)>&& callback) >+{ >+ m_extendQuotaCallbacks.add(++m_pendingCallbacksCounter, WTFMove(callback)); >+ NetworkProcess::singleton().requestCacheStorageSpace(m_sessionID, makeObjectIdentifier<DOMCacheQuotaExtensionRequestIdentifierType>(m_pendingCallbacksCounter), origin, quota, currentSize, spaceRequired); >+} >+ >+void Engine::answerToSpaceRequest(DOMCacheQuotaExtensionRequestIdentifier requestIdentifier, Optional<uint64_t> newQuota) >+{ >+ if (auto callback = m_extendQuotaCallbacks.take(requestIdentifier.toUInt64())) >+ callback(newQuota); >+} >+ > } // namespace CacheStorage > > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h b/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h >index 1ebcb73616570df5073cffd5b5ed085414d8d216..96a3fc083cf75674e9a4509b7405fab0bd14837b 100644 >--- a/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h >+++ b/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h >@@ -29,6 +29,7 @@ > #include "NetworkCacheData.h" > #include "WebsiteData.h" > #include <WebCore/ClientOrigin.h> >+#include <WebCore/DOMCacheQuotaExtensionRequestIdentifier.h> > #include <wtf/HashMap.h> > #include <wtf/RefCounted.h> > #include <wtf/WeakPtr.h> >@@ -90,8 +91,12 @@ public: > const NetworkCache::Salt& salt() const { return m_salt.value(); } > uint64_t nextCacheIdentifier() { return ++m_nextCacheIdentifier; } > >+ using ExtendQuotaCallback = CompletionHandler<void(Optional<uint64_t>)>; >+ void requestSpace(const WebCore::ClientOrigin&, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired, ExtendQuotaCallback&&); >+ void answerToSpaceRequest(WebCore::DOMCacheQuotaExtensionRequestIdentifier, Optional<uint64_t> newQuota); >+ > private: >- Engine(String&& rootPath, uint64_t quota); >+ Engine(PAL::SessionID, NetworkProcess&, String&& rootPath, uint64_t quota); > > void open(const WebCore::ClientOrigin&, const String& cacheName, WebCore::DOMCacheEngine::CacheIdentifierCallback&&); > void remove(uint64_t cacheIdentifier, WebCore::DOMCacheEngine::CacheIdentifierCallback&&); >@@ -129,6 +134,8 @@ private: > > Cache* cache(uint64_t cacheIdentifier); > >+ PAL::SessionID m_sessionID; >+ WeakPtr<NetworkProcess> m_networkProcess; > HashMap<WebCore::ClientOrigin, RefPtr<Caches>> m_caches; > uint64_t m_nextCacheIdentifier { 0 }; > String m_rootPath; >@@ -139,6 +146,7 @@ private: > Vector<WebCore::DOMCacheEngine::CompletionCallback> m_initializationCallbacks; > HashMap<uint64_t, WebCore::DOMCacheEngine::CompletionCallback> m_pendingWriteCallbacks; > HashMap<uint64_t, CompletionHandler<void(const NetworkCache::Data&, int error)>> m_pendingReadCallbacks; >+ HashMap<uint64_t, ExtendQuotaCallback> m_extendQuotaCallbacks; > uint64_t m_pendingCallbacksCounter { 0 }; > }; > >diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp b/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp >index e452dba5e331354592ce920cc284ba6623f0aa5a..fed88201592ed6cc77361623e3a54af9dd10ecf5 100644 >--- a/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp >+++ b/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp >@@ -400,10 +400,15 @@ void Cache::storeRecords(Vector<Record>&& records, RecordIdentifiersCallback&& c > } > } > >-void Cache::put(Vector<Record>&& records, RecordIdentifiersCallback&& callback) >+void Cache::put(Vector<Record>&& records, RecordIdentifiersCallback&& callback, CanRequestMoreSpace canRequestMoreSpace) > { > ASSERT(m_state == State::Open); > >+ if (m_caches.isRequestingSpace()) { >+ m_pendingPutRequests.append({ WTFMove(records), WTFMove(callback) }); >+ return; >+ } >+ > WebCore::CacheQueryOptions options; > uint64_t spaceRequired = 0; > >@@ -423,6 +428,11 @@ void Cache::put(Vector<Record>&& records, RecordIdentifiersCallback&& callback) > return; > } > >+ if (canRequestMoreSpace == CanRequestMoreSpace::No) { >+ callback(makeUnexpected(DOMCacheEngine::Error::QuotaExceeded)); >+ return; >+ } >+ > m_caches.requestSpace(spaceRequired, [caches = makeRef(m_caches), identifier = m_identifier, records = WTFMove(records), callback = WTFMove(callback)](Optional<DOMCacheEngine::Error>&& error) mutable { > if (error) { > callback(makeUnexpected(error.value())); >@@ -432,10 +442,17 @@ void Cache::put(Vector<Record>&& records, RecordIdentifiersCallback&& callback) > if (!cache) > return; > >- cache->storeRecords(WTFMove(records), WTFMove(callback)); >+ cache->put(WTFMove(records), WTFMove(callback), CanRequestMoreSpace::No); > }); > } > >+void Cache::retryPuttingPendingRecords() >+{ >+ auto pendingPutRequests = WTFMove(m_pendingPutRequests); >+ for (auto& request : pendingPutRequests) >+ put(WTFMove(request.records), WTFMove(request.callback)); >+} >+ > void Cache::remove(WebCore::ResourceRequest&& request, WebCore::CacheQueryOptions&& options, RecordIdentifiersCallback&& callback) > { > ASSERT(m_state == State::Open); >diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.h b/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.h >index cf1b3b613e151fd0b6270992b26ae91455219c29..22ea4079a385c88d9159c3a7ca0cf530d916533c 100644 >--- a/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.h >+++ b/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.h >@@ -69,7 +69,8 @@ public: > void retrieveRecords(const URL&, WebCore::DOMCacheEngine::RecordsCallback&&); > WebCore::DOMCacheEngine::CacheInfo info() const { return { m_identifier, m_name }; } > >- void put(Vector<WebCore::DOMCacheEngine::Record>&&, WebCore::DOMCacheEngine::RecordIdentifiersCallback&&); >+ enum class CanRequestMoreSpace { Yes, No }; >+ void put(Vector<WebCore::DOMCacheEngine::Record>&&, WebCore::DOMCacheEngine::RecordIdentifiersCallback&&, CanRequestMoreSpace = CanRequestMoreSpace::Yes); > void remove(WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&, WebCore::DOMCacheEngine::RecordIdentifiersCallback&&); > > Vector<NetworkCache::Key> keys() const; >@@ -77,6 +78,8 @@ public: > void dispose(); > void clearMemoryRepresentation(); > >+ void retryPuttingPendingRecords(); >+ > static Optional<WebCore::DOMCacheEngine::Record> decode(const NetworkCache::Storage::Record&); > static NetworkCache::Storage::Record encode(const RecordInformation&, const WebCore::DOMCacheEngine::Record&); > >@@ -120,6 +123,12 @@ private: > HashMap<String, Vector<RecordInformation>> m_records; > uint64_t m_nextRecordIdentifier { 0 }; > Vector<WebCore::DOMCacheEngine::CompletionCallback> m_pendingOpeningCallbacks; >+ >+ struct PendingPutRequest { >+ Vector<WebCore::DOMCacheEngine::Record> records; >+ WebCore::DOMCacheEngine::RecordIdentifiersCallback callback; >+ }; >+ Vector<PendingPutRequest> m_pendingPutRequests; > }; > > } // namespace CacheStorage >diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp b/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp >index faa88c963c36f7622287d78b57eeb13459ade5e5..993b6ab5e7d0d2b48e37c98315eea174a63e8a62 100644 >--- a/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp >+++ b/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp >@@ -481,9 +481,36 @@ void Caches::readRecordsList(Cache& cache, NetworkCache::Storage::TraverseHandle > > void Caches::requestSpace(uint64_t spaceRequired, WebCore::DOMCacheEngine::CompletionCallback&& callback) > { >- // FIXME: Implement quota increase request. >- ASSERT(m_quota < m_size + spaceRequired); >- callback(Error::QuotaExceeded); >+ ASSERT(!m_isRequestingSpace); >+ >+ auto minimumNewQuota = m_size + spaceRequired; >+ ASSERT(m_quota < minimumNewQuota); >+ >+ if (!m_engine) { >+ callback(Error::QuotaExceeded); >+ return; >+ } >+ >+ m_isRequestingSpace = true; >+ m_engine->requestSpace(m_origin, m_quota, m_size, spaceRequired, [this, protectedThis = makeRef(*this), minimumNewQuota, callback = WTFMove(callback)] (Optional<uint64_t> newQuota) { >+ m_isRequestingSpace = false; >+ if (!newQuota || *newQuota < minimumNewQuota) { >+ callback(Error::QuotaExceeded); >+ notifyCachesOfRequestSpaceEnd(); >+ return; >+ } >+ m_quota = *newQuota; >+ callback({ }); >+ notifyCachesOfRequestSpaceEnd(); >+ }); >+} >+ >+void Caches::notifyCachesOfRequestSpaceEnd() >+{ >+ for (auto& cache : m_caches) >+ cache.retryPuttingPendingRecords(); >+ for (auto& cache : m_removedCaches) >+ cache.retryPuttingPendingRecords(); > } > > void Caches::writeRecord(const Cache& cache, const RecordInformation& recordInformation, Record&& record, uint64_t previousRecordSize, CompletionCallback&& callback) >diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h b/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h >index f8e72bfee72915f0323a60352a482db46e852544..489622ceed13bc5e83b5b91be824ab088eb614f6 100644 >--- a/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h >+++ b/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h >@@ -61,6 +61,7 @@ public: > void readRecord(const NetworkCache::Key&, WTF::Function<void(Expected<WebCore::DOMCacheEngine::Record, WebCore::DOMCacheEngine::Error>&&)>&&); > > bool hasEnoughSpace(uint64_t spaceRequired) const { return m_quota >= m_size + spaceRequired; } >+ bool isRequestingSpace() const { return m_isRequestingSpace; } > void requestSpace(uint64_t spaceRequired, WebCore::DOMCacheEngine::CompletionCallback&&); > void writeRecord(const Cache&, const RecordInformation&, WebCore::DOMCacheEngine::Record&&, uint64_t previousRecordSize, WebCore::DOMCacheEngine::CompletionCallback&&); > >@@ -93,7 +94,10 @@ private: > void makeDirty() { ++m_updateCounter; } > bool isDirty(uint64_t updateCounter) const; > >+ void notifyCachesOfRequestSpaceEnd(); >+ > bool m_isInitialized { false }; >+ bool m_isRequestingSpace { false }; > Engine* m_engine { nullptr }; > uint64_t m_updateCounter { 0 }; > WebCore::ClientOrigin m_origin; >diff --git a/Source/WebKit/Scripts/webkit/messages.py b/Source/WebKit/Scripts/webkit/messages.py >index c481f337fbdbd15f702532c41c4105f39233dfa1..fa2a11727616fffe59d4b0b8948f850ccc69ecc0 100644 >--- a/Source/WebKit/Scripts/webkit/messages.py >+++ b/Source/WebKit/Scripts/webkit/messages.py >@@ -197,6 +197,7 @@ def forward_declarations_and_headers(receiver): > no_forward_declaration_types = frozenset([ > 'MachSendRight', > 'String', >+ 'WebCore::DOMCacheQuotaExtensionRequestIdentifier', > 'WebCore::DocumentIdentifier', > 'WebCore::FetchIdentifier', > 'WebCore::ServiceWorkerIdentifier', >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >index 4a791f35c30face474d459f1f22225f86d9595da..147db552d8d763a6b620b636b85570c9fc714a1c 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >@@ -728,6 +728,19 @@ 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) >+{ >+ auto* store = websiteDataStoreFromSessionID(sessionID); >+ >+ if (!store) { >+ send(Messages::NetworkProcess::RequestCacheStorageSpaceCompleted { sessionID, requestIdentifier, { } }, 0); >+ return; >+ } >+ >+ // FIXME: Ask WebsiteDataStore about updating the quota for this origin. >+ send(Messages::NetworkProcess::RequestCacheStorageSpaceCompleted { sessionID, requestIdentifier, quota }, 0); >+} >+ > } // namespace WebKit > > #undef MESSAGE_CHECK >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >index 4fe5ce7a456edb5b432c018f377b39243cfa547e..ff78b7a556462f3930269deb696f3baa3a74e083 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >@@ -165,6 +165,8 @@ private: > void establishWorkerContextConnectionToNetworkProcessForExplicitSession(WebCore::SecurityOriginData&&, PAL::SessionID); > #endif > >+ void requestCacheStorageSpace(PAL::SessionID, WebCore::DOMCacheQuotaExtensionRequestIdentifier, const WebCore::ClientOrigin&, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired); >+ > WebsiteDataStore* websiteDataStoreFromSessionID(PAL::SessionID); > > // ProcessLauncher::Client >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in >index b5641f969050820d55ef87d8be058991c9c763cc..80ab2160147e7405cc48a0096c51b77d9a05c9f8 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in >@@ -62,4 +62,6 @@ messages -> NetworkProcessProxy LegacyReceiver { > EstablishWorkerContextConnectionToNetworkProcess(struct WebCore::SecurityOriginData origin) > EstablishWorkerContextConnectionToNetworkProcessForExplicitSession(struct WebCore::SecurityOriginData origin, PAL::SessionID explicitSession) > #endif >+ >+ RequestCacheStorageSpace(PAL::SessionID sessionID, WebCore::DOMCacheQuotaExtensionRequestIdentifier requestIdentifier, struct WebCore::ClientOrigin origin, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired); > }
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 193296
:
358740
|
358762
|
358763
|
358800
|
359318