Changeset 280934 in webkit
- Timestamp:
- Aug 11, 2021, 3:25:56 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 28 edited
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/WTF.xcodeproj/project.pbxproj (modified) (4 diffs)
-
WTF/wtf/CMakeLists.txt (modified) (2 diffs)
-
WTF/wtf/Forward.h (modified) (2 diffs)
-
WTF/wtf/SuspendableWorkQueue.cpp (added)
-
WTF/wtf/SuspendableWorkQueue.h (added)
-
WTF/wtf/WorkQueue.h (modified) (3 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (modified) (2 diffs)
-
WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h (modified) (2 diffs)
-
WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp (modified) (1 diff)
-
WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h (modified) (2 diffs)
-
WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp (modified) (1 diff)
-
WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h (modified) (4 diffs)
-
WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (modified) (4 diffs)
-
WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (modified) (4 diffs)
-
WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp (modified) (2 diffs)
-
WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h (modified) (4 diffs)
-
WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.cpp (modified) (1 diff)
-
WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.h (modified) (2 diffs)
-
WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.cpp (modified) (1 diff)
-
WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.h (modified) (1 diff)
-
WebKit/NetworkProcess/WebStorage/StorageArea.cpp (modified) (2 diffs)
-
WebKit/NetworkProcess/WebStorage/StorageArea.h (modified) (2 diffs)
-
WebKit/NetworkProcess/WebStorage/StorageManager.cpp (modified) (4 diffs)
-
WebKit/NetworkProcess/WebStorage/StorageManager.h (modified) (1 diff)
-
WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp (modified) (3 diffs)
-
WebKit/NetworkProcess/WebStorage/StorageManagerSet.h (modified) (2 diffs)
-
WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp (modified) (1 diff)
-
WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r280908 r280934 1 2021-08-11 Sihui Liu <sihui_liu@apple.com> 2 3 Suspend WorkQueue of ResourceLoadStatistics and LocalStorage sooner 4 https://bugs.webkit.org/show_bug.cgi?id=228748 5 <rdar://problem/81626714> 6 7 Reviewed by Chris Dumez. 8 9 Add SuspendableWorkQueue that would perform suspend check before each task. 10 11 * WTF.xcodeproj/project.pbxproj: 12 * wtf/CMakeLists.txt: 13 * wtf/Forward.h: 14 * wtf/SuspendableWorkQueue.cpp: Added. 15 (WTF::SuspendableWorkQueue::create): 16 (WTF::SuspendableWorkQueue::SuspendableWorkQueue): 17 (WTF::SuspendableWorkQueue::suspend): 18 (WTF::SuspendableWorkQueue::resume): 19 (WTF::SuspendableWorkQueue::dispatch): 20 (WTF::SuspendableWorkQueue::dispatchAfter): 21 (WTF::SuspendableWorkQueue::dispatchSync): 22 (WTF::SuspendableWorkQueue::invokeAllSuspensionCompletionHandlers): 23 (WTF::SuspendableWorkQueue::suspendIfNeeded): 24 * wtf/SuspendableWorkQueue.h: Added. 25 * wtf/WorkQueue.h: 26 (): Deleted. 27 1 28 2021-08-11 Youenn Fablet <youenn@apple.com> 2 29 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r280795 r280934 103 103 93934BD318A1E8C300D0D6A1 /* StringViewCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD218A1E8C300D0D6A1 /* StringViewCocoa.mm */; }; 104 104 93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */; }; 105 93B07ED826B8717000A09B34 /* SuspendableWorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B07ED726B8715B00A09B34 /* SuspendableWorkQueue.cpp */; }; 105 106 93B5B44E2213D616004B7AA7 /* HexNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B5B44D2213D616004B7AA7 /* HexNumber.cpp */; }; 106 107 93B5B45122171EEA004B7AA7 /* Logger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B5B45022171EE9004B7AA7 /* Logger.cpp */; }; … … 511 512 93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringViewCF.cpp; sourceTree = "<group>"; }; 512 513 93AC91A718942FC400244939 /* LChar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LChar.h; sourceTree = "<group>"; }; 514 93B07ED626B86BB500A09B34 /* SuspendableWorkQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SuspendableWorkQueue.h; sourceTree = "<group>"; }; 515 93B07ED726B8715B00A09B34 /* SuspendableWorkQueue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SuspendableWorkQueue.cpp; sourceTree = "<group>"; }; 513 516 93B5B44D2213D616004B7AA7 /* HexNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HexNumber.cpp; sourceTree = "<group>"; }; 514 517 93B5B45022171EE9004B7AA7 /* Logger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Logger.cpp; sourceTree = "<group>"; }; … … 1312 1315 0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */, 1313 1316 0FDDBFA61666DFA300C55FEF /* StringPrintStream.h */, 1317 93B07ED726B8715B00A09B34 /* SuspendableWorkQueue.cpp */, 1318 93B07ED626B86BB500A09B34 /* SuspendableWorkQueue.h */, 1314 1319 5597F82C1D94B9970066BC21 /* SynchronizedFixedQueue.h */, 1315 1320 E3E158251EADA53C004A079D /* SystemFree.h */, … … 1825 1830 93934BD318A1E8C300D0D6A1 /* StringViewCocoa.mm in Sources */, 1826 1831 A8A473B7151A825B004123FF /* strtod.cc in Sources */, 1832 93B07ED826B8717000A09B34 /* SuspendableWorkQueue.cpp in Sources */, 1827 1833 52183012C99E476A84EEBEA8 /* SymbolImpl.cpp in Sources */, 1828 1834 70A993FE1AD7151300FA615B /* SymbolRegistry.cpp in Sources */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r280795 r280934 267 267 StringHashDumpContext.h 268 268 StringPrintStream.h 269 SuspendableWorkQueue.h 269 270 SynchronizedFixedQueue.h 270 271 SystemFree.h … … 463 464 StackTrace.cpp 464 465 StringPrintStream.cpp 466 SuspendableWorkQueue.cpp 465 467 ThreadGroup.cpp 466 468 ThreadMessage.cpp -
trunk/Source/WTF/wtf/Forward.h
r280559 r280934 45 45 class StringImpl; 46 46 class StringView; 47 class SuspendableWorkQueue; 47 48 class TextPosition; 48 49 class TextStream; … … 152 153 using WTF::StringParsingBuffer; 153 154 using WTF::StringView; 155 using WTF::SuspendableWorkQueue; 154 156 using WTF::TextPosition; 155 157 using WTF::TextStream; -
trunk/Source/WTF/wtf/WorkQueue.h
r274307 r280934 42 42 namespace WTF { 43 43 44 class WorkQueue final: public FunctionDispatcher {44 class WorkQueue : public FunctionDispatcher { 45 45 46 46 public: … … 54 54 55 55 WTF_EXPORT_PRIVATE static Ref<WorkQueue> create(const char* name, Type = Type::Serial, QOS = QOS::Default); 56 ~WorkQueue() final;56 ~WorkQueue() override; 57 57 58 WTF_EXPORT_PRIVATE void dispatch(Function<void()>&&) final;59 WTF_EXPORT_PRIVATE v oid dispatchAfter(Seconds, Function<void()>&&);60 WTF_EXPORT_PRIVATE v oid dispatchSync(Function<void()>&&);58 WTF_EXPORT_PRIVATE void dispatch(Function<void()>&&) override; 59 WTF_EXPORT_PRIVATE virtual void dispatchAfter(Seconds, Function<void()>&&); 60 WTF_EXPORT_PRIVATE virtual void dispatchSync(Function<void()>&&); 61 61 62 62 WTF_EXPORT_PRIVATE static void concurrentApply(size_t iterations, WTF::Function<void(size_t index)>&&); … … 68 68 #endif 69 69 70 pr ivate:70 protected: 71 71 WorkQueue(const char* name, Type, QOS); 72 72 73 private: 73 74 static Ref<WorkQueue> constructMainWorkQueue(); 74 75 #if USE(COCOA_EVENT_LOOP) -
trunk/Source/WebKit/ChangeLog
r280928 r280934 1 2021-08-11 Sihui Liu <sihui_liu@apple.com> 2 3 Suspend WorkQueue of ResourceLoadStatistics and LocalStorage sooner 4 https://bugs.webkit.org/show_bug.cgi?id=228748 5 <rdar://problem/81626714> 6 7 Reviewed by Chris Dumez. 8 9 When suspending ResourceLoadStatistics and LocalStorage, we dispatched a suspend task, which waits on a 10 condition, to their WorkQueue. That means the queue will be suspended after completing all tasks scheduled 11 before the suspend task. These tasks may take a long time to complete and assertion may be timed out. 12 13 When network process receives PrepareToSuspend message, we want the queues to suspend as soon as possible. To 14 achieve that, now we check if the queue needs to be suspended before each task, which ensures the queue 15 execute as most one task after suspend(). 16 17 * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: 18 (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore): 19 * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h: 20 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: 21 (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore): 22 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h: 23 * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: 24 (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore): 25 * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: 26 (WebKit::ResourceLoadStatisticsStore::workQueue): 27 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 28 (WebKit::sharedStatisticsQueue): 29 (WebKit::WebResourceLoadStatisticsStore::suspend): 30 (WebKit::WebResourceLoadStatisticsStore::resume): 31 (WebKit::WTF_GUARDED_BY_LOCK): Deleted. 32 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: 33 * NetworkProcess/WebStorage/LocalStorageDatabase.cpp: 34 (WebKit::LocalStorageDatabase::create): 35 (WebKit::LocalStorageDatabase::LocalStorageDatabase): 36 * NetworkProcess/WebStorage/LocalStorageDatabase.h: 37 * NetworkProcess/WebStorage/LocalStorageNamespace.cpp: 38 (WebKit::LocalStorageNamespace::getOrCreateStorageArea): 39 * NetworkProcess/WebStorage/LocalStorageNamespace.h: 40 * NetworkProcess/WebStorage/SessionStorageNamespace.cpp: 41 (WebKit::SessionStorageNamespace::getOrCreateStorageArea): 42 * NetworkProcess/WebStorage/SessionStorageNamespace.h: 43 * NetworkProcess/WebStorage/StorageArea.cpp: 44 (WebKit::StorageArea::StorageArea): 45 * NetworkProcess/WebStorage/StorageArea.h: 46 * NetworkProcess/WebStorage/StorageManager.cpp: 47 (WebKit::StorageManager::createLocalStorageArea): 48 (WebKit::StorageManager::createTransientLocalStorageArea): 49 (WebKit::StorageManager::createSessionStorageArea): 50 * NetworkProcess/WebStorage/StorageManager.h: 51 * NetworkProcess/WebStorage/StorageManagerSet.cpp: 52 (WebKit::StorageManagerSet::StorageManagerSet): 53 (WebKit::StorageManagerSet::suspend): 54 (WebKit::StorageManagerSet::resume): 55 * NetworkProcess/WebStorage/StorageManagerSet.h: 56 (WebKit::StorageManagerSet::WTF_GUARDED_BY_LOCK): Deleted. 57 * NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp: 58 (WebKit::TransientLocalStorageNamespace::getOrCreateStorageArea): 59 * NetworkProcess/WebStorage/TransientLocalStorageNamespace.h: 60 1 61 2021-08-11 Dana Estra <destra@apple.com> 2 62 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp
r280157 r280934 53 53 #include <wtf/Scope.h> 54 54 #include <wtf/StdSet.h> 55 #include <wtf/SuspendableWorkQueue.h> 55 56 #include <wtf/text/StringBuilder.h> 56 57 … … 347 348 } 348 349 349 ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost, const String& storageDirectoryPath, PAL::SessionID sessionID)350 ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore& store, SuspendableWorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost, const String& storageDirectoryPath, PAL::SessionID sessionID) 350 351 : ResourceLoadStatisticsStore(store, workQueue, shouldIncludeLocalhost) 351 352 , m_storageDirectoryPath(FileSystem::pathByAppendingComponent(storageDirectoryPath, "observations.db"_s)) -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h
r280157 r280934 39 39 #include <wtf/StdSet.h> 40 40 #include <wtf/Vector.h> 41 #include <wtf/WorkQueue.h>42 41 43 42 namespace WebCore { … … 77 76 class ResourceLoadStatisticsDatabaseStore final : public ResourceLoadStatisticsStore { 78 77 public: 79 ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost, const String& storageDirectoryPath, PAL::SessionID);78 ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore&, SuspendableWorkQueue&, ShouldIncludeLocalhost, const String& storageDirectoryPath, PAL::SessionID); 80 79 ~ResourceLoadStatisticsDatabaseStore(); 81 80 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
r278253 r280934 70 70 } 71 71 72 ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost)72 ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore& store, SuspendableWorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost) 73 73 : ResourceLoadStatisticsStore(store, workQueue, shouldIncludeLocalhost) 74 74 { -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h
r278253 r280934 33 33 #include <wtf/Vector.h> 34 34 #include <wtf/WeakPtr.h> 35 #include <wtf/WorkQueue.h>36 35 37 36 namespace WebCore { … … 48 47 class ResourceLoadStatisticsMemoryStore final : public ResourceLoadStatisticsStore { 49 48 public: 50 ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost);49 ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore&, SuspendableWorkQueue&, ShouldIncludeLocalhost); 51 50 52 51 void clear(CompletionHandler<void()>&&) override; -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp
r278185 r280934 107 107 } 108 108 109 ResourceLoadStatisticsStore::ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost)109 ResourceLoadStatisticsStore::ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore& store, SuspendableWorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost) 110 110 : m_store(store) 111 111 , m_workQueue(workQueue) -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h
r278253 r280934 33 33 #include <WebCore/FrameIdentifier.h> 34 34 #include <wtf/CompletionHandler.h> 35 #include <wtf/Forward.h> 35 36 #include <wtf/Vector.h> 36 37 #include <wtf/WeakPtr.h> 37 #include <wtf/WorkQueue.h>38 38 39 39 #if HAVE(CORE_PREDICTION) … … 218 218 static unsigned computeImportance(const WebCore::ResourceLoadStatistics&); 219 219 220 ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost);220 ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore&, SuspendableWorkQueue&, ShouldIncludeLocalhost); 221 221 222 222 bool dataRecordsBeingRemoved() const { return m_dataRecordsBeingRemoved; } … … 229 229 230 230 WebResourceLoadStatisticsStore& store() { return m_store; } 231 Ref< WorkQueue>& workQueue() { return m_workQueue; }231 Ref<SuspendableWorkQueue>& workQueue() { return m_workQueue; } 232 232 #if HAVE(CORE_PREDICTION) 233 233 ResourceLoadStatisticsClassifierCocoa& classifier() { return m_resourceLoadStatisticsClassifier; } … … 279 279 280 280 WebResourceLoadStatisticsStore& m_store; 281 Ref< WorkQueue> m_workQueue;281 Ref<SuspendableWorkQueue> m_workQueue; 282 282 #if HAVE(CORE_PREDICTION) 283 283 ResourceLoadStatisticsClassifierCocoa m_resourceLoadStatisticsClassifier; -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
r280110 r280934 55 55 #include <wtf/CrossThreadCopier.h> 56 56 #include <wtf/NeverDestroyed.h> 57 #include <wtf/SuspendableWorkQueue.h> 57 58 #include <wtf/threads/BinarySemaphore.h> 58 59 59 60 namespace WebKit { 60 61 using namespace WebCore; 61 62 static Lock globalSuspensionLock;63 static Condition globalSuspensionCondition;64 static bool globalShouldSuspend WTF_GUARDED_BY_LOCK(globalSuspensionLock) { false };65 static uint64_t globalSuspensionIdentifier WTF_GUARDED_BY_LOCK(globalSuspensionLock) { 0 };66 62 67 63 const OptionSet<WebsiteDataType>& WebResourceLoadStatisticsStore::monitoredDataTypes() … … 148 144 } 149 145 150 static Ref< WorkQueue> sharedStatisticsQueue()151 { 152 static NeverDestroyed<Ref< WorkQueue>> queue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::Type::Serial,WorkQueue::QOS::Utility));146 static Ref<SuspendableWorkQueue> sharedStatisticsQueue() 147 { 148 static NeverDestroyed<Ref<SuspendableWorkQueue>> queue(SuspendableWorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::QOS::Utility)); 153 149 return queue.get().copyRef(); 154 150 } … … 1449 1445 void WebResourceLoadStatisticsStore::suspend(CompletionHandler<void()>&& completionHandler) 1450 1446 { 1451 Locker suspensionLocker { globalSuspensionLock }; 1452 globalShouldSuspend = true; 1453 1454 sharedStatisticsQueue()->dispatch([suspensionIdentifier = ++globalSuspensionIdentifier, completionHandler = WTFMove(completionHandler)] () mutable { 1455 Locker suspensionLocker { globalSuspensionLock }; 1456 if (!globalShouldSuspend || suspensionIdentifier != globalSuspensionIdentifier) { 1457 postTaskReply(WTFMove(completionHandler)); 1458 return; 1459 } 1460 1447 ASSERT(RunLoop::isMain()); 1448 1449 sharedStatisticsQueue()->suspend([]() mutable { 1461 1450 for (auto& databaseStore : ResourceLoadStatisticsDatabaseStore::allStores()) 1462 1451 databaseStore->interrupt(); 1463 1464 postTaskReply(WTFMove(completionHandler)); 1465 1466 while (globalShouldSuspend) 1467 globalSuspensionCondition.wait(globalSuspensionLock); 1468 }); 1452 }, WTFMove(completionHandler)); 1469 1453 } 1470 1454 … … 1473 1457 ASSERT(RunLoop::isMain()); 1474 1458 1475 Locker suspensionLocker { globalSuspensionLock }; 1476 globalShouldSuspend = false; 1477 globalSuspensionCondition.notifyOne(); 1459 sharedStatisticsQueue()->resume(); 1478 1460 } 1479 1461 -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
r280110 r280934 43 43 #include <wtf/CompletionHandler.h> 44 44 #include <wtf/Condition.h> 45 #include <wtf/Forward.h> 45 46 #include <wtf/Lock.h> 46 47 #include <wtf/RunLoop.h> … … 50 51 #include <wtf/WeakPtr.h> 51 52 #include <wtf/text/WTFString.h> 52 53 namespace WTF {54 class WorkQueue;55 }56 53 57 54 namespace WebCore { … … 145 142 static const OptionSet<WebsiteDataType>& monitoredDataTypes(); 146 143 147 WTF::WorkQueue& statisticsQueue() { return m_statisticsQueue.get(); }144 SuspendableWorkQueue& statisticsQueue() { return m_statisticsQueue.get(); } 148 145 149 146 void populateMemoryStoreFromDisk(CompletionHandler<void()>&&); … … 277 274 278 275 WeakPtr<NetworkSession> m_networkSession; 279 Ref< WTF::WorkQueue> m_statisticsQueue;276 Ref<SuspendableWorkQueue> m_statisticsQueue; 280 277 std::unique_ptr<ResourceLoadStatisticsStore> m_statisticsStore; 281 278 -
trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp
r278786 r280934 35 35 #include <wtf/HashMap.h> 36 36 #include <wtf/RefPtr.h> 37 #include <wtf/SuspendableWorkQueue.h> 37 38 38 39 namespace WebKit { … … 43 44 constexpr Seconds transactionDuration { 500_ms }; 44 45 45 Ref<LocalStorageDatabase> LocalStorageDatabase::create(Ref< WorkQueue>&& workQueue, String&& databasePath, unsigned quotaInBytes)46 Ref<LocalStorageDatabase> LocalStorageDatabase::create(Ref<SuspendableWorkQueue>&& workQueue, String&& databasePath, unsigned quotaInBytes) 46 47 { 47 48 return adoptRef(*new LocalStorageDatabase(WTFMove(workQueue), WTFMove(databasePath), quotaInBytes)); 48 49 } 49 50 50 LocalStorageDatabase::LocalStorageDatabase(Ref< WorkQueue>&& workQueue, String&& databasePath, unsigned quotaInBytes)51 LocalStorageDatabase::LocalStorageDatabase(Ref<SuspendableWorkQueue>&& workQueue, String&& databasePath, unsigned quotaInBytes) 51 52 : m_workQueue(WTFMove(workQueue)) 52 53 , m_databasePath(WTFMove(databasePath)) -
trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h
r278786 r280934 27 27 28 28 #include <WebCore/SQLiteDatabase.h> 29 #include <wtf/Forward.h> 29 30 #include <wtf/HashMap.h> 30 31 #include <wtf/WeakPtr.h> 31 #include <wtf/WorkQueue.h>32 32 33 33 namespace WebCore { … … 42 42 class LocalStorageDatabase : public RefCounted<LocalStorageDatabase>, public CanMakeWeakPtr<LocalStorageDatabase> { 43 43 public: 44 static Ref<LocalStorageDatabase> create(Ref< WorkQueue>&&, String&& databasePath, unsigned quotaInBytes);44 static Ref<LocalStorageDatabase> create(Ref<SuspendableWorkQueue>&&, String&& databasePath, unsigned quotaInBytes); 45 45 ~LocalStorageDatabase(); 46 46 … … 59 59 60 60 private: 61 LocalStorageDatabase(Ref< WorkQueue>&&, String&& databasePath, unsigned quotaInBytes);61 LocalStorageDatabase(Ref<SuspendableWorkQueue>&&, String&& databasePath, unsigned quotaInBytes); 62 62 63 63 enum class ShouldCreateDatabase : bool { No, Yes }; … … 72 72 WebCore::SQLiteStatementAutoResetScope scopedStatement(std::unique_ptr<WebCore::SQLiteStatement>&, ASCIILiteral query) const; 73 73 74 Ref< WorkQueue> m_workQueue;74 Ref<SuspendableWorkQueue> m_workQueue; 75 75 String m_databasePath; 76 76 mutable WebCore::SQLiteDatabase m_database; -
trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.cpp
r276653 r280934 48 48 } 49 49 50 StorageArea& LocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, IsEphemeral isEphemeral, Ref< WorkQueue>&& workQueue)50 StorageArea& LocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, IsEphemeral isEphemeral, Ref<SuspendableWorkQueue>&& workQueue) 51 51 { 52 52 ASSERT(!RunLoop::isMain()); -
trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.h
r275886 r280934 32 32 #include <wtf/HashMap.h> 33 33 #include <wtf/WeakPtr.h> 34 #include <wtf/WorkQueue.h>35 34 36 35 namespace WebKit { … … 49 48 50 49 enum class IsEphemeral : bool { No, Yes }; 51 StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, IsEphemeral, Ref< WorkQueue>&&);50 StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, IsEphemeral, Ref<SuspendableWorkQueue>&&); 52 51 53 52 void clearStorageAreasMatchingOrigin(const WebCore::SecurityOriginData&); -
trunk/Source/WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.cpp
r249533 r280934 44 44 } 45 45 46 StorageArea& SessionStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, Ref< WorkQueue>&& workQueue)46 StorageArea& SessionStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, Ref<SuspendableWorkQueue>&& workQueue) 47 47 { 48 48 ASSERT(!RunLoop::isMain()); -
trunk/Source/WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.h
r249533 r280934 45 45 bool isEmpty() const { return m_storageAreaMap.isEmpty(); } 46 46 47 StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, Ref< WorkQueue>&&);47 StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, Ref<SuspendableWorkQueue>&&); 48 48 49 49 void cloneTo(SessionStorageNamespace& newSessionStorageNamespace); -
trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp
r278786 r280934 31 31 #include "StorageAreaMapMessages.h" 32 32 #include "StorageManager.h" 33 #include <wtf/SuspendableWorkQueue.h> 33 34 34 35 namespace WebKit { … … 36 37 using namespace WebCore; 37 38 38 StorageArea::StorageArea(LocalStorageNamespace* localStorageNamespace, const SecurityOriginData& securityOrigin, unsigned quotaInBytes, Ref< WorkQueue>&& queue)39 StorageArea::StorageArea(LocalStorageNamespace* localStorageNamespace, const SecurityOriginData& securityOrigin, unsigned quotaInBytes, Ref<SuspendableWorkQueue>&& queue) 39 40 : m_localStorageNamespace(makeWeakPtr(localStorageNamespace)) 40 41 , m_securityOrigin(securityOrigin) -
trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h
r278786 r280934 49 49 using Identifier = StorageAreaIdentifier; 50 50 51 StorageArea(LocalStorageNamespace*, const WebCore::SecurityOriginData&, unsigned quotaInBytes, Ref< WorkQueue>&&);51 StorageArea(LocalStorageNamespace*, const WebCore::SecurityOriginData&, unsigned quotaInBytes, Ref<SuspendableWorkQueue>&&); 52 52 ~StorageArea(); 53 53 … … 91 91 92 92 Identifier m_identifier; 93 Ref< WorkQueue> m_queue;93 Ref<SuspendableWorkQueue> m_queue; 94 94 }; 95 95 -
trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp
r261038 r280934 42 42 #include <wtf/CrossThreadCopier.h> 43 43 #include <wtf/FileSystem.h> 44 #include <wtf/SuspendableWorkQueue.h> 44 45 #include <wtf/WorkQueue.h> 45 46 … … 212 213 } 213 214 214 StorageArea* StorageManager::createLocalStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& origin, Ref< WorkQueue>&& workQueue)215 StorageArea* StorageManager::createLocalStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& origin, Ref<SuspendableWorkQueue>&& workQueue) 215 216 { 216 217 ASSERT(!RunLoop::isMain()); … … 222 223 } 223 224 224 StorageArea* StorageManager::createTransientLocalStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& topLevelOrigin, SecurityOriginData&& origin, Ref< WorkQueue>&& workQueue)225 StorageArea* StorageManager::createTransientLocalStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& topLevelOrigin, SecurityOriginData&& origin, Ref<SuspendableWorkQueue>&& workQueue) 225 226 { 226 227 ASSERT(!RunLoop::isMain()); … … 233 234 } 234 235 235 StorageArea* StorageManager::createSessionStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& origin, Ref< WorkQueue>&& workQueue)236 StorageArea* StorageManager::createSessionStorageArea(StorageNamespaceIdentifier storageNamespaceID, SecurityOriginData&& origin, Ref<SuspendableWorkQueue>&& workQueue) 236 237 { 237 238 ASSERT(!RunLoop::isMain()); -
trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h
r274189 r280934 81 81 static const unsigned localStorageDatabaseQuotaInBytes; 82 82 83 StorageArea* createLocalStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, Ref< WorkQueue>&&);84 StorageArea* createTransientLocalStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, WebCore::SecurityOriginData&&, Ref< WorkQueue>&&);85 StorageArea* createSessionStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, Ref< WorkQueue>&&);83 StorageArea* createLocalStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, Ref<SuspendableWorkQueue>&&); 84 StorageArea* createTransientLocalStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, WebCore::SecurityOriginData&&, Ref<SuspendableWorkQueue>&&); 85 StorageArea* createSessionStorageArea(StorageNamespaceIdentifier, WebCore::SecurityOriginData&&, Ref<SuspendableWorkQueue>&&); 86 86 87 87 Vector<StorageAreaIdentifier> allStorageAreaIdentifiers() const; -
trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp
r280110 r280934 42 42 43 43 StorageManagerSet::StorageManagerSet() 44 : m_queue( WorkQueue::create("com.apple.WebKit.WebStorage"))44 : m_queue(SuspendableWorkQueue::create("com.apple.WebKit.WebStorage")) 45 45 { 46 46 ASSERT(RunLoop::isMain()); … … 178 178 ASSERT(RunLoop::isMain()); 179 179 180 Locker suspensionLocker { m_suspensionLock }; 181 m_shouldSuspend = true; 182 183 m_queue->dispatch([this, protectedThis = makeRef(*this), suspensionIdentifier = ++m_suspensionIdentifier, completionHandler = WTFMove(completionHandler)] () mutable { 184 Locker suspensionLocker { m_suspensionLock }; 185 if (!m_shouldSuspend || suspensionIdentifier != m_suspensionIdentifier) { 186 RunLoop::main().dispatch(WTFMove(completionHandler)); 187 return; 188 } 189 190 // Make sure we flush local storage to disk before we suspend the thread as we want to make sure any pending 191 // SQL transaction has been committed. 192 flushLocalStorage(); 193 194 RunLoop::main().dispatch(WTFMove(completionHandler)); 195 196 while (m_shouldSuspend) 197 m_suspensionCondition.wait(m_suspensionLock); 198 }); 180 m_queue->suspend([protectedThis = makeRef(*this)] { 181 protectedThis->flushLocalStorage(); 182 }, WTFMove(completionHandler)); 199 183 } 200 184 … … 203 187 ASSERT(RunLoop::isMain()); 204 188 205 Locker suspensionLocker { m_suspensionLock }; 206 m_shouldSuspend = false; 207 m_suspensionCondition.notifyOne(); 189 m_queue->resume(); 208 190 } 209 191 -
trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.h
r280110 r280934 34 34 #include <wtf/Condition.h> 35 35 #include <wtf/Lock.h> 36 #include <wtf/SuspendableWorkQueue.h> 36 37 #include <wtf/WeakPtr.h> 37 38 … … 99 100 100 101 HashSet<IPC::Connection::UniqueID> m_connections; 101 Ref<WorkQueue> m_queue; 102 103 Lock m_suspensionLock; 104 Condition m_suspensionCondition; 105 bool m_shouldSuspend WTF_GUARDED_BY_LOCK(m_suspensionLock) { false }; 106 uint64_t m_suspensionIdentifier WTF_GUARDED_BY_LOCK(m_suspensionLock) { 0 }; 102 Ref<SuspendableWorkQueue> m_queue; 107 103 }; 108 104 -
trunk/Source/WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp
r249533 r280934 45 45 } 46 46 47 StorageArea& TransientLocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, Ref< WorkQueue>&& workQueue)47 StorageArea& TransientLocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, Ref<SuspendableWorkQueue>&& workQueue) 48 48 { 49 49 ASSERT(!RunLoop::isMain()); -
trunk/Source/WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.h
r249533 r280934 43 43 ~TransientLocalStorageNamespace(); 44 44 45 StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, Ref< WorkQueue>&&);45 StorageArea& getOrCreateStorageArea(WebCore::SecurityOriginData&&, Ref<SuspendableWorkQueue>&&); 46 46 Vector<WebCore::SecurityOriginData> origins() const; 47 47
Note:
See TracChangeset
for help on using the changeset viewer.