Title: [201371] trunk/Source/WebKit2
Revision
201371
Author
[email protected]
Date
2016-05-24 22:18:00 -0700 (Tue, 24 May 2016)

Log Message

Simplify a couple of lambda captures in the network cache code
https://bugs.webkit.org/show_bug.cgi?id=158053

Reviewed by Brady Eidson.

* NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
(WebKit::NetworkCache::SpeculativeLoadManager::preloadEntry):
Just capture subResourceInfo instead of allocating a new copy
on the heap. There is no reason we cannot simply capture
subResourceInfo here.

* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::clear):
Use new C++14 capture with initialization to make the code a
bit nicer.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (201370 => 201371)


--- trunk/Source/WebKit2/ChangeLog	2016-05-25 01:21:45 UTC (rev 201370)
+++ trunk/Source/WebKit2/ChangeLog	2016-05-25 05:18:00 UTC (rev 201371)
@@ -1,3 +1,21 @@
+2016-05-24  Chris Dumez  <[email protected]>
+
+        Simplify a couple of lambda captures in the network cache code
+        https://bugs.webkit.org/show_bug.cgi?id=158053
+
+        Reviewed by Brady Eidson.
+
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
+        (WebKit::NetworkCache::SpeculativeLoadManager::preloadEntry):
+        Just capture subResourceInfo instead of allocating a new copy
+        on the heap. There is no reason we cannot simply capture
+        subResourceInfo here.
+
+        * NetworkProcess/cache/NetworkCacheStorage.cpp:
+        (WebKit::NetworkCache::Storage::clear):
+        Use new C++14 capture with initialization to make the code a
+        bit nicer.
+
 2016-05-24  Conrad Shultz  <[email protected]>
 
         _WKThumbnailView should expose its snapshot size

Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp (201370 => 201371)


--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp	2016-05-25 01:21:45 UTC (rev 201370)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp	2016-05-25 05:18:00 UTC (rev 201371)
@@ -493,9 +493,7 @@
         return;
 
     m_pendingPreloads.add(key, nullptr);
-    auto* subResourceInfoPtr = new SubresourceInfo(subResourceInfo);
-    retrieveEntryFromStorage(key, [this, key, subResourceInfoPtr, frameID](std::unique_ptr<Entry> entry) {
-        auto subResourceInfo = std::unique_ptr<SubresourceInfo>(subResourceInfoPtr);
+    retrieveEntryFromStorage(key, [this, key, subResourceInfo, frameID](std::unique_ptr<Entry> entry) {
         ASSERT(!m_pendingPreloads.get(key));
         bool removed = m_pendingPreloads.remove(key);
         ASSERT_UNUSED(removed, removed);
@@ -510,7 +508,7 @@
             return;
 
         if (entry->needsValidation())
-            revalidateEntry(WTFMove(entry), *subResourceInfo, frameID);
+            revalidateEntry(WTFMove(entry), subResourceInfo, frameID);
         else
             addPreloadedEntry(WTFMove(entry), frameID);
     });

Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp (201370 => 201371)


--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp	2016-05-25 01:21:45 UTC (rev 201370)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp	2016-05-25 05:18:00 UTC (rev 201371)
@@ -898,10 +898,8 @@
         m_blobFilter->clear();
     m_approximateRecordsSize = 0;
 
-    // Avoid non-thread safe std::function copies.
-    auto* completionHandlerPtr = completionHandler ? new std::function<void ()>(WTFMove(completionHandler)) : nullptr;
     StringCapture typeCapture(type);
-    ioQueue().dispatch([this, modifiedSinceTime, completionHandlerPtr, typeCapture] {
+    ioQueue().dispatch([this, modifiedSinceTime, completionHandler = WTFMove(completionHandler), typeCapture] () mutable {
         auto recordsPath = this->recordsPath();
         traverseRecordsFiles(recordsPath, typeCapture.string(), [modifiedSinceTime](const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath) {
             auto filePath = WebCore::pathByAppendingComponent(recordDirectoryPath, fileName);
@@ -918,10 +916,9 @@
         // This cleans unreferenced blobs.
         m_blobStorage.synchronize();
 
-        if (completionHandlerPtr) {
-            RunLoop::main().dispatch([completionHandlerPtr] {
-                (*completionHandlerPtr)();
-                delete completionHandlerPtr;
+        if (completionHandler) {
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {
+                completionHandler();
             });
         }
     });
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to