Drop unnecessary uses of targetStatistics.dataRecordsRemoved in ResourceLoadObserver
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Jul 2017 04:15:09 +0000 (04:15 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Jul 2017 04:15:09 +0000 (04:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174234

Reviewed by Brent Fulgham.

Drop unnecessary uses of targetStatistics.dataRecordsRemoved in ResourceLoadObserver. It is
always 0 since this member is only initialized later on, in the UIProcess.

* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::logFrameNavigation):
(WebCore::ResourceLoadObserver::logSubresourceLoading):
(WebCore::ResourceLoadObserver::logWebSocketLoading):

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

Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoadObserver.cpp

index 768d708..22ffe37 100644 (file)
@@ -1,3 +1,18 @@
+2017-07-06  Chris Dumez  <cdumez@apple.com>
+
+        Drop unnecessary uses of targetStatistics.dataRecordsRemoved in ResourceLoadObserver
+        https://bugs.webkit.org/show_bug.cgi?id=174234
+
+        Reviewed by Brent Fulgham.
+
+        Drop unnecessary uses of targetStatistics.dataRecordsRemoved in ResourceLoadObserver. It is
+        always 0 since this member is only initialized later on, in the UIProcess.
+
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::ResourceLoadObserver::logFrameNavigation):
+        (WebCore::ResourceLoadObserver::logSubresourceLoading):
+        (WebCore::ResourceLoadObserver::logWebSocketLoading):
+
 2017-07-06  Yoav Weiss  <yoav@yoav.ws>
 
         [preload] Avoid reflecting "video" and "audio" when they are not supported `as` value
index 60297dc..39e5314 100644 (file)
@@ -84,6 +84,9 @@ void ResourceLoadObserver::logFrameNavigation(const Frame& frame, const Frame& t
     ASSERT(frame.document());
     ASSERT(topFrame.document());
     ASSERT(topFrame.page());
+
+    if (frame.isMainFrame())
+        return;
     
     if (!shouldLog(topFrame.page()))
         return;
@@ -109,18 +112,8 @@ void ResourceLoadObserver::logFrameNavigation(const Frame& frame, const Frame& t
         return;
 
     auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain);
-
-    // Always fire if we have previously removed data records for this domain
-    // FIXME: targetStatistics.dataRecordsRemoved is always 0 in WebCore as it gets populated in the UIProcess.
-    bool shouldCallNotificationCallback = targetStatistics.dataRecordsRemoved > 0;
-
-    if (!frame.isMainFrame()) {
-        auto subframeUnderTopFrameOriginsResult = targetStatistics.subframeUnderTopFrameOrigins.add(mainFramePrimaryDomain);
-        if (subframeUnderTopFrameOriginsResult.isNewEntry)
-            shouldCallNotificationCallback = true;
-    }
-
-    if (shouldCallNotificationCallback)
+    auto subframeUnderTopFrameOriginsResult = targetStatistics.subframeUnderTopFrameOrigins.add(mainFramePrimaryDomain);
+    if (subframeUnderTopFrameOriginsResult.isNewEntry)
         scheduleNotificationIfNeeded();
 }
     
@@ -150,23 +143,15 @@ void ResourceLoadObserver::logSubresourceLoading(const Frame* frame, const Resou
         return;
 
     bool shouldCallNotificationCallback = false;
-
     {
         auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain);
-
-        // Always fire if we have previously removed data records for this domain
-        // FIXME: targetStatistics.dataRecordsRemoved is always 0 in WebCore as it gets populated in the UIProcess.
-        shouldCallNotificationCallback = targetStatistics.dataRecordsRemoved > 0;
-
-        auto subresourceUnderTopFrameOriginsResult = targetStatistics.subresourceUnderTopFrameOrigins.add(mainFramePrimaryDomain);
-        if (subresourceUnderTopFrameOriginsResult.isNewEntry)
+        if (targetStatistics.subresourceUnderTopFrameOrigins.add(mainFramePrimaryDomain).isNewEntry)
             shouldCallNotificationCallback = true;
     }
 
     if (isRedirect) {
         auto& redirectingOriginStatistics = ensureResourceStatisticsForPrimaryDomain(sourcePrimaryDomain);
-        auto subresourceUniqueRedirectsToResult = redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetPrimaryDomain);
-        if (subresourceUniqueRedirectsToResult.isNewEntry)
+        if (redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetPrimaryDomain).isNewEntry)
             shouldCallNotificationCallback = true;
     }
 
@@ -199,16 +184,7 @@ void ResourceLoadObserver::logWebSocketLoading(const Frame* frame, const URL& ta
         return;
 
     auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain);
-
-    // Always fire if we have previously removed data records for this domain
-    // FIXME: targetStatistics.dataRecordsRemoved is always 0 in WebCore as it gets populated in the UIProcess.
-    bool shouldCallNotificationCallback = targetStatistics.dataRecordsRemoved > 0;
-
-    auto subresourceUnderTopFrameOriginsResult = targetStatistics.subresourceUnderTopFrameOrigins.add(mainFramePrimaryDomain);
-    if (subresourceUnderTopFrameOriginsResult.isNewEntry)
-        shouldCallNotificationCallback = true;
-
-    if (shouldCallNotificationCallback)
+    if (targetStatistics.subresourceUnderTopFrameOrigins.add(mainFramePrimaryDomain).isNewEntry)
         scheduleNotificationIfNeeded();
 }