Move ResourceLoadStatisticsStore to WebKit2/UIProcess
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2017 20:54:26 +0000 (20:54 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2017 20:54:26 +0000 (20:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174033

Reviewed by Brent Fulgham.

Move ResourceLoadStatisticsStore to WebKit2/UIProcess since it is only
used in the WebKit2 UIProcess.

* CMakeLists.txt:
Source/WebCore:

* WebCore.xcodeproj/project.pbxproj:
* loader/ResourceLoadObserver.cpp:
(WebCore::primaryDomain):
* loader/ResourceLoadStatistics.cpp:
(WebCore::ResourceLoadStatistics::primaryDomain):
* loader/ResourceLoadStatistics.h:

Source/WebKit2:

* UIProcess/Storage/ResourceLoadStatisticsStore.cpp: Renamed from Source/WebCore/loader/ResourceLoadStatisticsStore.cpp.
(WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
(WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
(WebKit::ResourceLoadStatisticsStore::clearInMemory):
(WebKit::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
(WebKit::ResourceLoadStatisticsStore::mergeStatistics):
(WebKit::ResourceLoadStatisticsStore::fireDataModificationHandler):
(WebKit::ResourceLoadStatisticsStore::fireTelemetryHandler):
(WebKit::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
(WebKit::ResourceLoadStatisticsStore::processStatistics):
(WebKit::ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry):
(WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
(WebKit::ResourceLoadStatisticsStore::dataRecordsBeingRemoved):
(WebKit::ResourceLoadStatisticsStore::dataRecordsWereRemoved):
(WebKit::ResourceLoadStatisticsStore::statisticsLock):
* UIProcess/Storage/ResourceLoadStatisticsStore.h: Renamed from Source/WebCore/loader/ResourceLoadStatisticsStore.h.
* UIProcess/WebResourceLoadStatisticsManager.cpp:
(WebKit::primaryDomain):
* UIProcess/WebResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsStore.h:
* UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
* UIProcess/WebResourceLoadStatisticsTelemetry.h:
* WebKit2.xcodeproj/project.pbxproj:

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

16 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/ResourceLoadObserver.cpp
Source/WebCore/loader/ResourceLoadStatistics.cpp
Source/WebCore/loader/ResourceLoadStatistics.h
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.cpp [moved from Source/WebCore/loader/ResourceLoadStatisticsStore.cpp with 92% similarity]
Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h [moved from Source/WebCore/loader/ResourceLoadStatisticsStore.h with 50% similarity]
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsTelemetry.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsTelemetry.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

index 37fd896..ce7b168 100644 (file)
@@ -1976,7 +1976,6 @@ set(WebCore_SOURCES
     loader/ResourceLoadNotifier.cpp
     loader/ResourceLoadObserver.cpp
     loader/ResourceLoadStatistics.cpp
-    loader/ResourceLoadStatisticsStore.cpp
     loader/ResourceLoader.cpp
     loader/ResourceTiming.cpp
     loader/ResourceTimingInformation.cpp
index c0afddb..5c12cd8 100644 (file)
@@ -1,3 +1,21 @@
+2017-06-30  Chris Dumez  <cdumez@apple.com>
+
+        Move ResourceLoadStatisticsStore to WebKit2/UIProcess
+        https://bugs.webkit.org/show_bug.cgi?id=174033
+
+        Reviewed by Brent Fulgham.
+
+        Move ResourceLoadStatisticsStore to WebKit2/UIProcess since it is only
+        used in the WebKit2 UIProcess.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::primaryDomain):
+        * loader/ResourceLoadStatistics.cpp:
+        (WebCore::ResourceLoadStatistics::primaryDomain):
+        * loader/ResourceLoadStatistics.h:
+
 2017-06-30  Ryosuke Niwa  <rniwa@webkit.org>
 
         Ran sort-Xcode-project-file.
index 54536ce..3e1331a 100644 (file)
                7AB0B1C11211A62200A76940 /* InspectorDatabaseAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB0B1BF1211A62200A76940 /* InspectorDatabaseAgent.h */; };
                7ACD88D314C08BD60084EDD2 /* InspectorIndexedDBAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7ACD88D114C08BD60084EDD2 /* InspectorIndexedDBAgent.cpp */; };
                7ACD88D414C08BD60084EDD2 /* InspectorIndexedDBAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ACD88D214C08BD60084EDD2 /* InspectorIndexedDBAgent.h */; };
-               7AD3CDD91C8A002F00F12698 /* ResourceLoadStatisticsStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A7CC8361C87506800366243 /* ResourceLoadStatisticsStore.cpp */; };
-               7AD3CDDA1C8A01A400F12698 /* ResourceLoadStatisticsStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A7CC8371C87506800366243 /* ResourceLoadStatisticsStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7ADE722610CBBB9B006B3B3A /* ContextMenuProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7AE335F11ACB09E200E401EF /* WheelEventTestTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AE335EF1ACB09E200E401EF /* WheelEventTestTrigger.cpp */; };
                7AE335F21ACB09E200E401EF /* WheelEventTestTrigger.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AE335F01ACB09E200E401EF /* WheelEventTestTrigger.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7A74ECB8101839A500BF939E /* InspectorDOMStorageAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDOMStorageAgent.cpp; sourceTree = "<group>"; };
                7A74ECB9101839A600BF939E /* InspectorDOMStorageAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDOMStorageAgent.h; sourceTree = "<group>"; };
                7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInspectorFrontendHostCustom.cpp; sourceTree = "<group>"; };
-               7A7CC8361C87506800366243 /* ResourceLoadStatisticsStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsStore.cpp; sourceTree = "<group>"; };
-               7A7CC8371C87506800366243 /* ResourceLoadStatisticsStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsStore.h; sourceTree = "<group>"; };
                7A929CA11C598378004DF226 /* ResourceLoadStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatistics.cpp; sourceTree = "<group>"; };
                7A929CA21C598378004DF226 /* ResourceLoadStatistics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatistics.h; sourceTree = "<group>"; };
                7A93868218DCC14500B8263D /* VTTScanner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VTTScanner.cpp; sourceTree = "<group>"; };
                                6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */,
                                7A929CA11C598378004DF226 /* ResourceLoadStatistics.cpp */,
                                7A929CA21C598378004DF226 /* ResourceLoadStatistics.h */,
-                               7A7CC8361C87506800366243 /* ResourceLoadStatisticsStore.cpp */,
-                               7A7CC8371C87506800366243 /* ResourceLoadStatisticsStore.h */,
                                A5CE9F3E1E4C416B001BBE7C /* ResourceTiming.cpp */,
                                A5CE9F3C1E4BC586001BBE7C /* ResourceTiming.h */,
                                CBC2D22D1CE5B77400D1880B /* ResourceTimingInformation.cpp */,
                                6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */,
                                E4295FA412B0614E00D1ACE0 /* ResourceLoadPriority.h in Headers */,
                                7A929CA71C598AA9004DF226 /* ResourceLoadStatistics.h in Headers */,
-                               7AD3CDDA1C8A01A400F12698 /* ResourceLoadStatisticsStore.h in Headers */,
                                7EE6846D12D26E3800E79415 /* ResourceRequest.h in Headers */,
                                514C767D0CE923A1007EF3CD /* ResourceRequestBase.h in Headers */,
                                7EE6846F12D26E3800E79415 /* ResourceRequestCFNet.h in Headers */,
                                973E325610883B7C005BC493 /* ResourceLoadNotifier.cpp in Sources */,
                                6B693A341C51A95D00B03BEF /* ResourceLoadObserver.cpp in Sources */,
                                7A929CA61C598A9E004DF226 /* ResourceLoadStatistics.cpp in Sources */,
-                               7AD3CDD91C8A002F00F12698 /* ResourceLoadStatisticsStore.cpp in Sources */,
                                514C767C0CE923A1007EF3CD /* ResourceRequestBase.cpp in Sources */,
                                7EE6846E12D26E3800E79415 /* ResourceRequestCFNet.cpp in Sources */,
                                7E7DE1FD195CEF260035363B /* ResourceRequestCocoa.mm in Sources */,
index 17c2d16..d27a6a1 100644 (file)
@@ -31,7 +31,7 @@
 #include "Logging.h"
 #include "MainFrame.h"
 #include "Page.h"
-#include "ResourceLoadStatisticsStore.h"
+#include "ResourceLoadStatistics.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
 #include "SecurityOrigin.h"
@@ -43,7 +43,7 @@ namespace WebCore {
 
 template<typename T> static inline String primaryDomain(const T& value)
 {
-    return ResourceLoadStatisticsStore::primaryDomain(value);
+    return ResourceLoadStatistics::primaryDomain(value);
 }
 
 static Seconds timestampResolution { 1_h };
index eefa5af..251591c 100644 (file)
@@ -27,6 +27,7 @@
 #include "ResourceLoadStatistics.h"
 
 #include "KeyedCoding.h"
+#include "PublicSuffix.h"
 #include <wtf/text/StringBuilder.h>
 #include <wtf/text/StringHash.h>
 
@@ -364,4 +365,24 @@ void ResourceLoadStatistics::merge(const ResourceLoadStatistics& other)
     isMarkedForCookiePartitioning |= other.isMarkedForCookiePartitioning;
 }
 
+String ResourceLoadStatistics::primaryDomain(const URL& url)
+{
+    return primaryDomain(url.host());
+}
+
+String ResourceLoadStatistics::primaryDomain(const String& host)
+{
+    if (host.isNull() || host.isEmpty())
+        return ASCIILiteral("nullOrigin");
+
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+    String primaryDomain = topPrivatelyControlledDomain(host);
+    // We will have an empty string here if there is no TLD. Use the host as a fallback.
+    if (!primaryDomain.isEmpty())
+        return primaryDomain;
+#endif
+
+    return host;
+}
+
 }
index ebe6895..ae33608 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "URL.h"
 #include <wtf/HashCountedSet.h>
 #include <wtf/WallTime.h>
 #include <wtf/text/StringHash.h>
@@ -48,12 +49,15 @@ struct ResourceLoadStatistics {
     ResourceLoadStatistics(ResourceLoadStatistics&&) = default;
     ResourceLoadStatistics& operator=(ResourceLoadStatistics&&) = default;
 
-    void encode(KeyedEncoder&) const;
-    bool decode(KeyedDecoder&, unsigned version);
+    WEBCORE_EXPORT static String primaryDomain(const URL&);
+    WEBCORE_EXPORT static String primaryDomain(const String& host);
+
+    WEBCORE_EXPORT void encode(KeyedEncoder&) const;
+    WEBCORE_EXPORT bool decode(KeyedDecoder&, unsigned version);
 
     String toString() const;
 
-    void merge(const ResourceLoadStatistics&);
+    WEBCORE_EXPORT void merge(const ResourceLoadStatistics&);
 
     String highLevelDomain;
 
index ef6b00b..3c12797 100644 (file)
@@ -435,6 +435,7 @@ set(WebKit2_SOURCES
 
     UIProcess/Storage/LocalStorageDatabase.cpp
     UIProcess/Storage/LocalStorageDatabaseTracker.cpp
+    UIProcess/Storage/ResourceLoadStatisticsStore.cpp
 
     UIProcess/UserContent/WebScriptMessageHandler.cpp
     UIProcess/UserContent/WebUserContentControllerProxy.cpp
index 64b4906..71556eb 100644 (file)
@@ -1,3 +1,38 @@
+2017-06-30  Chris Dumez  <cdumez@apple.com>
+
+        Move ResourceLoadStatisticsStore to WebKit2/UIProcess
+        https://bugs.webkit.org/show_bug.cgi?id=174033
+
+        Reviewed by Brent Fulgham.
+
+        Move ResourceLoadStatisticsStore to WebKit2/UIProcess since it is only
+        used in the WebKit2 UIProcess.
+
+        * CMakeLists.txt:
+        * UIProcess/Storage/ResourceLoadStatisticsStore.cpp: Renamed from Source/WebCore/loader/ResourceLoadStatisticsStore.cpp.
+        (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
+        (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
+        (WebKit::ResourceLoadStatisticsStore::clearInMemory):
+        (WebKit::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
+        (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
+        (WebKit::ResourceLoadStatisticsStore::fireDataModificationHandler):
+        (WebKit::ResourceLoadStatisticsStore::fireTelemetryHandler):
+        (WebKit::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
+        (WebKit::ResourceLoadStatisticsStore::processStatistics):
+        (WebKit::ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry):
+        (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
+        (WebKit::ResourceLoadStatisticsStore::dataRecordsBeingRemoved):
+        (WebKit::ResourceLoadStatisticsStore::dataRecordsWereRemoved):
+        (WebKit::ResourceLoadStatisticsStore::statisticsLock):
+        * UIProcess/Storage/ResourceLoadStatisticsStore.h: Renamed from Source/WebCore/loader/ResourceLoadStatisticsStore.h.
+        * UIProcess/WebResourceLoadStatisticsManager.cpp:
+        (WebKit::primaryDomain):
+        * UIProcess/WebResourceLoadStatisticsManager.h:
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+        * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
+        * UIProcess/WebResourceLoadStatisticsTelemetry.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2017-06-30  Ryosuke Niwa  <rniwa@webkit.org>
 
         Ran sort-Xcode-project-file.
 #include "config.h"
 #include "ResourceLoadStatisticsStore.h"
 
-#include "KeyedCoding.h"
 #include "Logging.h"
-#include "NetworkStorageSession.h"
-#include "PlatformStrategies.h"
-#include "PublicSuffix.h"
-#include "ResourceLoadStatistics.h"
-#include "SharedBuffer.h"
-#include "URL.h"
+#include <WebCore/KeyedCoding.h>
+#include <WebCore/ResourceLoadStatistics.h>
+#include <WebCore/SharedBuffer.h>
+#include <WebCore/URL.h>
 #include <wtf/CrossThreadCopier.h>
-#include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/RunLoop.h>
 
-namespace WebCore {
+namespace WebKit {
+
+using namespace WebCore;
 
 static const auto statisticsModelVersion = 4;
 static Seconds timeToLiveUserInteraction { 24_h * 30. };
@@ -76,7 +74,7 @@ typedef HashMap<String, ResourceLoadStatistics>::KeyValuePairType StatisticsValu
 
 std::unique_ptr<KeyedEncoder> ResourceLoadStatisticsStore::createEncoderFromData()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     auto encoder = KeyedEncoder::encoder();
 
     auto locker = holdLock(m_statisticsLock);
@@ -92,7 +90,7 @@ std::unique_ptr<KeyedEncoder> ResourceLoadStatisticsStore::createEncoderFromData
 
 void ResourceLoadStatisticsStore::readDataFromDecoder(KeyedDecoder& decoder)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     ASSERT(m_statisticsLock.isLocked());
     if (m_resourceStatisticsMap.size())
         return;
@@ -137,7 +135,7 @@ void ResourceLoadStatisticsStore::readDataFromDecoder(KeyedDecoder& decoder)
 
 void ResourceLoadStatisticsStore::clearInMemory()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     {
     auto locker = holdLock(m_statisticsLock);
     m_resourceStatisticsMap.clear();
@@ -148,7 +146,7 @@ void ResourceLoadStatisticsStore::clearInMemory()
 
 void ResourceLoadStatisticsStore::clearInMemoryAndPersistent()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     clearInMemory();
     if (m_deletePersistentStoreHandler)
         m_deletePersistentStoreHandler();
@@ -158,7 +156,7 @@ void ResourceLoadStatisticsStore::clearInMemoryAndPersistent()
 
 void ResourceLoadStatisticsStore::mergeStatistics(const Vector<ResourceLoadStatistics>& statistics)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     auto locker = holdLock(m_statisticsLock);
     for (auto& statistic : statistics) {
         auto result = m_resourceStatisticsMap.ensure(statistic.highLevelDomain, [&statistic] {
@@ -201,7 +199,7 @@ void ResourceLoadStatisticsStore::setFireTelemetryCallback(WTF::Function<void()>
     
 void ResourceLoadStatisticsStore::fireDataModificationHandler()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     RunLoop::main().dispatch([this, protectedThis = makeRef(*this)] () {
         if (m_dataAddedHandler)
             m_dataAddedHandler();
@@ -210,7 +208,7 @@ void ResourceLoadStatisticsStore::fireDataModificationHandler()
 
 void ResourceLoadStatisticsStore::fireTelemetryHandler()
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     if (m_fireTelemetryHandler)
         m_fireTelemetryHandler();
 }
@@ -222,7 +220,7 @@ static inline bool shouldPartitionCookies(const ResourceLoadStatistics& statisti
 
 void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     Vector<String> domainsToRemove;
     Vector<String> domainsToAdd;
     
@@ -249,7 +247,7 @@ void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler()
 
 void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     if (domainsToRemove.isEmpty() && domainsToAdd.isEmpty())
         return;
     
@@ -297,7 +295,7 @@ void ResourceLoadStatisticsStore::setGrandfatheringTime(Seconds seconds)
 
 void ResourceLoadStatisticsStore::processStatistics(WTF::Function<void(ResourceLoadStatistics&)>&& processFunction)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     auto locker = holdLock(m_statisticsLock);
     for (auto& resourceStatistic : m_resourceStatisticsMap.values())
         processFunction(resourceStatistic);
@@ -346,7 +344,7 @@ Vector<String> ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemov
     
 Vector<PrevalentResourceTelemetry> ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry() const
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     auto locker = holdLock(m_statisticsLock);
     Vector<PrevalentResourceTelemetry> sorted;
     for (auto& statistic : m_resourceStatisticsMap.values()) {
@@ -396,7 +394,7 @@ void ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore(HashSet<Str
 
 bool ResourceLoadStatisticsStore::shouldRemoveDataRecords() const
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     if (m_dataRecordsRemovalPending)
         return false;
 
@@ -408,14 +406,14 @@ bool ResourceLoadStatisticsStore::shouldRemoveDataRecords() const
 
 void ResourceLoadStatisticsStore::dataRecordsBeingRemoved()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     m_lastTimeDataRecordsWereRemoved = MonotonicTime::now();
     m_dataRecordsRemovalPending = true;
 }
 
 void ResourceLoadStatisticsStore::dataRecordsWereRemoved()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     m_dataRecordsRemovalPending = false;
 }
     
@@ -423,25 +421,5 @@ WTF::RecursiveLockAdapter<Lock>& ResourceLoadStatisticsStore::statisticsLock()
 {
     return m_statisticsLock;
 }
-
-String ResourceLoadStatisticsStore::primaryDomain(const URL& url)
-{
-    return primaryDomain(url.host());
-}
-
-String ResourceLoadStatisticsStore::primaryDomain(const String& host)
-{
-    if (host.isNull() || host.isEmpty())
-        return ASCIILiteral("nullOrigin");
-
-#if ENABLE(PUBLIC_SUFFIX_LIST)
-    String primaryDomain = topPrivatelyControlledDomain(host);
-    // We will have an empty string here if there is no TLD. Use the host as a fallback.
-    if (!primaryDomain.isEmpty())
-        return primaryDomain;
-#endif
-
-    return host;
-}
     
 }
 
 #pragma once
 
-#include "ResourceLoadStatistics.h"
 #include <wtf/Function.h>
+#include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/MonotonicTime.h>
 #include <wtf/RecursiveLockAdapter.h>
 #include <wtf/WallTime.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
-
 class KeyedDecoder;
 class KeyedEncoder;
-class URL;
+struct ResourceLoadStatistics;
+}
+
+namespace WebKit {
 
 static const auto minimumPrevalentResourcesForTelemetry = 3;
 
@@ -49,65 +52,60 @@ struct PrevalentResourceTelemetry {
     unsigned subresourceUniqueRedirectsTo;
 };
 
-struct ResourceLoadStatistics;
-
-// FIXME: This should be moved to WebKit2/UIProcess.
+// FIXME: We should probably consider merging this with WebResourceLoadStatisticsStore.
 class ResourceLoadStatisticsStore : public ThreadSafeRefCounted<ResourceLoadStatisticsStore> {
 public:
-    WEBCORE_EXPORT static Ref<ResourceLoadStatisticsStore> create();
+    static Ref<ResourceLoadStatisticsStore> create();
 
-    WEBCORE_EXPORT std::unique_ptr<KeyedEncoder> createEncoderFromData();
-    WEBCORE_EXPORT void readDataFromDecoder(KeyedDecoder&);
+    std::unique_ptr<WebCore::KeyedEncoder> createEncoderFromData();
+    void readDataFromDecoder(WebCore::KeyedDecoder&);
 
     bool isEmpty() const { return m_resourceStatisticsMap.isEmpty(); }
     size_t size() const { return m_resourceStatisticsMap.size(); }
-    WEBCORE_EXPORT void clearInMemory();
-    WEBCORE_EXPORT void clearInMemoryAndPersistent();
+    void clearInMemory();
+    void clearInMemoryAndPersistent();
 
-    WEBCORE_EXPORT ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
-    void setResourceStatisticsForPrimaryDomain(const String&, ResourceLoadStatistics&&);
+    WebCore::ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
+    void setResourceStatisticsForPrimaryDomain(const String&, WebCore::ResourceLoadStatistics&&);
 
     bool isPrevalentResource(const String&) const;
     
-    WEBCORE_EXPORT void mergeStatistics(const Vector<ResourceLoadStatistics>&);
-
-    WEBCORE_EXPORT void setNotificationCallback(WTF::Function<void()>&&);
-    WEBCORE_EXPORT void setShouldPartitionCookiesCallback(WTF::Function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)>&&);
-    WEBCORE_EXPORT void setWritePersistentStoreCallback(WTF::Function<void()>&&);
-    WEBCORE_EXPORT void setDeletePersistentStoreCallback(WTF::Function<void()>&&);
-    WEBCORE_EXPORT void setGrandfatherExistingWebsiteDataCallback(WTF::Function<void()>&&);
-    WEBCORE_EXPORT void setFireTelemetryCallback(WTF::Function<void()>&& handler);
-
-    WEBCORE_EXPORT void fireDataModificationHandler();
-    WEBCORE_EXPORT void fireTelemetryHandler();
-    WEBCORE_EXPORT void setTimeToLiveUserInteraction(Seconds);
-    WEBCORE_EXPORT void setTimeToLiveCookiePartitionFree(Seconds);
-    WEBCORE_EXPORT void setMinimumTimeBetweeenDataRecordsRemoval(Seconds);
-    WEBCORE_EXPORT void setGrandfatheringTime(Seconds);
-    WEBCORE_EXPORT void fireShouldPartitionCookiesHandler();
-    WEBCORE_EXPORT void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
-
-    WEBCORE_EXPORT void processStatistics(WTF::Function<void(ResourceLoadStatistics&)>&&);
-
-    WEBCORE_EXPORT bool hasHadRecentUserInteraction(ResourceLoadStatistics&) const;
-    WEBCORE_EXPORT Vector<String> topPrivatelyControlledDomainsToRemoveWebsiteDataFor();
-    WEBCORE_EXPORT Vector<PrevalentResourceTelemetry> sortedPrevalentResourceTelemetry() const;
-    WEBCORE_EXPORT void updateStatisticsForRemovedDataRecords(const HashSet<String>& prevalentResourceDomains);
-
-    WEBCORE_EXPORT void handleFreshStartWithEmptyOrNoStore(HashSet<String>&& topPrivatelyControlledDomainsToGrandfather);
-    WEBCORE_EXPORT bool shouldRemoveDataRecords() const;
-    WEBCORE_EXPORT void dataRecordsBeingRemoved();
-    WEBCORE_EXPORT void dataRecordsWereRemoved();
+    void mergeStatistics(const Vector<WebCore::ResourceLoadStatistics>&);
+
+    void setNotificationCallback(WTF::Function<void()>&&);
+    void setShouldPartitionCookiesCallback(WTF::Function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)>&&);
+    void setWritePersistentStoreCallback(WTF::Function<void()>&&);
+    void setDeletePersistentStoreCallback(WTF::Function<void()>&&);
+    void setGrandfatherExistingWebsiteDataCallback(WTF::Function<void()>&&);
+    void setFireTelemetryCallback(WTF::Function<void()>&& handler);
+
+    void fireDataModificationHandler();
+    void fireTelemetryHandler();
+    void setTimeToLiveUserInteraction(Seconds);
+    void setTimeToLiveCookiePartitionFree(Seconds);
+    void setMinimumTimeBetweeenDataRecordsRemoval(Seconds);
+    void setGrandfatheringTime(Seconds);
+    void fireShouldPartitionCookiesHandler();
+    void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
+
+    void processStatistics(WTF::Function<void (WebCore::ResourceLoadStatistics&)>&&);
+
+    bool hasHadRecentUserInteraction(WebCore::ResourceLoadStatistics&) const;
+    Vector<String> topPrivatelyControlledDomainsToRemoveWebsiteDataFor();
+    Vector<PrevalentResourceTelemetry> sortedPrevalentResourceTelemetry() const;
+    void updateStatisticsForRemovedDataRecords(const HashSet<String>& prevalentResourceDomains);
+
+    void handleFreshStartWithEmptyOrNoStore(HashSet<String>&& topPrivatelyControlledDomainsToGrandfather);
+    bool shouldRemoveDataRecords() const;
+    void dataRecordsBeingRemoved();
+    void dataRecordsWereRemoved();
     
-    WEBCORE_EXPORT WTF::RecursiveLockAdapter<Lock>& statisticsLock();
-
-    WEBCORE_EXPORT static String primaryDomain(const URL&);
-    WEBCORE_EXPORT static String primaryDomain(const String& host);
+    WTF::RecursiveLockAdapter<Lock>& statisticsLock();
 
 private:
     ResourceLoadStatisticsStore() = default;
 
-    HashMap<String, ResourceLoadStatistics> m_resourceStatisticsMap;
+    HashMap<String, WebCore::ResourceLoadStatistics> m_resourceStatisticsMap;
     mutable WTF::RecursiveLockAdapter<Lock> m_statisticsLock;
 
     WTF::Function<void()> m_dataAddedHandler;
@@ -122,4 +120,4 @@ private:
     bool m_dataRecordsRemovalPending { false };
 };
     
-} // namespace WebCore
+} // namespace WebKit
index c1f4331..d758f83 100644 (file)
@@ -26,7 +26,8 @@
 #include "config.h"
 #include "WebResourceLoadStatisticsManager.h"
 
-#include <WebCore/ResourceLoadStatisticsStore.h>
+#include "ResourceLoadStatisticsStore.h"
+#include <WebCore/ResourceLoadStatistics.h>
 #include <WebCore/URL.h>
 #include <wtf/CrossThreadCopier.h>
 #include <wtf/NeverDestroyed.h>
@@ -39,7 +40,7 @@ using namespace WebCore;
 
 template<typename T> static inline String primaryDomain(const T& value)
 {
-    return ResourceLoadStatisticsStore::primaryDomain(value);
+    return ResourceLoadStatistics::primaryDomain(value);
 }
 
 WebResourceLoadStatisticsManager& WebResourceLoadStatisticsManager::shared()
index eb22870..eb844f5 100644 (file)
@@ -25,7 +25,8 @@
 
 #pragma once
 
-#include <WebCore/ResourceLoadStatisticsStore.h>
+#include <chrono>
+#include <wtf/Seconds.h>
 #include <wtf/text/WTFString.h>
 
 namespace WTF {
@@ -38,6 +39,8 @@ class URL;
 
 namespace WebKit {
 
+class ResourceLoadStatisticsStore;
+
 class WebResourceLoadStatisticsManager {
     friend class NeverDestroyed<WebResourceLoadStatisticsManager>;
 public:
@@ -67,7 +70,7 @@ public:
     void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
     void fireTelemetryHandler();
 
-    void setStatisticsStore(Ref<WebCore::ResourceLoadStatisticsStore>&&);
+    void setStatisticsStore(Ref<ResourceLoadStatisticsStore>&&);
     void setStatisticsQueue(Ref<WTF::WorkQueue>&&);
     void clearInMemoryStore();
     void clearInMemoryAndPersistentStore();
@@ -78,7 +81,7 @@ public:
 #endif
 
 private:
-    RefPtr<WebCore::ResourceLoadStatisticsStore> m_store;
+    RefPtr<ResourceLoadStatisticsStore> m_store;
     RefPtr<WTF::WorkQueue> m_queue;
 };
 
index 8a20ef3..33fed92 100644 (file)
@@ -28,9 +28,9 @@
 #include "APIObject.h"
 #include "Connection.h"
 #include "ResourceLoadStatisticsClassifier.h"
+#include "ResourceLoadStatisticsStore.h"
 #include "WebResourceLoadStatisticsTelemetry.h"
 #include "WebsiteDataRecord.h"
-#include <WebCore/ResourceLoadStatisticsStore.h>
 #include <wtf/RunLoop.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -76,8 +76,8 @@ public:
 
     void readDataFromDiskIfNeeded();
 
-    WebCore::ResourceLoadStatisticsStore& coreStore() { return m_resourceLoadStatisticsStore.get(); }
-    const WebCore::ResourceLoadStatisticsStore& coreStore() const { return m_resourceLoadStatisticsStore.get(); }
+    ResourceLoadStatisticsStore& coreStore() { return m_resourceLoadStatisticsStore.get(); }
+    const ResourceLoadStatisticsStore& coreStore() const { return m_resourceLoadStatisticsStore.get(); }
 
 private:
     explicit WebResourceLoadStatisticsStore(const String&);
@@ -107,7 +107,7 @@ private:
     void telemetryTimerFired();
     void submitTelemetry();
 
-    Ref<WebCore::ResourceLoadStatisticsStore> m_resourceLoadStatisticsStore;
+    Ref<ResourceLoadStatisticsStore> m_resourceLoadStatisticsStore;
 #if HAVE(CORE_PREDICTION)
     ResourceLoadStatisticsClassifierCocoa m_resourceLoadStatisticsClassifier;
 #else
index b60e1f5..5ec46f0 100644 (file)
 #include "config.h"
 #include "WebResourceLoadStatisticsTelemetry.h"
 
+#include "ResourceLoadStatisticsStore.h"
 #include "WebProcessPool.h"
 #include "WebProcessProxy.h"
 #include <WebCore/DiagnosticLoggingKeys.h>
 #include <WebCore/ResourceLoadStatistics.h>
-#include <WebCore/ResourceLoadStatisticsStore.h>
 #include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/RunLoop.h>
index a788830..7c2ff58 100644 (file)
 
 #include <wtf/text/WTFString.h>
 
-namespace WebCore {
+namespace WebKit {
+
 class ResourceLoadStatisticsStore;
-}
 
-namespace WebKit {
-    
 namespace WebResourceLoadStatisticsTelemetry {
     
-void calculateAndSubmit(const WebCore::ResourceLoadStatisticsStore&);
+void calculateAndSubmit(const ResourceLoadStatisticsStore&);
 void setNotifyPagesWhenTelemetryWasCaptured(bool);
     
-};
-    
+}
 }
index f883bf0..1ee4961 100644 (file)
                839902031BE9A02B000F3653 /* NetworkLoad.h in Headers */ = {isa = PBXBuildFile; fileRef = 839901FE1BE9A01B000F3653 /* NetworkLoad.h */; };
                839A2F311E2067450039057E /* HighPerformanceGraphicsUsageSampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 839A2F2F1E2067390039057E /* HighPerformanceGraphicsUsageSampler.cpp */; };
                839A2F321E2067450039057E /* HighPerformanceGraphicsUsageSampler.h in Headers */ = {isa = PBXBuildFile; fileRef = 839A2F301E2067390039057E /* HighPerformanceGraphicsUsageSampler.h */; };
+               83AFDC0A1F06CEEA00472815 /* ResourceLoadStatisticsStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83AFDC081F06CEE000472815 /* ResourceLoadStatisticsStore.cpp */; };
                83BDCCB91AC5FDB6003F6441 /* NetworkCacheStatistics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BDCCB81AC5FDB6003F6441 /* NetworkCacheStatistics.cpp */; };
                83BFAC421D96137C00433490 /* BlobDownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 83BFAC401D96136000433490 /* BlobDownloadClient.h */; };
                83BFAC431D96137C00433490 /* BlobDownloadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BFAC411D96136000433490 /* BlobDownloadClient.cpp */; };
                839901FF1BE9A01B000F3653 /* NetworkLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkLoad.cpp; path = NetworkProcess/NetworkLoad.cpp; sourceTree = "<group>"; };
                839A2F2F1E2067390039057E /* HighPerformanceGraphicsUsageSampler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HighPerformanceGraphicsUsageSampler.cpp; sourceTree = "<group>"; };
                839A2F301E2067390039057E /* HighPerformanceGraphicsUsageSampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HighPerformanceGraphicsUsageSampler.h; sourceTree = "<group>"; };
+               83AFDC081F06CEE000472815 /* ResourceLoadStatisticsStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsStore.cpp; sourceTree = "<group>"; };
+               83AFDC091F06CEE000472815 /* ResourceLoadStatisticsStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsStore.h; sourceTree = "<group>"; };
                83BDCCB81AC5FDB6003F6441 /* NetworkCacheStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheStatistics.cpp; sourceTree = "<group>"; };
                83BFAC401D96136000433490 /* BlobDownloadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlobDownloadClient.h; path = NetworkProcess/Downloads/BlobDownloadClient.h; sourceTree = "<group>"; };
                83BFAC411D96136000433490 /* BlobDownloadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BlobDownloadClient.cpp; path = NetworkProcess/Downloads/BlobDownloadClient.cpp; sourceTree = "<group>"; };
                                1A1D8BA01731A36300141DA4 /* LocalStorageDatabase.h */,
                                1A8C728A1738477C000A6554 /* LocalStorageDatabaseTracker.cpp */,
                                1A8C728B1738477C000A6554 /* LocalStorageDatabaseTracker.h */,
+                               83AFDC081F06CEE000472815 /* ResourceLoadStatisticsStore.cpp */,
+                               83AFDC091F06CEE000472815 /* ResourceLoadStatisticsStore.h */,
                                1A44B95916B73F9F00B7BBD8 /* StorageManager.cpp */,
                                1A44B95A16B73F9F00B7BBD8 /* StorageManager.h */,
                                1AB31A9316BC65AB00F6DBC9 /* StorageManager.messages.in */,
                                7A821F4E1E2F67A800604577 /* LegacyCustomProtocolManagerClient.mm in Sources */,
                                5C14271D1C23F8CF00D41183 /* LegacyCustomProtocolManagerCocoa.mm in Sources */,
                                2984F588164BA095004BC0C6 /* LegacyCustomProtocolManagerMessageReceiver.cpp in Sources */,
+                               83AFDC0A1F06CEEA00472815 /* ResourceLoadStatisticsStore.cpp in Sources */,
                                7A821F4A1E2F65E900604577 /* LegacyCustomProtocolManagerProxy.cpp in Sources */,
                                2984F57C164B915F004BC0C6 /* LegacyCustomProtocolManagerProxyMessageReceiver.cpp in Sources */,
                                1AFDE65D1954E8D500C48FFA /* LegacySessionStateCoding.cpp in Sources */,