Changeset 181079 in webkit
- Timestamp:
- Mar 5, 2015 9:05:54 AM (9 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r181076 r181079 1 2015-03-05 Antti Koivisto <antti@apple.com> 2 3 Switch NetworkCacheStorage to WorkQueue abstraction 4 https://bugs.webkit.org/show_bug.cgi?id=142337 5 6 Reviewed by Anders Carlsson. 7 8 Don't use dispatch_async directly. 9 10 * NetworkProcess/cache/NetworkCacheStorage.h: 11 (WebKit::NetworkCacheStorage::ioQueue): 12 (WebKit::NetworkCacheStorage::backgroundIOQueue): 13 * NetworkProcess/cache/NetworkCacheStorageCocoa.mm: 14 (WebKit::NetworkCacheStorage::NetworkCacheStorage): 15 (WebKit::NetworkCacheStorage::initialize): 16 (WebKit::NetworkCacheStorage::removeEntry): 17 (WebKit::NetworkCacheStorage::dispatchReadOperation): 18 (WebKit::retrieveFromMemory): 19 (WebKit::NetworkCacheStorage::traverse): 20 (WebKit::NetworkCacheStorage::dispatchFullWriteOperation): 21 (WebKit::NetworkCacheStorage::dispatchHeaderWriteOperation): 22 (WebKit::NetworkCacheStorage::clear): 23 (WebKit::NetworkCacheStorage::shrinkIfNeeded): 24 (WebKit::NetworkCacheStorage::deleteOldVersions): 25 1 26 2015-03-05 Lukasz Bialek <l.bialek@samsung.com> 2 27 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h
r181020 r181079 35 35 #include <wtf/HashSet.h> 36 36 #include <wtf/Optional.h> 37 #include <wtf/WorkQueue.h> 37 38 #include <wtf/text/WTFString.h> 38 39 … … 103 104 void dispatchPendingWriteOperations(); 104 105 106 WorkQueue& ioQueue() { return m_ioQueue.get(); } 107 WorkQueue& backgroundIOQueue() { return m_backgroundIOQueue.get(); } 108 105 109 const String m_baseDirectoryPath; 106 110 const String m_directoryPath; … … 119 123 HashSet<std::unique_ptr<const WriteOperation>> m_activeWriteOperations; 120 124 121 #if PLATFORM(COCOA) 122 mutable DispatchPtr<dispatch_queue_t> m_ioQueue; 123 mutable DispatchPtr<dispatch_queue_t> m_backgroundIOQueue; 124 #endif 125 Ref<WorkQueue> m_ioQueue; 126 Ref<WorkQueue> m_backgroundIOQueue; 125 127 }; 126 128 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm
r181020 r181079 70 70 : m_baseDirectoryPath(baseDirectoryPath) 71 71 , m_directoryPath(makeVersionedDirectoryPath(baseDirectoryPath)) 72 , m_ioQueue(adoptDispatch(dispatch_queue_create("com.apple.WebKit.Cache.Storage", DISPATCH_QUEUE_CONCURRENT))) 73 , m_backgroundIOQueue(adoptDispatch(dispatch_queue_create("com.apple.WebKit.Cache.Storage.Background", DISPATCH_QUEUE_CONCURRENT))) 74 { 75 dispatch_set_target_queue(m_backgroundIOQueue.get(), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)); 76 72 , m_ioQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage", WorkQueue::Type::Concurrent)) 73 , m_backgroundIOQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage", WorkQueue::Type::Concurrent, WorkQueue::QOS::Background)) 74 { 77 75 deleteOldVersions(); 78 76 initialize(); … … 85 83 StringCapture cachePathCapture(m_directoryPath); 86 84 87 dispatch_async(m_backgroundIOQueue.get(),[this, cachePathCapture] {85 backgroundIOQueue().dispatch([this, cachePathCapture] { 88 86 String cachePath = cachePathCapture.string(); 89 87 traverseCacheFiles(cachePath, [this](const String& fileName, const String& partitionPath) { … … 92 90 return; 93 91 unsigned shortHash = NetworkCacheKey::toShortHash(hash); 94 dispatch_async(dispatch_get_main_queue(),[this, shortHash] {92 RunLoop::main().dispatch([this, shortHash] { 95 93 m_contentsFilter.add(shortHash); 96 94 }); … … 293 291 294 292 StringCapture filePathCapture(filePathForKey(key, m_directoryPath)); 295 dispatch_async(m_backgroundIOQueue.get(),[this, filePathCapture] {293 backgroundIOQueue().dispatch([this, filePathCapture] { 296 294 WebCore::deleteFile(filePathCapture.string()); 297 295 }); … … 304 302 305 303 StringCapture cachePathCapture(m_directoryPath); 306 dispatch_async(m_ioQueue.get(),[this, &read, cachePathCapture] {304 ioQueue().dispatch([this, &read, cachePathCapture] { 307 305 auto channel = openFileForKey(read.key, NetworkCacheIOChannel::Type::Read, cachePathCapture.string()); 308 306 int fd = channel->fileDescriptor(); 309 310 307 channel->read(0, std::numeric_limits<size_t>::max(), [this, &read, fd](NetworkCacheData& fileData, int error) { 311 308 if (error) { … … 355 352 LOG(NetworkCacheStorage, "(NetworkProcess) found write operation in progress"); 356 353 auto entry = operation->entry; 357 dispatch_async(dispatch_get_main_queue(),[entry, completionHandler] {354 RunLoop::main().dispatch([entry, completionHandler] { 358 355 completionHandler(std::make_unique<NetworkCacheStorage::Entry>(entry)); 359 356 }); … … 426 423 { 427 424 StringCapture cachePathCapture(m_directoryPath); 428 dispatch_async(m_ioQueue.get(),[this, cachePathCapture, traverseHandler] {425 ioQueue().dispatch([this, cachePathCapture, traverseHandler] { 429 426 String cachePath = cachePathCapture.string(); 430 427 auto semaphore = adoptDispatch(dispatch_semaphore_create(0)); … … 444 441 dispatch_semaphore_wait(semaphore.get(), DISPATCH_TIME_FOREVER); 445 442 }); 446 dispatch_async(dispatch_get_main_queue(),[this, traverseHandler] {443 RunLoop::main().dispatch([this, traverseHandler] { 447 444 traverseHandler(nullptr); 448 445 }); … … 482 479 483 480 StringCapture cachePathCapture(m_directoryPath); 484 dispatch_async(m_backgroundIOQueue.get(),[this, &write, cachePathCapture] {481 backgroundIOQueue().dispatch([this, &write, cachePathCapture] { 485 482 auto encodedHeader = encodeEntryHeader(write.entry); 486 483 auto headerAndBodyData = adoptDispatch(dispatch_data_create_concat(encodedHeader.dispatchData(), write.entry.body.dispatchData())); … … 527 524 // Try to update the header of an existing entry. 528 525 StringCapture cachePathCapture(m_directoryPath); 529 dispatch_async(m_backgroundIOQueue.get(),[this, &write, cachePathCapture] {526 backgroundIOQueue().dispatch([this, &write, cachePathCapture] { 530 527 auto headerData = encodeEntryHeader(write.entry); 531 528 auto existingHeaderData = encodeEntryHeader(write.existingEntry.value()); … … 534 531 if (pageRoundedHeaderSizeChanged) { 535 532 LOG(NetworkCacheStorage, "(NetworkProcess) page-rounded header size changed, storing full entry"); 536 dispatch_async(dispatch_get_main_queue(),[this, &write] {533 RunLoop::main().dispatch([this, &write] { 537 534 dispatchFullWriteOperation(write); 538 535 }); … … 574 571 StringCapture directoryPathCapture(m_directoryPath); 575 572 576 dispatch_async(m_ioQueue.get(),[directoryPathCapture] {573 ioQueue().dispatch([directoryPathCapture] { 577 574 String directoryPath = directoryPathCapture.string(); 578 575 traverseDirectory(directoryPath, DT_DIR, [&directoryPath](const String& subdirName) { … … 603 600 604 601 StringCapture cachePathCapture(m_directoryPath); 605 dispatch_async(m_backgroundIOQueue.get(),[this, cachePathCapture] {602 backgroundIOQueue().dispatch([this, cachePathCapture] { 606 603 String cachePath = cachePathCapture.string(); 607 604 traverseCacheFiles(cachePath, [this](const String& fileName, const String& partitionPath) { … … 621 618 return; 622 619 unsigned shortHash = NetworkCacheKey::toShortHash(hash); 623 dispatch_async(dispatch_get_main_queue(),[this, shortHash] {620 RunLoop::main().dispatch([this, shortHash] { 624 621 if (m_contentsFilter.mayContain(shortHash)) 625 622 m_contentsFilter.remove(shortHash); … … 643 640 // Delete V1 cache. 644 641 StringCapture cachePathCapture(m_baseDirectoryPath); 645 dispatch_async(m_backgroundIOQueue.get(),[cachePathCapture] {642 backgroundIOQueue().dispatch([cachePathCapture] { 646 643 String cachePath = cachePathCapture.string(); 647 644 traverseDirectory(cachePath, DT_DIR, [&cachePath](const String& subdirName) {
Note: See TracChangeset
for help on using the changeset viewer.