Diff
Modified: trunk/Source/WTF/ChangeLog (280933 => 280934)
--- trunk/Source/WTF/ChangeLog 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WTF/ChangeLog 2021-08-11 22:25:56 UTC (rev 280934)
@@ -1,3 +1,30 @@
+2021-08-11 Sihui Liu <[email protected]>
+
+ Suspend WorkQueue of ResourceLoadStatistics and LocalStorage sooner
+ https://bugs.webkit.org/show_bug.cgi?id=228748
+ <rdar://problem/81626714>
+
+ Reviewed by Chris Dumez.
+
+ Add SuspendableWorkQueue that would perform suspend check before each task.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/CMakeLists.txt:
+ * wtf/Forward.h:
+ * wtf/SuspendableWorkQueue.cpp: Added.
+ (WTF::SuspendableWorkQueue::create):
+ (WTF::SuspendableWorkQueue::SuspendableWorkQueue):
+ (WTF::SuspendableWorkQueue::suspend):
+ (WTF::SuspendableWorkQueue::resume):
+ (WTF::SuspendableWorkQueue::dispatch):
+ (WTF::SuspendableWorkQueue::dispatchAfter):
+ (WTF::SuspendableWorkQueue::dispatchSync):
+ (WTF::SuspendableWorkQueue::invokeAllSuspensionCompletionHandlers):
+ (WTF::SuspendableWorkQueue::suspendIfNeeded):
+ * wtf/SuspendableWorkQueue.h: Added.
+ * wtf/WorkQueue.h:
+ (): Deleted.
+
2021-08-11 Youenn Fablet <[email protected]>
Enable WebRTC relay by default
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (280933 => 280934)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2021-08-11 22:25:56 UTC (rev 280934)
@@ -102,6 +102,7 @@
8348BA0E21FBC0D500FD3054 /* ObjectIdentifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8348BA0D21FBC0D400FD3054 /* ObjectIdentifier.cpp */; };
93934BD318A1E8C300D0D6A1 /* StringViewCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD218A1E8C300D0D6A1 /* StringViewCocoa.mm */; };
93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */; };
+ 93B07ED826B8717000A09B34 /* SuspendableWorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B07ED726B8715B00A09B34 /* SuspendableWorkQueue.cpp */; };
93B5B44E2213D616004B7AA7 /* HexNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B5B44D2213D616004B7AA7 /* HexNumber.cpp */; };
93B5B45122171EEA004B7AA7 /* Logger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B5B45022171EE9004B7AA7 /* Logger.cpp */; };
93F1993E19D7958D00C2390B /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1993D19D7958D00C2390B /* StringView.cpp */; };
@@ -510,6 +511,8 @@
93934BD218A1E8C300D0D6A1 /* StringViewCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringViewCocoa.mm; sourceTree = "<group>"; };
93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringViewCF.cpp; sourceTree = "<group>"; };
93AC91A718942FC400244939 /* LChar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LChar.h; sourceTree = "<group>"; };
+ 93B07ED626B86BB500A09B34 /* SuspendableWorkQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SuspendableWorkQueue.h; sourceTree = "<group>"; };
+ 93B07ED726B8715B00A09B34 /* SuspendableWorkQueue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SuspendableWorkQueue.cpp; sourceTree = "<group>"; };
93B5B44D2213D616004B7AA7 /* HexNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HexNumber.cpp; sourceTree = "<group>"; };
93B5B45022171EE9004B7AA7 /* Logger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Logger.cpp; sourceTree = "<group>"; };
93D0017B264DBACF00BCF109 /* StringConcatenateCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringConcatenateCF.h; sourceTree = "<group>"; };
@@ -1311,6 +1314,8 @@
A748745117A0BDAE00FA04CB /* StringHashDumpContext.h */,
0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */,
0FDDBFA61666DFA300C55FEF /* StringPrintStream.h */,
+ 93B07ED726B8715B00A09B34 /* SuspendableWorkQueue.cpp */,
+ 93B07ED626B86BB500A09B34 /* SuspendableWorkQueue.h */,
5597F82C1D94B9970066BC21 /* SynchronizedFixedQueue.h */,
E3E158251EADA53C004A079D /* SystemFree.h */,
E4D2AE4D268A4C7F00DFEA02 /* SystemMalloc.h */,
@@ -1824,6 +1829,7 @@
93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */,
93934BD318A1E8C300D0D6A1 /* StringViewCocoa.mm in Sources */,
A8A473B7151A825B004123FF /* strtod.cc in Sources */,
+ 93B07ED826B8717000A09B34 /* SuspendableWorkQueue.cpp in Sources */,
52183012C99E476A84EEBEA8 /* SymbolImpl.cpp in Sources */,
70A993FE1AD7151300FA615B /* SymbolRegistry.cpp in Sources */,
EB61EDC72409CCC1001EFE36 /* SystemTracingCocoa.cpp in Sources */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (280933 => 280934)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2021-08-11 22:25:56 UTC (rev 280934)
@@ -266,6 +266,7 @@
StringExtras.h
StringHashDumpContext.h
StringPrintStream.h
+ SuspendableWorkQueue.h
SynchronizedFixedQueue.h
SystemFree.h
SystemMalloc.h
@@ -462,6 +463,7 @@
StackStats.cpp
StackTrace.cpp
StringPrintStream.cpp
+ SuspendableWorkQueue.cpp
ThreadGroup.cpp
ThreadMessage.cpp
Threading.cpp
Modified: trunk/Source/WTF/wtf/Forward.h (280933 => 280934)
--- trunk/Source/WTF/wtf/Forward.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WTF/wtf/Forward.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -44,6 +44,7 @@
class StringBuilder;
class StringImpl;
class StringView;
+class SuspendableWorkQueue;
class TextPosition;
class TextStream;
class UniquedStringImpl;
@@ -151,6 +152,7 @@
using WTF::StringImpl;
using WTF::StringParsingBuffer;
using WTF::StringView;
+using WTF::SuspendableWorkQueue;
using WTF::TextPosition;
using WTF::TextStream;
using WTF::URL;
Added: trunk/Source/WTF/wtf/SuspendableWorkQueue.cpp (0 => 280934)
--- trunk/Source/WTF/wtf/SuspendableWorkQueue.cpp (rev 0)
+++ trunk/Source/WTF/wtf/SuspendableWorkQueue.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2021 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. ``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
+ * 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.
+ */
+
+#include "config.h"
+#include <wtf/SuspendableWorkQueue.h>
+
+namespace WTF {
+
+Ref<SuspendableWorkQueue> SuspendableWorkQueue::create(const char* name, WorkQueue::QOS qos)
+{
+ return adoptRef(*new SuspendableWorkQueue(name, qos));
+}
+
+SuspendableWorkQueue::SuspendableWorkQueue(const char* name, QOS qos)
+ : WorkQueue(name, Type::Serial, qos)
+{
+ ASSERT(isMainThread());
+}
+
+void SuspendableWorkQueue::suspend(Function<void()>&& suspendFunction, CompletionHandler<void()>&& completionHandler)
+{
+ ASSERT(isMainThread());
+ Locker suspensionLocker { m_suspensionLock };
+
+ // Last suspend function will be the one that is used.
+ m_suspendFunction = WTFMove(suspendFunction);
+ m_suspensionCompletionHandlers.append(WTFMove(completionHandler));
+ if (m_isOrWillBeSuspended)
+ return;
+
+ m_isOrWillBeSuspended = true;
+ // Make sure queue will be suspended when there is no task scheduled on the queue.
+ WorkQueue::dispatch([this] {
+ suspendIfNeeded();
+ });
+}
+
+void SuspendableWorkQueue::resume()
+{
+ ASSERT(isMainThread());
+ Locker suspensionLocker { m_suspensionLock };
+
+ if (!m_isOrWillBeSuspended)
+ return;
+
+ m_isOrWillBeSuspended = false;
+ m_suspensionCondition.notifyOne();
+}
+
+void SuspendableWorkQueue::dispatch(Function<void()>&& function)
+{
+ // WorkQueue will protect this in dispatch().
+ WorkQueue::dispatch([this, function = WTFMove(function)] {
+ suspendIfNeeded();
+ function();
+ });
+}
+
+void SuspendableWorkQueue::dispatchAfter(Seconds seconds, Function<void()>&& function)
+{
+ WorkQueue::dispatchAfter(seconds, [this, function = WTFMove(function)] {
+ suspendIfNeeded();
+ function();
+ });
+}
+
+void SuspendableWorkQueue::dispatchSync(Function<void()>&& function)
+{
+ // This function should be called only when queue is not about to be suspended,
+ // otherwise thread may be blocked.
+ if (isMainThread()) {
+ Locker suspensionLocker { m_suspensionLock };
+ RELEASE_ASSERT(!m_isOrWillBeSuspended);
+ }
+ WorkQueue::dispatchSync(WTFMove(function));
+}
+
+void SuspendableWorkQueue::invokeAllSuspensionCompletionHandlers()
+{
+ ASSERT(!isMainThread());
+
+ if (m_suspensionCompletionHandlers.isEmpty())
+ return;
+
+ callOnMainThread([completionHandlers = std::exchange(m_suspensionCompletionHandlers, { })]() mutable {
+ for (auto& completionHandler : completionHandlers) {
+ if (completionHandler)
+ completionHandler();
+ }
+ });
+}
+
+void SuspendableWorkQueue::suspendIfNeeded()
+{
+ ASSERT(!isMainThread());
+
+ Locker suspensionLocker { m_suspensionLock };
+ auto suspendFunction = std::exchange(m_suspendFunction, { });
+ if (m_isOrWillBeSuspended)
+ suspendFunction();
+
+ invokeAllSuspensionCompletionHandlers();
+
+ while (m_isOrWillBeSuspended)
+ m_suspensionCondition.wait(m_suspensionLock);
+}
+
+} // namespace WTF
Added: trunk/Source/WTF/wtf/SuspendableWorkQueue.h (0 => 280934)
--- trunk/Source/WTF/wtf/SuspendableWorkQueue.h (rev 0)
+++ trunk/Source/WTF/wtf/SuspendableWorkQueue.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 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>
+#include <wtf/Condition.h>
+#include <wtf/Deque.h>
+#include <wtf/Lock.h>
+#include <wtf/WorkQueue.h>
+
+namespace WTF {
+
+class SuspendableWorkQueue final : public WorkQueue {
+public:
+ using QOS = WorkQueue::QOS;
+ WTF_EXPORT_PRIVATE static Ref<SuspendableWorkQueue> create(const char* name, QOS = QOS::Default);
+
+ WTF_EXPORT_PRIVATE void suspend(Function<void()>&& suspendFunction, CompletionHandler<void()>&& suspensionCompletionHandler);
+ WTF_EXPORT_PRIVATE void resume();
+ WTF_EXPORT_PRIVATE void dispatch(Function<void()>&&) final;
+ WTF_EXPORT_PRIVATE void dispatchAfter(Seconds, Function<void()>&&) final;
+ WTF_EXPORT_PRIVATE void dispatchSync(Function<void()>&&) final;
+
+private:
+ SuspendableWorkQueue(const char* name, QOS);
+ void invokeAllSuspensionCompletionHandlers() WTF_REQUIRES_LOCK(m_suspensionLock);
+ void suspendIfNeeded();
+#if USE(COCOA_EVENT_LOOP)
+ using WorkQueue::dispatchQueue;
+#else
+ using WorkQueue::runLoop;
+#endif
+
+ Lock m_suspensionLock;
+ Condition m_suspensionCondition;
+ bool m_isOrWillBeSuspended WTF_GUARDED_BY_LOCK(m_suspensionLock) { false };
+ Function<void()> m_suspendFunction WTF_GUARDED_BY_LOCK(m_suspensionLock);
+ Vector<CompletionHandler<void()>> m_suspensionCompletionHandlers WTF_GUARDED_BY_LOCK(m_suspensionLock);
+};
+
+} // namespace WTF
+
+using WTF::SuspendableWorkQueue;
Modified: trunk/Source/WTF/wtf/WorkQueue.h (280933 => 280934)
--- trunk/Source/WTF/wtf/WorkQueue.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WTF/wtf/WorkQueue.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -41,7 +41,7 @@
namespace WTF {
-class WorkQueue final : public FunctionDispatcher {
+class WorkQueue : public FunctionDispatcher {
public:
enum class Type {
@@ -53,11 +53,11 @@
WTF_EXPORT_PRIVATE static WorkQueue& main();
WTF_EXPORT_PRIVATE static Ref<WorkQueue> create(const char* name, Type = Type::Serial, QOS = QOS::Default);
- ~WorkQueue() final;
+ ~WorkQueue() override;
- WTF_EXPORT_PRIVATE void dispatch(Function<void()>&&) final;
- WTF_EXPORT_PRIVATE void dispatchAfter(Seconds, Function<void()>&&);
- WTF_EXPORT_PRIVATE void dispatchSync(Function<void()>&&);
+ WTF_EXPORT_PRIVATE void dispatch(Function<void()>&&) override;
+ WTF_EXPORT_PRIVATE virtual void dispatchAfter(Seconds, Function<void()>&&);
+ WTF_EXPORT_PRIVATE virtual void dispatchSync(Function<void()>&&);
WTF_EXPORT_PRIVATE static void concurrentApply(size_t iterations, WTF::Function<void(size_t index)>&&);
@@ -67,9 +67,10 @@
RunLoop& runLoop() const { return *m_runLoop; }
#endif
-private:
+protected:
WorkQueue(const char* name, Type, QOS);
+private:
static Ref<WorkQueue> constructMainWorkQueue();
#if USE(COCOA_EVENT_LOOP)
explicit WorkQueue(OSObjectPtr<dispatch_queue_t>&&);
Modified: trunk/Source/WebKit/ChangeLog (280933 => 280934)
--- trunk/Source/WebKit/ChangeLog 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/ChangeLog 2021-08-11 22:25:56 UTC (rev 280934)
@@ -1,3 +1,63 @@
+2021-08-11 Sihui Liu <[email protected]>
+
+ Suspend WorkQueue of ResourceLoadStatistics and LocalStorage sooner
+ https://bugs.webkit.org/show_bug.cgi?id=228748
+ <rdar://problem/81626714>
+
+ Reviewed by Chris Dumez.
+
+ When suspending ResourceLoadStatistics and LocalStorage, we dispatched a suspend task, which waits on a
+ condition, to their WorkQueue. That means the queue will be suspended after completing all tasks scheduled
+ before the suspend task. These tasks may take a long time to complete and assertion may be timed out.
+
+ When network process receives PrepareToSuspend message, we want the queues to suspend as soon as possible. To
+ achieve that, now we check if the queue needs to be suspended before each task, which ensures the queue
+ execute as most one task after suspend().
+
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+ (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
+ * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
+ (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
+ * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
+ * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
+ (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore):
+ * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
+ (WebKit::ResourceLoadStatisticsStore::workQueue):
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::sharedStatisticsQueue):
+ (WebKit::WebResourceLoadStatisticsStore::suspend):
+ (WebKit::WebResourceLoadStatisticsStore::resume):
+ (WebKit::WTF_GUARDED_BY_LOCK): Deleted.
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+ * NetworkProcess/WebStorage/LocalStorageDatabase.cpp:
+ (WebKit::LocalStorageDatabase::create):
+ (WebKit::LocalStorageDatabase::LocalStorageDatabase):
+ * NetworkProcess/WebStorage/LocalStorageDatabase.h:
+ * NetworkProcess/WebStorage/LocalStorageNamespace.cpp:
+ (WebKit::LocalStorageNamespace::getOrCreateStorageArea):
+ * NetworkProcess/WebStorage/LocalStorageNamespace.h:
+ * NetworkProcess/WebStorage/SessionStorageNamespace.cpp:
+ (WebKit::SessionStorageNamespace::getOrCreateStorageArea):
+ * NetworkProcess/WebStorage/SessionStorageNamespace.h:
+ * NetworkProcess/WebStorage/StorageArea.cpp:
+ (WebKit::StorageArea::StorageArea):
+ * NetworkProcess/WebStorage/StorageArea.h:
+ * NetworkProcess/WebStorage/StorageManager.cpp:
+ (WebKit::StorageManager::createLocalStorageArea):
+ (WebKit::StorageManager::createTransientLocalStorageArea):
+ (WebKit::StorageManager::createSessionStorageArea):
+ * NetworkProcess/WebStorage/StorageManager.h:
+ * NetworkProcess/WebStorage/StorageManagerSet.cpp:
+ (WebKit::StorageManagerSet::StorageManagerSet):
+ (WebKit::StorageManagerSet::suspend):
+ (WebKit::StorageManagerSet::resume):
+ * NetworkProcess/WebStorage/StorageManagerSet.h:
+ (WebKit::StorageManagerSet::WTF_GUARDED_BY_LOCK): Deleted.
+ * NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp:
+ (WebKit::TransientLocalStorageNamespace::getOrCreateStorageArea):
+ * NetworkProcess/WebStorage/TransientLocalStorageNamespace.h:
+
2021-08-11 Dana Estra <[email protected]>
Start smooth keyboard scrolling animation when pageUp or pageDown key is pressed.
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -52,6 +52,7 @@
#include <wtf/RobinHoodHashMap.h>
#include <wtf/Scope.h>
#include <wtf/StdSet.h>
+#include <wtf/SuspendableWorkQueue.h>
#include <wtf/text/StringBuilder.h>
namespace WebKit {
@@ -346,7 +347,7 @@
return map;
}
-ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost, const String& storageDirectoryPath, PAL::SessionID sessionID)
+ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore& store, SuspendableWorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost, const String& storageDirectoryPath, PAL::SessionID sessionID)
: ResourceLoadStatisticsStore(store, workQueue, shouldIncludeLocalhost)
, m_storageDirectoryPath(FileSystem::pathByAppendingComponent(storageDirectoryPath, "observations.db"_s))
, m_transaction(m_database)
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -38,7 +38,6 @@
#include <wtf/Scope.h>
#include <wtf/StdSet.h>
#include <wtf/Vector.h>
-#include <wtf/WorkQueue.h>
namespace WebCore {
class SQLiteDatabase;
@@ -76,7 +75,7 @@
// This is always constructed / used / destroyed on the WebResourceLoadStatisticsStore's statistics queue.
class ResourceLoadStatisticsDatabaseStore final : public ResourceLoadStatisticsStore {
public:
- ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost, const String& storageDirectoryPath, PAL::SessionID);
+ ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore&, SuspendableWorkQueue&, ShouldIncludeLocalhost, const String& storageDirectoryPath, PAL::SessionID);
~ResourceLoadStatisticsDatabaseStore();
static HashSet<ResourceLoadStatisticsDatabaseStore*>& allStores();
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -69,7 +69,7 @@
statisticsMap.remove(statisticsToPrune[i].domain);
}
-ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost)
+ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore& store, SuspendableWorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost)
: ResourceLoadStatisticsStore(store, workQueue, shouldIncludeLocalhost)
{
RELEASE_ASSERT(!RunLoop::isMain());
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -32,7 +32,6 @@
#include <wtf/CompletionHandler.h>
#include <wtf/Vector.h>
#include <wtf/WeakPtr.h>
-#include <wtf/WorkQueue.h>
namespace WebCore {
class KeyedDecoder;
@@ -47,7 +46,7 @@
// This is always constructed / used / destroyed on the WebResourceLoadStatisticsStore's statistics queue.
class ResourceLoadStatisticsMemoryStore final : public ResourceLoadStatisticsStore {
public:
- ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost);
+ ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore&, SuspendableWorkQueue&, ShouldIncludeLocalhost);
void clear(CompletionHandler<void()>&&) override;
bool isEmpty() const override;
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -106,7 +106,7 @@
return secondsSinceEpoch() <= other.secondsSinceEpoch();
}
-ResourceLoadStatisticsStore::ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost)
+ResourceLoadStatisticsStore::ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore& store, SuspendableWorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost)
: m_store(store)
, m_workQueue(workQueue)
, m_shouldIncludeLocalhost(shouldIncludeLocalhost)
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -32,9 +32,9 @@
#include <_javascript_Core/ConsoleTypes.h>
#include <WebCore/FrameIdentifier.h>
#include <wtf/CompletionHandler.h>
+#include <wtf/Forward.h>
#include <wtf/Vector.h>
#include <wtf/WeakPtr.h>
-#include <wtf/WorkQueue.h>
#if HAVE(CORE_PREDICTION)
#include "ResourceLoadStatisticsClassifierCocoa.h"
@@ -217,7 +217,7 @@
protected:
static unsigned computeImportance(const WebCore::ResourceLoadStatistics&);
- ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost);
+ ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore&, SuspendableWorkQueue&, ShouldIncludeLocalhost);
bool dataRecordsBeingRemoved() const { return m_dataRecordsBeingRemoved; }
@@ -228,7 +228,7 @@
virtual void pruneStatisticsIfNeeded() = 0;
WebResourceLoadStatisticsStore& store() { return m_store; }
- Ref<WorkQueue>& workQueue() { return m_workQueue; }
+ Ref<SuspendableWorkQueue>& workQueue() { return m_workQueue; }
#if HAVE(CORE_PREDICTION)
ResourceLoadStatisticsClassifierCocoa& classifier() { return m_resourceLoadStatisticsClassifier; }
#else
@@ -278,7 +278,7 @@
void updateClientSideCookiesAgeCap();
WebResourceLoadStatisticsStore& m_store;
- Ref<WorkQueue> m_workQueue;
+ Ref<SuspendableWorkQueue> m_workQueue;
#if HAVE(CORE_PREDICTION)
ResourceLoadStatisticsClassifierCocoa m_resourceLoadStatisticsClassifier;
#else
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -54,16 +54,12 @@
#include <wtf/CallbackAggregator.h>
#include <wtf/CrossThreadCopier.h>
#include <wtf/NeverDestroyed.h>
+#include <wtf/SuspendableWorkQueue.h>
#include <wtf/threads/BinarySemaphore.h>
namespace WebKit {
using namespace WebCore;
-static Lock globalSuspensionLock;
-static Condition globalSuspensionCondition;
-static bool globalShouldSuspend WTF_GUARDED_BY_LOCK(globalSuspensionLock) { false };
-static uint64_t globalSuspensionIdentifier WTF_GUARDED_BY_LOCK(globalSuspensionLock) { 0 };
-
const OptionSet<WebsiteDataType>& WebResourceLoadStatisticsStore::monitoredDataTypes()
{
static NeverDestroyed<OptionSet<WebsiteDataType>> dataTypes(std::initializer_list<WebsiteDataType>({
@@ -147,9 +143,9 @@
});
}
-static Ref<WorkQueue> sharedStatisticsQueue()
+static Ref<SuspendableWorkQueue> sharedStatisticsQueue()
{
- static NeverDestroyed<Ref<WorkQueue>> queue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::Type::Serial, WorkQueue::QOS::Utility));
+ static NeverDestroyed<Ref<SuspendableWorkQueue>> queue(SuspendableWorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::QOS::Utility));
return queue.get().copyRef();
}
@@ -1448,24 +1444,12 @@
void WebResourceLoadStatisticsStore::suspend(CompletionHandler<void()>&& completionHandler)
{
- Locker suspensionLocker { globalSuspensionLock };
- globalShouldSuspend = true;
+ ASSERT(RunLoop::isMain());
- sharedStatisticsQueue()->dispatch([suspensionIdentifier = ++globalSuspensionIdentifier, completionHandler = WTFMove(completionHandler)] () mutable {
- Locker suspensionLocker { globalSuspensionLock };
- if (!globalShouldSuspend || suspensionIdentifier != globalSuspensionIdentifier) {
- postTaskReply(WTFMove(completionHandler));
- return;
- }
-
+ sharedStatisticsQueue()->suspend([]() mutable {
for (auto& databaseStore : ResourceLoadStatisticsDatabaseStore::allStores())
databaseStore->interrupt();
-
- postTaskReply(WTFMove(completionHandler));
-
- while (globalShouldSuspend)
- globalSuspensionCondition.wait(globalSuspensionLock);
- });
+ }, WTFMove(completionHandler));
}
void WebResourceLoadStatisticsStore::resume()
@@ -1472,9 +1456,7 @@
{
ASSERT(RunLoop::isMain());
- Locker suspensionLocker { globalSuspensionLock };
- globalShouldSuspend = false;
- globalSuspensionCondition.notifyOne();
+ sharedStatisticsQueue()->resume();
}
void WebResourceLoadStatisticsStore::insertExpiredStatisticForTesting(const RegistrableDomain& domain, unsigned numberOfOperatingDaysPassed, bool hadUserInteraction, bool isScheduledForAllButCookieDataRemoval, bool isPrevalent, CompletionHandler<void()>&& completionHandler)
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -42,6 +42,7 @@
#include <WebCore/ResourceLoadObserver.h>
#include <wtf/CompletionHandler.h>
#include <wtf/Condition.h>
+#include <wtf/Forward.h>
#include <wtf/Lock.h>
#include <wtf/RunLoop.h>
#include <wtf/ThreadSafeRefCounted.h>
@@ -50,10 +51,6 @@
#include <wtf/WeakPtr.h>
#include <wtf/text/WTFString.h>
-namespace WTF {
-class WorkQueue;
-}
-
namespace WebCore {
class ResourceRequest;
struct ResourceLoadStatistics;
@@ -144,7 +141,7 @@
static const OptionSet<WebsiteDataType>& monitoredDataTypes();
- WTF::WorkQueue& statisticsQueue() { return m_statisticsQueue.get(); }
+ SuspendableWorkQueue& statisticsQueue() { return m_statisticsQueue.get(); }
void populateMemoryStoreFromDisk(CompletionHandler<void()>&&);
void setNotifyPagesWhenDataRecordsWereScanned(bool);
@@ -276,7 +273,7 @@
void destroyResourceLoadStatisticsStore(CompletionHandler<void()>&&);
WeakPtr<NetworkSession> m_networkSession;
- Ref<WTF::WorkQueue> m_statisticsQueue;
+ Ref<SuspendableWorkQueue> m_statisticsQueue;
std::unique_ptr<ResourceLoadStatisticsStore> m_statisticsStore;
RunLoop::Timer<WebResourceLoadStatisticsStore> m_dailyTasksTimer;
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -34,6 +34,7 @@
#include <wtf/FileSystem.h>
#include <wtf/HashMap.h>
#include <wtf/RefPtr.h>
+#include <wtf/SuspendableWorkQueue.h>
namespace WebKit {
using namespace WebCore;
@@ -42,12 +43,12 @@
constexpr unsigned maximumSizeForValuesKeptInMemory { 1024 }; // 1 KB
constexpr Seconds transactionDuration { 500_ms };
-Ref<LocalStorageDatabase> LocalStorageDatabase::create(Ref<WorkQueue>&& workQueue, String&& databasePath, unsigned quotaInBytes)
+Ref<LocalStorageDatabase> LocalStorageDatabase::create(Ref<SuspendableWorkQueue>&& workQueue, String&& databasePath, unsigned quotaInBytes)
{
return adoptRef(*new LocalStorageDatabase(WTFMove(workQueue), WTFMove(databasePath), quotaInBytes));
}
-LocalStorageDatabase::LocalStorageDatabase(Ref<WorkQueue>&& workQueue, String&& databasePath, unsigned quotaInBytes)
+LocalStorageDatabase::LocalStorageDatabase(Ref<SuspendableWorkQueue>&& workQueue, String&& databasePath, unsigned quotaInBytes)
: m_workQueue(WTFMove(workQueue))
, m_databasePath(WTFMove(databasePath))
, m_quotaInBytes(quotaInBytes)
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -26,9 +26,9 @@
#pragma once
#include <WebCore/SQLiteDatabase.h>
+#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/WeakPtr.h>
-#include <wtf/WorkQueue.h>
namespace WebCore {
class SQLiteStatementAutoResetScope;
@@ -41,7 +41,7 @@
class LocalStorageDatabase : public RefCounted<LocalStorageDatabase>, public CanMakeWeakPtr<LocalStorageDatabase> {
public:
- static Ref<LocalStorageDatabase> create(Ref<WorkQueue>&&, String&& databasePath, unsigned quotaInBytes);
+ static Ref<LocalStorageDatabase> create(Ref<SuspendableWorkQueue>&&, String&& databasePath, unsigned quotaInBytes);
~LocalStorageDatabase();
HashMap<String, String> items() const;
@@ -58,7 +58,7 @@
void handleLowMemoryWarning();
private:
- LocalStorageDatabase(Ref<WorkQueue>&&, String&& databasePath, unsigned quotaInBytes);
+ LocalStorageDatabase(Ref<SuspendableWorkQueue>&&, String&& databasePath, unsigned quotaInBytes);
enum class ShouldCreateDatabase : bool { No, Yes };
bool openDatabase(ShouldCreateDatabase);
@@ -71,7 +71,7 @@
WebCore::SQLiteStatementAutoResetScope scopedStatement(std::unique_ptr<WebCore::SQLiteStatement>&, ASCIILiteral query) const;
- Ref<WorkQueue> m_workQueue;
+ Ref<SuspendableWorkQueue> m_workQueue;
String m_databasePath;
mutable WebCore::SQLiteDatabase m_database;
std::unique_ptr<WebCore::SQLiteTransaction> m_transaction;
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -47,7 +47,7 @@
ASSERT(!RunLoop::isMain());
}
-StorageArea& LocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, IsEphemeral isEphemeral, Ref<WorkQueue>&& workQueue)
+StorageArea& LocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, IsEphemeral isEphemeral, Ref<SuspendableWorkQueue>&& workQueue)
{
ASSERT(!RunLoop::isMain());
return *m_storageAreaMap.ensure(securityOrigin, [&]() mutable {
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -31,7 +31,6 @@
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/WeakPtr.h>
-#include <wtf/WorkQueue.h>
namespace WebKit {
@@ -48,7 +47,7 @@
StorageManager* storageManager() const { return &m_storageManager; }
enum class IsEphemeral : bool { No, Yes };
- StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, IsEphemeral, Ref<WorkQueue>&&);
+ StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, IsEphemeral, Ref<SuspendableWorkQueue>&&);
void clearStorageAreasMatchingOrigin(const WebCore::SecurityOriginData&);
void clearAllStorageAreas();
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -43,7 +43,7 @@
ASSERT(!RunLoop::isMain());
}
-StorageArea& SessionStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, Ref<WorkQueue>&& workQueue)
+StorageArea& SessionStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, Ref<SuspendableWorkQueue>&& workQueue)
{
ASSERT(!RunLoop::isMain());
return *m_storageAreaMap.ensure(securityOrigin, [&]() mutable {
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -44,7 +44,7 @@
bool isEmpty() const { return m_storageAreaMap.isEmpty(); }
- StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, Ref<WorkQueue>&&);
+ StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, Ref<SuspendableWorkQueue>&&);
void cloneTo(SessionStorageNamespace& newSessionStorageNamespace);
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -30,12 +30,13 @@
#include "LocalStorageNamespace.h"
#include "StorageAreaMapMessages.h"
#include "StorageManager.h"
+#include <wtf/SuspendableWorkQueue.h>
namespace WebKit {
using namespace WebCore;
-StorageArea::StorageArea(LocalStorageNamespace* localStorageNamespace, const SecurityOriginData& securityOrigin, unsigned quotaInBytes, Ref<WorkQueue>&& queue)
+StorageArea::StorageArea(LocalStorageNamespace* localStorageNamespace, const SecurityOriginData& securityOrigin, unsigned quotaInBytes, Ref<SuspendableWorkQueue>&& queue)
: m_localStorageNamespace(makeWeakPtr(localStorageNamespace))
, m_securityOrigin(securityOrigin)
, m_quotaInBytes(quotaInBytes)
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -48,7 +48,7 @@
public:
using Identifier = StorageAreaIdentifier;
- StorageArea(LocalStorageNamespace*, const WebCore::SecurityOriginData&, unsigned quotaInBytes, Ref<WorkQueue>&&);
+ StorageArea(LocalStorageNamespace*, const WebCore::SecurityOriginData&, unsigned quotaInBytes, Ref<SuspendableWorkQueue>&&);
~StorageArea();
const WebCore::SecurityOriginData& securityOrigin() const { return m_securityOrigin; }
@@ -90,7 +90,7 @@
HashSet<IPC::Connection::UniqueID> m_eventListeners;
Identifier m_identifier;
- Ref<WorkQueue> m_queue;
+ Ref<SuspendableWorkQueue> m_queue;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -41,6 +41,7 @@
#include <memory>
#include <wtf/CrossThreadCopier.h>
#include <wtf/FileSystem.h>
+#include <wtf/SuspendableWorkQueue.h>
#include <wtf/WorkQueue.h>
namespace WebKit {
@@ -211,7 +212,7 @@
}
}
-StorageArea* StorageManager::createLocalStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& origin, Ref<WorkQueue>&& workQueue)
+StorageArea* StorageManager::createLocalStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& origin, Ref<SuspendableWorkQueue>&& workQueue)
{
ASSERT(!RunLoop::isMain());
@@ -221,7 +222,7 @@
return nullptr;
}
-StorageArea* StorageManager::createTransientLocalStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& topLevelOrigin, SecurityOriginData&& origin, Ref<WorkQueue>&& workQueue)
+StorageArea* StorageManager::createTransientLocalStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& topLevelOrigin, SecurityOriginData&& origin, Ref<SuspendableWorkQueue>&& workQueue)
{
ASSERT(!RunLoop::isMain());
ASSERT((HashMap<StorageNamespaceIdentifier, RefPtr<TransientLocalStorageNamespace>>::isValidKey(storageNamespaceID)));
@@ -232,7 +233,7 @@
return nullptr;
}
-StorageArea* StorageManager::createSessionStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& origin, Ref<WorkQueue>&& workQueue)
+StorageArea* StorageManager::createSessionStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& origin, Ref<SuspendableWorkQueue>&& workQueue)
{
ASSERT(!RunLoop::isMain());
ASSERT((HashMap<StorageNamespaceIdentifier, RefPtr<SessionStorageNamespace>>::isValidKey(storageNamespaceID)));
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -80,9 +80,9 @@
static const unsigned localStorageDatabaseQuotaInBytes;
- StorageArea* createLocalStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, Ref<WorkQueue>&&);
- StorageArea* createTransientLocalStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, WebCore::SecurityOriginData&&, Ref<WorkQueue>&&);
- StorageArea* createSessionStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, Ref<WorkQueue>&&);
+ StorageArea* createLocalStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, Ref<SuspendableWorkQueue>&&);
+ StorageArea* createTransientLocalStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, WebCore::SecurityOriginData&&, Ref<SuspendableWorkQueue>&&);
+ StorageArea* createSessionStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, Ref<SuspendableWorkQueue>&&);
Vector<StorageAreaIdentifier> allStorageAreaIdentifiers() const;
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -41,7 +41,7 @@
}
StorageManagerSet::StorageManagerSet()
- : m_queue(WorkQueue::create("com.apple.WebKit.WebStorage"))
+ : m_queue(SuspendableWorkQueue::create("com.apple.WebKit.WebStorage"))
{
ASSERT(RunLoop::isMain());
@@ -177,25 +177,9 @@
{
ASSERT(RunLoop::isMain());
- Locker suspensionLocker { m_suspensionLock };
- m_shouldSuspend = true;
-
- m_queue->dispatch([this, protectedThis = makeRef(*this), suspensionIdentifier = ++m_suspensionIdentifier, completionHandler = WTFMove(completionHandler)] () mutable {
- Locker suspensionLocker { m_suspensionLock };
- if (!m_shouldSuspend || suspensionIdentifier != m_suspensionIdentifier) {
- RunLoop::main().dispatch(WTFMove(completionHandler));
- return;
- }
-
- // Make sure we flush local storage to disk before we suspend the thread as we want to make sure any pending
- // SQL transaction has been committed.
- flushLocalStorage();
-
- RunLoop::main().dispatch(WTFMove(completionHandler));
-
- while (m_shouldSuspend)
- m_suspensionCondition.wait(m_suspensionLock);
- });
+ m_queue->suspend([protectedThis = makeRef(*this)] {
+ protectedThis->flushLocalStorage();
+ }, WTFMove(completionHandler));
}
void StorageManagerSet::resume()
@@ -202,9 +186,7 @@
{
ASSERT(RunLoop::isMain());
- Locker suspensionLocker { m_suspensionLock };
- m_shouldSuspend = false;
- m_suspensionCondition.notifyOne();
+ m_queue->resume();
}
void StorageManagerSet::getSessionStorageOrigins(PAL::SessionID sessionID, GetOriginsCallback&& completionHandler)
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -33,6 +33,7 @@
#include <pal/SessionID.h>
#include <wtf/Condition.h>
#include <wtf/Lock.h>
+#include <wtf/SuspendableWorkQueue.h>
#include <wtf/WeakPtr.h>
using WebCore::SecurityOriginData;
@@ -98,12 +99,7 @@
HashMap<StorageAreaIdentifier, WeakPtr<StorageArea>> m_storageAreas;
HashSet<IPC::Connection::UniqueID> m_connections;
- Ref<WorkQueue> m_queue;
-
- Lock m_suspensionLock;
- Condition m_suspensionCondition;
- bool m_shouldSuspend WTF_GUARDED_BY_LOCK(m_suspensionLock) { false };
- uint64_t m_suspensionIdentifier WTF_GUARDED_BY_LOCK(m_suspensionLock) { 0 };
+ Ref<SuspendableWorkQueue> m_queue;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp 2021-08-11 22:25:56 UTC (rev 280934)
@@ -44,7 +44,7 @@
ASSERT(!RunLoop::isMain());
}
-StorageArea& TransientLocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, Ref<WorkQueue>&& workQueue)
+StorageArea& TransientLocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, Ref<SuspendableWorkQueue>&& workQueue)
{
ASSERT(!RunLoop::isMain());
return *m_storageAreaMap.ensure(securityOrigin, [&]() mutable {
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.h (280933 => 280934)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.h 2021-08-11 22:21:57 UTC (rev 280933)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.h 2021-08-11 22:25:56 UTC (rev 280934)
@@ -42,7 +42,7 @@
TransientLocalStorageNamespace();
~TransientLocalStorageNamespace();
- StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, Ref<WorkQueue>&&);
+ StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, Ref<SuspendableWorkQueue>&&);
Vector<WebCore::SecurityOriginData> origins() const;
void clearStorageAreasMatchingOrigin(const WebCore::SecurityOriginData&);