Changeset 247125 in webkit
- Timestamp:
- Jul 3, 2019 6:10:27 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r247123 r247125 1 2019-07-03 Youenn Fablet <youenn@apple.com> 2 3 Make CacheStorage::Engine directory listing operations in a background thread 4 https://bugs.webkit.org/show_bug.cgi?id=199470 5 6 Reviewed by Chris Dumez. 7 8 Use the io work queue to get the list of directories. 9 Then go back to main thread and trigger clear/fetch operation as currently done. 10 11 * NetworkProcess/cache/CacheStorageEngine.cpp: 12 (WebKit::CacheStorage::ReadOriginsTaskCounter::create): 13 (WebKit::CacheStorage::ReadOriginsTaskCounter::ReadOriginsTaskCounter): 14 (WebKit::CacheStorage::Engine::getDirectories): 15 (WebKit::CacheStorage::Engine::fetchEntries): 16 (WebKit::CacheStorage::Engine::fetchDirectoryEntries): 17 (WebKit::CacheStorage::Engine::clearCachesForOriginFromDisk): 18 (WebKit::CacheStorage::Engine::clearCachesForOriginFromDirectories): 19 * NetworkProcess/cache/CacheStorageEngine.h: 20 1 21 2019-07-03 Sihui Liu <sihui_liu@apple.com> 2 22 -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
r247111 r247125 460 460 class ReadOriginsTaskCounter : public RefCounted<ReadOriginsTaskCounter> { 461 461 public: 462 static Ref<ReadOriginsTaskCounter> create( WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&& callback)462 static Ref<ReadOriginsTaskCounter> create(CompletionHandler<void(Vector<WebsiteData::Entry>)>&& callback) 463 463 { 464 464 return adoptRef(*new ReadOriginsTaskCounter(WTFMove(callback))); … … 476 476 477 477 private: 478 explicit ReadOriginsTaskCounter( WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&& callback)478 explicit ReadOriginsTaskCounter(CompletionHandler<void(Vector<WebsiteData::Entry>)>&& callback) 479 479 : m_callback(WTFMove(callback)) 480 480 { 481 481 } 482 482 483 WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)> m_callback;483 CompletionHandler<void(Vector<WebsiteData::Entry>)> m_callback; 484 484 Vector<WebsiteData::Entry> m_entries; 485 485 }; 486 486 487 void Engine::fetchEntries(bool shouldComputeSize, WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&& completionHandler) 487 void Engine::getDirectories(CompletionHandler<void(const Vector<String>&)>&& completionHandler) 488 { 489 m_ioQueue->dispatch([path = m_rootPath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 490 Vector<String> folderPaths; 491 for (auto& filename : FileSystem::listDirectory(path, "*")) { 492 if (FileSystem::fileIsDirectory(filename, FileSystem::ShouldFollowSymbolicLinks::No)) 493 folderPaths.append(filename.isolatedCopy()); 494 } 495 496 RunLoop::main().dispatch([folderPaths = WTFMove(folderPaths), completionHandler = WTFMove(completionHandler)]() mutable { 497 completionHandler(folderPaths); 498 }); 499 }); 500 } 501 502 void Engine::fetchEntries(bool shouldComputeSize, CompletionHandler<void(Vector<WebsiteData::Entry>)>&& completionHandler) 488 503 { 489 504 if (!shouldPersist()) { … … 495 510 } 496 511 512 getDirectories([this, weakThis = makeWeakPtr(this), path = m_rootPath.isolatedCopy(), shouldComputeSize, completionHandler = WTFMove(completionHandler)](const auto& folderPaths) mutable { 513 if (!weakThis) 514 return completionHandler({ }); 515 fetchDirectoryEntries(shouldComputeSize, folderPaths, WTFMove(completionHandler)); 516 }); 517 } 518 519 void Engine::fetchDirectoryEntries(bool shouldComputeSize, const Vector<String>& folderPaths, CompletionHandler<void(Vector<WebsiteData::Entry>)>&& completionHandler) 520 { 497 521 auto taskCounter = ReadOriginsTaskCounter::create(WTFMove(completionHandler)); 498 for (auto& folderPath : FileSystem::listDirectory(m_rootPath, "*")) { 499 if (!FileSystem::fileIsDirectory(folderPath, FileSystem::ShouldFollowSymbolicLinks::No)) 500 continue; 522 for (auto& folderPath : folderPaths) { 501 523 Caches::retrieveOriginFromDirectory(folderPath, *m_ioQueue, [protectedThis = makeRef(*this), shouldComputeSize, taskCounter = taskCounter.copyRef()] (auto&& origin) mutable { 502 524 ASSERT(RunLoop::isMain()); … … 570 592 { 571 593 ASSERT(RunLoop::isMain()); 572 594 getDirectories([this, weakThis = makeWeakPtr(this), origin, completionHandler = WTFMove(completionHandler)](const auto& folderPaths) mutable { 595 if (!weakThis) 596 return completionHandler(); 597 clearCachesForOriginFromDirectories(folderPaths, origin, WTFMove(completionHandler)); 598 }); 599 } 600 601 void Engine::clearCachesForOriginFromDirectories(const Vector<String>& folderPaths, const WebCore::SecurityOriginData& origin, CompletionHandler<void()>&& completionHandler) 602 { 573 603 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 574 575 for (auto& folderPath : FileSystem::listDirectory(m_rootPath, "*")) { 576 if (!FileSystem::fileIsDirectory(folderPath, FileSystem::ShouldFollowSymbolicLinks::No)) 577 continue; 604 for (auto& folderPath : folderPaths) { 578 605 Caches::retrieveOriginFromDirectory(folderPath, *m_ioQueue, [this, protectedThis = makeRef(*this), origin, callbackAggregator = callbackAggregator.copyRef(), folderPath] (Optional<WebCore::ClientOrigin>&& folderOrigin) mutable { 579 606 if (!folderOrigin) -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h
r243339 r247125 120 120 void fetchEntries(bool /* shouldComputeSize */, CompletionHandler<void(Vector<WebsiteData::Entry>)>&&); 121 121 122 void getDirectories(CompletionHandler<void(const Vector<String>&)>&&); 123 void fetchDirectoryEntries(bool shouldComputeSize, const Vector<String>& folderPaths, CompletionHandler<void(Vector<WebsiteData::Entry>)>&&); 124 void clearCachesForOriginFromDirectories(const Vector<String>&, const WebCore::SecurityOriginData&, CompletionHandler<void()>&&); 125 122 126 void initialize(WebCore::DOMCacheEngine::CompletionCallback&&); 123 127
Note: See TracChangeset
for help on using the changeset viewer.