Avoid code duplication in ResourceLoadStatisticsMemoryStore::processStatisticsAndData...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2018 03:39:59 +0000 (03:39 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2018 03:39:59 +0000 (03:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189130

Reviewed by Youenn Fablet.

Move if check inside the lambda instead of outside to avoid code duplication.

* UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235495 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp

index 43ccc4a..953e494 100644 (file)
@@ -1,3 +1,15 @@
+2018-08-29  Chris Dumez  <cdumez@apple.com>
+
+        Avoid code duplication in ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords()
+        https://bugs.webkit.org/show_bug.cgi?id=189130
+
+        Reviewed by Youenn Fablet.
+
+        Move if check inside the lambda instead of outside to avoid code duplication.
+
+        * UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
+        (WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords):
+
 2018-08-29  Alex Christensen  <achristensen@webkit.org>
 
         Revert some of r235398
index e589f85..17ce7bd 100644 (file)
@@ -345,31 +345,22 @@ void ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords()
         }
     }
 
-    if (m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned) {
-        removeDataRecords([this, weakThis = makeWeakPtr(*this)] {
-            ASSERT(!RunLoop::isMain());
-            if (!weakThis)
-                return;
-
-            pruneStatisticsIfNeeded();
-            if (m_persistentStorage)
-                m_persistentStorage->scheduleOrWriteMemoryStore(ResourceLoadStatisticsPersistentStorage::ForceImmediateWrite::No);
-
-            RunLoop::main().dispatch([] {
-                WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
-            });
-        });
-    } else {
-        removeDataRecords([this, weakThis = makeWeakPtr(*this)] {
-            ASSERT(!RunLoop::isMain());
-            if (!weakThis)
-                return;
-
-            pruneStatisticsIfNeeded();
-            if (m_persistentStorage)
-                m_persistentStorage->scheduleOrWriteMemoryStore(ResourceLoadStatisticsPersistentStorage::ForceImmediateWrite::No);
+    removeDataRecords([this, weakThis = makeWeakPtr(*this)] {
+        ASSERT(!RunLoop::isMain());
+        if (!weakThis)
+            return;
+
+        pruneStatisticsIfNeeded();
+        if (m_persistentStorage)
+            m_persistentStorage->scheduleOrWriteMemoryStore(ResourceLoadStatisticsPersistentStorage::ForceImmediateWrite::No);
+
+        if (!m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned)
+            return;
+
+        RunLoop::main().dispatch([] {
+            WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
         });
-    }
+    });
 }
 
 void ResourceLoadStatisticsMemoryStore::hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)