Title: [239816] trunk/Source/WebKit
Revision
239816
Author
bfulg...@apple.com
Date
2019-01-09 19:28:48 -0800 (Wed, 09 Jan 2019)

Log Message

Create a WebResourceLoadStatisticsStore attached to the NetworkSession
https://bugs.webkit.org/show_bug.cgi?id=193261
<rdar://problem/47158616>

Reviewed by Alex Christensen.

This patch modifies NetworkSession so that it owns a WebResourceLoadStatisticsStore
object. This object is only created if the ResourceLoadStatistics feature is turned on.

The patch also modifies WebResourceLoadStatisticsStore so that it can be constructed
with an owning NetworkSession as an alternative to the current practice of using a
WebsiteDataStore object.

Two initial messages from the WebContent process are added (logFrameNavigation and
logUserNavigation) that notify the network process of these actions. Currently they
are called in addition the calls to the WebsiteDataStore object. These redundant calls
will be removed in a future patch.

This patch forces the ResourceLoadStatistics code in the NetworkSession to be off by
default, so there should be no change in behavior with this patch.

* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::updateClientSideCookiesAgeCap):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
(WebKit::WebResourceLoadStatisticsStore::hasStorageAccessForFrame):
(WebKit::WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler):
(WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
(WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):
(WebKit::WebResourceLoadStatisticsStore::removeAllStorageAccess):
(WebKit::WebResourceLoadStatisticsStore::logFrameNavigation):
(WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
(WebKit::WebResourceLoadStatisticsStore::setCacheMaxAgeCapForPrevalentResources):
(WebKit::WebResourceLoadStatisticsStore::setCacheMaxAgeCap):
(WebKit::WebResourceLoadStatisticsStore::updatePrevalentDomainsToBlockCookiesFor):
(WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler):
(WebKit::WebResourceLoadStatisticsStore::removePrevalentDomains):
(WebKit::WebResourceLoadStatisticsStore::callRemoveDomainsHandler):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::initializeNetworkProcess):
(WebKit::NetworkProcess::logFrameNavigation):
(WebKit::NetworkProcess::logUserInteraction):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::enableResourceLoadStatistics):
* NetworkProcess/NetworkSession.h:
(WebKit::NetworkSession::resourceLoadStatistics const):
* NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::privateSessionParameters):
(WebKit::NetworkSessionCreationParameters::encode const):
(WebKit::NetworkSessionCreationParameters::decode):
* NetworkProcess/NetworkSessionCreationParameters.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeNetworkProcess):
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::didLogUserInteraction):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebsiteDataStore::parameters):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::logFrameNavigation):
* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureNetworkProcess):
(WebKit::WebProcessPool::initializeNewWebProcess):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (239815 => 239816)


--- trunk/Source/WebKit/ChangeLog	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/ChangeLog	2019-01-10 03:28:48 UTC (rev 239816)
@@ -1,3 +1,77 @@
+2019-01-09  Brent Fulgham  <bfulg...@apple.com>
+
+        Create a WebResourceLoadStatisticsStore attached to the NetworkSession
+        https://bugs.webkit.org/show_bug.cgi?id=193261
+        <rdar://problem/47158616>
+
+        Reviewed by Alex Christensen.
+
+        This patch modifies NetworkSession so that it owns a WebResourceLoadStatisticsStore
+        object. This object is only created if the ResourceLoadStatistics feature is turned on.
+
+        The patch also modifies WebResourceLoadStatisticsStore so that it can be constructed
+        with an owning NetworkSession as an alternative to the current practice of using a
+        WebsiteDataStore object.
+
+        Two initial messages from the WebContent process are added (logFrameNavigation and
+        logUserNavigation) that notify the network process of these actions. Currently they
+        are called in addition the calls to the WebsiteDataStore object. These redundant calls
+        will be removed in a future patch.
+
+        This patch forces the ResourceLoadStatistics code in the NetworkSession to be off by
+        default, so there should be no change in behavior with this patch.
+
+        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
+        (WebKit::ResourceLoadStatisticsMemoryStore::updateClientSideCookiesAgeCap):
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
+        (WebKit::WebResourceLoadStatisticsStore::hasStorageAccessForFrame):
+        (WebKit::WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler):
+        (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
+        (WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):
+        (WebKit::WebResourceLoadStatisticsStore::removeAllStorageAccess):
+        (WebKit::WebResourceLoadStatisticsStore::logFrameNavigation):
+        (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
+        (WebKit::WebResourceLoadStatisticsStore::setCacheMaxAgeCapForPrevalentResources):
+        (WebKit::WebResourceLoadStatisticsStore::setCacheMaxAgeCap):
+        (WebKit::WebResourceLoadStatisticsStore::updatePrevalentDomainsToBlockCookiesFor):
+        (WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler):
+        (WebKit::WebResourceLoadStatisticsStore::removePrevalentDomains):
+        (WebKit::WebResourceLoadStatisticsStore::callRemoveDomainsHandler):
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::initializeNetworkProcess):
+        (WebKit::NetworkProcess::logFrameNavigation):
+        (WebKit::NetworkProcess::logUserInteraction):
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+        * NetworkProcess/NetworkSession.cpp:
+        (WebKit::NetworkSession::enableResourceLoadStatistics):
+        * NetworkProcess/NetworkSession.h:
+        (WebKit::NetworkSession::resourceLoadStatistics const):
+        * NetworkProcess/NetworkSessionCreationParameters.cpp:
+        (WebKit::NetworkSessionCreationParameters::privateSessionParameters):
+        (WebKit::NetworkSessionCreationParameters::encode const):
+        (WebKit::NetworkSessionCreationParameters::decode):
+        * NetworkProcess/NetworkSessionCreationParameters.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::didLogUserInteraction):
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxy.messages.in:
+        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+        (WebsiteDataStore::parameters):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+        (WebKit::WebPageProxy::logFrameNavigation):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::ensureNetworkProcess):
+        (WebKit::WebProcessPool::initializeNewWebProcess):
+
 2019-01-09  Alex Christensen  <achristen...@webkit.org>
 
         Replace SessionTracker with HashMap member of NetworkProcess

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp	2019-01-10 03:28:48 UTC (rev 239816)
@@ -27,6 +27,7 @@
 #include "ResourceLoadStatisticsMemoryStore.h"
 
 #include "Logging.h"
+#include "NetworkSession.h"
 #include "PluginProcessManager.h"
 #include "PluginProcessProxy.h"
 #include "ResourceLoadStatisticsPersistentStorage.h"
@@ -34,6 +35,7 @@
 #include "WebResourceLoadStatisticsTelemetry.h"
 #include "WebsiteDataStore.h"
 #include <WebCore/KeyedCoding.h>
+#include <WebCore/NetworkStorageSession.h>
 #include <WebCore/ResourceLoadStatistics.h>
 #include <wtf/CallbackAggregator.h>
 #include <wtf/DateMath.h>
@@ -862,6 +864,8 @@
     RunLoop::main().dispatch([store = makeRef(m_store), seconds = m_parameters.clientSideCookiesAgeCapTime] () {
         if (auto* websiteDataStore = store->websiteDataStore())
             websiteDataStore->setAgeCapForClientSideCookies(seconds, [] { });
+        if (auto* networkSession = store->networkSession())
+            networkSession->networkStorageSession().setAgeCapForClientSideCookies(seconds);
     });
 #endif
 }

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2019-01-10 03:28:48 UTC (rev 239816)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,6 +27,7 @@
 #include "WebResourceLoadStatisticsStore.h"
 
 #include "Logging.h"
+#include "NetworkSession.h"
 #include "ResourceLoadStatisticsMemoryStore.h"
 #include "ResourceLoadStatisticsPersistentStorage.h"
 #include "WebFrameProxy.h"
@@ -37,6 +38,7 @@
 #include "WebResourceLoadStatisticsTelemetry.h"
 #include "WebsiteDataFetchOption.h"
 #include "WebsiteDataStore.h"
+#include <WebCore/NetworkStorageSession.h>
 #include <WebCore/ResourceLoadStatistics.h>
 #include <wtf/CallbackAggregator.h>
 #include <wtf/CrossThreadCopier.h>
@@ -121,6 +123,21 @@
     m_dailyTasksTimer.startRepeating(24_h);
 }
 
+WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory)
+    : m_networkSession(makeWeakPtr(networkSession))
+    , m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::Type::Serial, WorkQueue::QOS::Utility))
+    , m_dailyTasksTimer(RunLoop::main(), this, &WebResourceLoadStatisticsStore::performDailyTasks)
+{
+    ASSERT(RunLoop::isMain());
+    
+    postTask([this, resourceLoadStatisticsDirectory = resourceLoadStatisticsDirectory.isolatedCopy()] {
+        m_memoryStore = std::make_unique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue);
+        m_persistentStorage = std::make_unique<ResourceLoadStatisticsPersistentStorage>(*m_memoryStore, m_statisticsQueue, resourceLoadStatisticsDirectory);
+    });
+    
+    m_dailyTasksTimer.startRepeating(24_h);
+}
+
 WebResourceLoadStatisticsStore::~WebResourceLoadStatisticsStore()
 {
     ASSERT(RunLoop::isMain());
@@ -236,6 +253,13 @@
     });
 }
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+bool WebResourceLoadStatisticsStore::hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID)
+{
+    return m_networkSession ? m_networkSession->networkStorageSession().hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID) : false;
+}
+#endif
+
 void WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&& callback)
 {
     ASSERT(RunLoop::isMain());
@@ -244,6 +268,9 @@
     if (m_websiteDataStore) {
         m_websiteDataStore->hasStorageAccessForFrameHandler(resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(callback));
         return;
+    } else {
+        callback(hasStorageAccessForFrame(resourceDomain, firstPartyDomain, frameID, pageID));
+        return;
     }
 #endif
     callback(false);
@@ -309,6 +336,21 @@
     });
 }
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+bool WebResourceLoadStatisticsStore::grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID)
+{
+    bool isStorageGranted = false;
+
+    if (m_networkSession) {
+        m_networkSession->networkStorageSession().grantStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID);
+        ASSERT(m_networkSession->networkStorageSession().hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID));
+        isStorageGranted = true;
+    }
+
+    return isStorageGranted;
+}
+#endif
+
 void WebResourceLoadStatisticsStore::callGrantStorageAccessHandler(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback)
 {
     ASSERT(RunLoop::isMain());
@@ -317,6 +359,9 @@
     if (m_websiteDataStore) {
         m_websiteDataStore->grantStorageAccessHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, WTFMove(callback));
         return;
+    } else {
+        callback(grantStorageAccess(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID));
+        return;
     }
 #endif
     callback(false);
@@ -333,18 +378,26 @@
     });
 }
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+void WebResourceLoadStatisticsStore::removeAllStorageAccess()
+{
+    if (m_networkSession)
+        m_networkSession->networkStorageSession().removeAllStorageAccess();
+}
+#endif
+
 void WebResourceLoadStatisticsStore::removeAllStorageAccess(CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    if (m_websiteDataStore)
+    if (m_websiteDataStore) {
         m_websiteDataStore->removeAllStorageAccessHandler(WTFMove(completionHandler));
-    else
-        completionHandler();
-#else
+        return;
+    }
+    removeAllStorageAccess();
+#endif
     completionHandler();
-#endif
 }
 
 void WebResourceLoadStatisticsStore::applicationWillTerminate()
@@ -402,7 +455,12 @@
     auto mainFramePrimaryDomain = ResourceLoadStatistics::primaryDomain(pageURL);
     auto sourcePrimaryDomain = ResourceLoadStatistics::primaryDomain(sourceURL);
 
-    postTask([this, targetPrimaryDomain = targetPrimaryDomain.isolatedCopy(), mainFramePrimaryDomain = mainFramePrimaryDomain.isolatedCopy(), sourcePrimaryDomain = sourcePrimaryDomain.isolatedCopy(), targetHost = targetHost.toString().isolatedCopy(), mainFrameHost = mainFrameHost.toString().isolatedCopy(), isRedirect, isMainFrame = frame.isMainFrame()] {
+    logFrameNavigation(targetPrimaryDomain, mainFramePrimaryDomain, sourcePrimaryDomain, targetHost.toString(), mainFrameHost.toString(), isRedirect, frame.isMainFrame());
+}
+
+void WebResourceLoadStatisticsStore::logFrameNavigation(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame)
+{
+    postTask([this, targetPrimaryDomain = targetPrimaryDomain.isolatedCopy(), mainFramePrimaryDomain = mainFramePrimaryDomain.isolatedCopy(), sourcePrimaryDomain = sourcePrimaryDomain.isolatedCopy(), targetHost = targetHost.isolatedCopy(), mainFrameHost = mainFrameHost.isolatedCopy(), isRedirect, isMainFrame] {
         
         if (m_memoryStore)
             m_memoryStore->logFrameNavigation(targetPrimaryDomain, mainFramePrimaryDomain, sourcePrimaryDomain, targetHost, mainFrameHost, isRedirect, isMainFrame);
@@ -418,7 +476,14 @@
         return;
     }
 
-    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
+    logUserInteraction(isolatedPrimaryDomain(url), WTFMove(completionHandler));
+}
+
+void WebResourceLoadStatisticsStore::logUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler)
+{
+    ASSERT(RunLoop::isMain());
+
+    postTask([this, primaryDomain = targetPrimaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
         if (m_memoryStore)
             m_memoryStore->logUserInteraction(primaryDomain);
         postTaskReply(WTFMove(completionHandler));
@@ -823,6 +888,14 @@
     });
 }
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+void WebResourceLoadStatisticsStore::setCacheMaxAgeCapForPrevalentResources(Seconds seconds)
+{
+    if (m_networkSession)
+        m_networkSession->networkStorageSession().setCacheMaxAgeCapForPrevalentResources(seconds);
+}
+#endif
+
 void WebResourceLoadStatisticsStore::setCacheMaxAgeCap(Seconds seconds, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
@@ -833,10 +906,19 @@
         m_websiteDataStore->setCacheMaxAgeCapForPrevalentResources(seconds, WTFMove(completionHandler));
         return;
     }
+    setCacheMaxAgeCapForPrevalentResources(seconds);
 #endif
     completionHandler();
 }
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+void WebResourceLoadStatisticsStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock)
+{
+    if (m_networkSession)
+        m_networkSession->networkStorageSession().setPrevalentDomainsToBlockCookiesFor(domainsToBlock);
+}
+#endif
+
 void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
@@ -846,10 +928,19 @@
         m_websiteDataStore->updatePrevalentDomainsToBlockCookiesFor(domainsToBlock, WTFMove(completionHandler));
         return;
     }
+    updatePrevalentDomainsToBlockCookiesFor(domainsToBlock);
 #endif
     completionHandler();
 }
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+void WebResourceLoadStatisticsStore::removePrevalentDomains(const Vector<String>& domains)
+{
+    if (m_networkSession)
+        m_networkSession->networkStorageSession().removePrevalentDomains(domains);
+}
+#endif
+
 void WebResourceLoadStatisticsStore::callRemoveDomainsHandler(const Vector<String>& domains)
 {
     ASSERT(RunLoop::isMain());
@@ -857,6 +948,7 @@
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     if (m_websiteDataStore)
         m_websiteDataStore->removePrevalentDomains(domains);
+    removePrevalentDomains(domains);
 #endif
 }
     

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2019-01-10 03:28:48 UTC (rev 239816)
@@ -46,6 +46,7 @@
 
 namespace WebKit {
 
+class NetworkSession;
 class ResourceLoadStatisticsMemoryStore;
 class ResourceLoadStatisticsPersistentStorage;
 class WebFrameProxy;
@@ -65,6 +66,11 @@
         return adoptRef(*new WebResourceLoadStatisticsStore(websiteDataStore));
     }
 
+    static Ref<WebResourceLoadStatisticsStore> create(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory)
+    {
+        return adoptRef(*new WebResourceLoadStatisticsStore(networkSession, resourceLoadStatisticsDirectory));
+    }
+
     ~WebResourceLoadStatisticsStore();
 
     static const OptionSet<WebsiteDataType>& monitoredDataTypes();
@@ -83,9 +89,13 @@
     void applicationWillTerminate();
 
     void logFrameNavigation(const WebFrameProxy&, const URL& pageURL, const WebCore::ResourceRequest&, const URL& redirectURL);
+    void logFrameNavigation(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame);
     void logUserInteraction(const URL&, CompletionHandler<void()>&&);
+    void logUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&);
     void clearUserInteraction(const URL&, CompletionHandler<void()>&&);
+    bool grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID);
     void hasHadUserInteraction(const URL&, CompletionHandler<void(bool)>&&);
+    bool hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID);
     void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&);
     void setPrevalentResource(const URL&, CompletionHandler<void()>&&);
     void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&);
@@ -98,6 +108,9 @@
     void clearPrevalentResource(const URL&, CompletionHandler<void()>&&);
     void setGrandfathered(const URL&, bool);
     void isGrandfathered(const URL&, CompletionHandler<void(bool)>&&);
+    void removeAllStorageAccess();
+    void removePrevalentDomains(const Vector<String>& domainsToBlock);
+    void setCacheMaxAgeCapForPrevalentResources(Seconds);
     void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame);
     void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame);
     void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo);
@@ -109,6 +122,7 @@
     void scheduleClearBlockingStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&&);
     void scheduleStatisticsAndDataRecordsProcessing();
     void submitTelemetry();
+    void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock);
 
     enum class ShouldGrandfather {
         No,
@@ -140,9 +154,11 @@
     void didCreateNetworkProcess();
 
     WebsiteDataStore* websiteDataStore() { return m_websiteDataStore.get(); }
+    NetworkSession* networkSession() { return m_networkSession.get(); }
 
 private:
     explicit WebResourceLoadStatisticsStore(WebsiteDataStore&);
+    explicit WebResourceLoadStatisticsStore(NetworkSession&, const String&);
 
     void postTask(WTF::Function<void()>&&);
     static void postTaskReply(WTF::Function<void()>&&);
@@ -161,6 +177,7 @@
     void flushAndDestroyPersistentStore();
 
     WeakPtr<WebsiteDataStore> m_websiteDataStore;
+    WeakPtr<NetworkSession> m_networkSession;
     Ref<WorkQueue> m_statisticsQueue;
     std::unique_ptr<ResourceLoadStatisticsMemoryStore> m_memoryStore;
     std::unique_ptr<ResourceLoadStatisticsPersistentStorage> m_persistentStorage;

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2019-01-10 03:28:48 UTC (rev 239816)
@@ -53,6 +53,7 @@
 #include "WebCookieManager.h"
 #include "WebPageProxyMessages.h"
 #include "WebProcessPoolMessages.h"
+#include "WebResourceLoadStatisticsStore.h"
 #include "WebSWOriginStore.h"
 #include "WebSWServerConnection.h"
 #include "WebSWServerToContextConnection.h"
@@ -300,6 +301,8 @@
     if (parameters.shouldUseTestingNetworkSession)
         NetworkStorageSession::switchToNewTestingSession();
 
+    SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectoryExtensionHandle);
+
     auto sessionID = parameters.defaultDataStoreParameters.networkSessionParameters.sessionID;
     setSession(sessionID, NetworkSession::create(*this, WTFMove(parameters.defaultDataStoreParameters.networkSessionParameters)));
 
@@ -534,6 +537,27 @@
     parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessRequestResult(isStorageGranted, contextId), 0);
 }
 
+void NetworkProcess::logFrameNavigation(PAL::SessionID sessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame)
+{
+    if (auto* networkSession = SessionTracker::networkSession(sessionID)) {
+        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
+            resourceLoadStatistics->logFrameNavigation(targetPrimaryDomain, mainFramePrimaryDomain, sourcePrimaryDomain, targetHost, mainFrameHost, isRedirect, isMainFrame);
+    } else
+        ASSERT_NOT_REACHED();
+}
+
+void NetworkProcess::logUserInteraction(PAL::SessionID sessionID, const String& targetPrimaryDomain, uint64_t contextId)
+{
+    if (auto* networkSession = SessionTracker::networkSession(sessionID)) {
+        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) {
+            resourceLoadStatistics->logUserInteraction(targetPrimaryDomain, [this, contextId] {
+                parentProcessConnection()->send(Messages::NetworkProcessProxy::DidLogUserInteraction(contextId), 0);
+            });        
+        }
+    } else
+        ASSERT_NOT_REACHED();
+}
+
 void NetworkProcess::removeAllStorageAccess(PAL::SessionID sessionID, uint64_t contextId)
 {
     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2019-01-10 03:28:48 UTC (rev 239816)
@@ -161,6 +161,8 @@
     void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId);
     void getAllStorageAccessEntries(PAL::SessionID, uint64_t contextId);
     void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId);
+    void logFrameNavigation(PAL::SessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame);
+    void logUserInteraction(PAL::SessionID, const String& targetPrimaryDomain, uint64_t contextId);
     void removeAllStorageAccess(PAL::SessionID, uint64_t contextId);
     void removePrevalentDomains(PAL::SessionID, const Vector<String>& domains);
     void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, uint64_t contextId);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2019-01-10 03:28:48 UTC (rev 239816)
@@ -90,6 +90,8 @@
     HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
     GetAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId)
     GrantStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId)
+    LogFrameNavigation(PAL::SessionID sessionID, String targetPrimaryDomain, String mainFramePrimaryDomain, String sourcePrimaryDomain, String targetHost, String mainFrameHost, bool isRedirect, bool isMainFrame)
+    LogUserInteraction(PAL::SessionID sessionID, String targetPrimaryDomain, uint64_t contextId)
     RemoveAllStorageAccess(PAL::SessionID sessionID, uint64_t contextId)
     RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction)
     SetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId)

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2019-01-10 03:28:48 UTC (rev 239816)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "NetworkSession.h"
 
+#include "WebResourceLoadStatisticsStore.h"
 #include <WebCore/NetworkStorageSession.h>
 
 #if PLATFORM(COCOA)
@@ -77,4 +78,12 @@
         task->invalidateAndCancel();
 }
 
+void NetworkSession::enableResourceLoadStatistics()
+{
+    if (m_resourceLoadStatistics)
+        return;
+
+    m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2019-01-10 03:28:48 UTC (rev 239816)
@@ -30,6 +30,8 @@
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Seconds.h>
+#include <wtf/WeakPtr.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 class NetworkStorageSession;
@@ -39,9 +41,10 @@
 
 class NetworkDataTask;
 class NetworkProcess;
+class WebResourceLoadStatisticsStore;
 struct NetworkSessionCreationParameters;
 
-class NetworkSession : public RefCounted<NetworkSession> {
+class NetworkSession : public RefCounted<NetworkSession>, public CanMakeWeakPtr<NetworkSession> {
 public:
     static Ref<NetworkSession> create(NetworkProcess&, NetworkSessionCreationParameters&&);
     virtual ~NetworkSession();
@@ -58,6 +61,9 @@
     void registerNetworkDataTask(NetworkDataTask& task) { m_dataTaskSet.add(&task); }
     void unregisterNetworkDataTask(NetworkDataTask& task) { m_dataTaskSet.remove(&task); }
 
+    WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); }
+    void enableResourceLoadStatistics();
+    
 protected:
     NetworkSession(NetworkProcess&, PAL::SessionID);
 
@@ -64,6 +70,8 @@
     PAL::SessionID m_sessionID;
     Ref<NetworkProcess> m_networkProcess;
     HashSet<NetworkDataTask*> m_dataTaskSet;
+    String m_resourceLoadStatisticsDirectory;
+    RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp	2019-01-10 03:28:48 UTC (rev 239816)
@@ -47,6 +47,7 @@
 #if USE(CURL)
         , { }, { }
 #endif
+        , { }, { }, false
     };
 }
 
@@ -68,6 +69,9 @@
     encoder << cookiePersistentStorageFile;
     encoder << proxySettings;
 #endif
+    encoder << resourceLoadStatisticsDirectory;
+    encoder << resourceLoadStatisticsDirectoryExtensionHandle;
+    encoder << enableResourceLoadStatistics;
 }
 
 Optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters::decode(IPC::Decoder& decoder)
@@ -133,7 +137,22 @@
     if (!proxySettings)
         return WTF::nullopt;
 #endif
-    
+
+    Optional<String> resourceLoadStatisticsDirectory;
+    decoder >> resourceLoadStatisticsDirectory;
+    if (!resourceLoadStatisticsDirectory)
+        return WTF::nullopt;
+
+    Optional<SandboxExtension::Handle> resourceLoadStatisticsDirectoryExtensionHandle;
+    decoder >> resourceLoadStatisticsDirectoryExtensionHandle;
+    if (!resourceLoadStatisticsDirectoryExtensionHandle)
+        return WTF::nullopt;
+
+    Optional<bool> enableResourceLoadStatistics;
+    decoder >> enableResourceLoadStatistics;
+    if (!enableResourceLoadStatistics)
+        return WTF::nullopt;
+
     return {{
         sessionID
         , WTFMove(*boundInterfaceIdentifier)
@@ -151,6 +170,9 @@
         , WTFMove(*cookiePersistentStorageFile)
         , WTFMove(*proxySettings)
 #endif
+        , WTFMove(*resourceLoadStatisticsDirectory)
+        , WTFMove(*resourceLoadStatisticsDirectoryExtensionHandle)
+        , WTFMove(*enableResourceLoadStatistics)
     }};
 }
 

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h	2019-01-10 03:28:48 UTC (rev 239816)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "SandboxExtension.h"
 #include <pal/SessionID.h>
 #include <wtf/Seconds.h>
 #include <wtf/URL.h>
@@ -69,6 +70,9 @@
     String cookiePersistentStorageFile;
     WebCore::CurlProxySettings proxySettings;
 #endif
+    String resourceLoadStatisticsDirectory;
+    SandboxExtension::Handle resourceLoadStatisticsDirectoryExtensionHandle;
+    bool enableResourceLoadStatistics { false };
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (239815 => 239816)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2019-01-10 03:28:48 UTC (rev 239816)
@@ -931,6 +931,10 @@
 
     m_statelessSessionDelegate = adoptNS([[WKNetworkSessionDelegate alloc] initWithNetworkSession:*this withCredentials:false]);
     m_statelessSession = [NSURLSession sessionWithConfiguration:configuration delegate:static_cast<id>(m_statelessSessionDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]];
+
+    m_resourceLoadStatisticsDirectory = parameters.resourceLoadStatisticsDirectory;
+    if (parameters.enableResourceLoadStatistics)
+        enableResourceLoadStatistics();
 }
 
 NetworkSessionCocoa::~NetworkSessionCocoa()

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (239815 => 239816)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2019-01-10 03:28:48 UTC (rev 239816)
@@ -419,6 +419,12 @@
     m_updateBlockCookiesCallbackMap.take(callbackId)();
 }
 
+void NetworkProcessProxy::didLogUserInteraction(uint64_t contextId)
+{
+    // FIXME(193297): Implement when activating automated test cases.
+    UNUSED_PARAM(contextId);
+}
+
 void NetworkProcessProxy::setAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds, CompletionHandler<void()>&& completionHandler)
 {
     if (!canSendMessage()) {

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (239815 => 239816)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2019-01-10 03:28:48 UTC (rev 239816)
@@ -142,6 +142,7 @@
     void logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample);
     void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample);
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
+    void didLogUserInteraction(uint64_t contextId);
     void didUpdateBlockCookies(uint64_t contextId);
     void didSetAgeCapForClientSideCookies(uint64_t contextId);
     void storageAccessRequestResult(bool wasGranted, uint64_t contextId);

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (239815 => 239816)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2019-01-10 03:28:48 UTC (rev 239816)
@@ -40,6 +40,7 @@
     LogDiagnosticMessageWithValue(uint64_t pageID, String message, String description, double value, unsigned significantFigures, enum:bool WebCore::ShouldSample shouldSample)
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
+    DidLogUserInteraction(uint64_t callbackId)
     DidUpdateBlockCookies(uint64_t callbackId)
     DidSetAgeCapForClientSideCookies(uint64_t callbackId)
     StorageAccessRequestResult(bool wasGranted, uint64_t contextId)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (239815 => 239816)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-01-10 03:28:48 UTC (rev 239816)
@@ -221,10 +221,6 @@
 #include "WebAuthenticatorCoordinatorProxy.h"
 #endif
 
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-#include "WebResourceLoadStatisticsStore.h"
-#endif
-
 #if ENABLE(REMOTE_INSPECTOR)
 #include <_javascript_Core/RemoteInspector.h>
 #endif
@@ -4451,8 +4447,11 @@
     API::Navigation* mainFrameNavigation = frame.isMainFrame() ? navigation.get() : nullptr;
     WebFrameProxy* originatingFrame = m_process->webFrame(originatingFrameInfoData.frameID);
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
     if (auto* resourceLoadStatisticsStore = websiteDataStore().resourceLoadStatistics())
         resourceLoadStatisticsStore->logFrameNavigation(frame, URL(URL(), m_pageLoadState.url()), request, redirectResponse.url());
+    logFrameNavigation(frame, URL(URL(), m_pageLoadState.url()), request, redirectResponse.url());
+#endif
 
     if (m_policyClient)
         m_policyClient->decidePolicyForNavigationAction(*this, &frame, WTFMove(navigationActionData), originatingFrame, originalRequest, WTFMove(request), WTFMove(listener), m_process->transformHandlesToObjects(userData.object()).get());
@@ -4475,6 +4474,38 @@
     m_shouldSuppressAppLinksInNextNavigationPolicyDecision = false;
 }
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+void WebPageProxy::logFrameNavigation(const WebFrameProxy& frame, const URL& pageURL, const WebCore::ResourceRequest& request, const URL& redirectURL)
+{
+    ASSERT(RunLoop::isMain());
+    
+    auto sourceURL = redirectURL;
+    bool isRedirect = !redirectURL.isNull();
+    if (!isRedirect) {
+        sourceURL = frame.url();
+        if (sourceURL.isNull())
+            sourceURL = pageURL;
+    }
+    
+    auto& targetURL = request.url();
+    
+    if (!targetURL.isValid() || !pageURL.isValid())
+        return;
+    
+    auto targetHost = targetURL.host();
+    auto mainFrameHost = pageURL.host();
+    
+    if (targetHost.isEmpty() || mainFrameHost.isEmpty() || targetHost == sourceURL.host())
+        return;
+    
+    auto targetPrimaryDomain = ResourceLoadStatistics::primaryDomain(targetURL);
+    auto mainFramePrimaryDomain = ResourceLoadStatistics::primaryDomain(pageURL);
+    auto sourcePrimaryDomain = ResourceLoadStatistics::primaryDomain(sourceURL);
+
+    m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::LogFrameNavigation(m_websiteDataStore->sessionID(), targetPrimaryDomain, mainFramePrimaryDomain, sourcePrimaryDomain, targetHost.toString(), mainFrameHost.toString(), isRedirect, frame.isMainFrame()));
+}
+#endif
+
 void WebPageProxy::decidePolicyForNavigationActionSync(uint64_t frameID, bool isMainFrame, WebCore::SecurityOriginData&& frameSecurityOrigin, uint64_t navigationID, NavigationActionData&& navigationActionData, FrameInfoData&& frameInfoData, uint64_t originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&& request, IPC::FormDataReference&& requestBody, WebCore::ResourceResponse&& redirectResponse, const UserData& userData, Messages::WebPageProxy::DecidePolicyForNavigationActionSync::DelayedReply&& reply)
 {
     auto sender = PolicyDecisionSender::create(WTFMove(reply));

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (239815 => 239816)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-01-10 03:28:48 UTC (rev 239816)
@@ -1907,6 +1907,10 @@
     void setNeedsFontAttributes(bool);
     void updateFontAttributesAfterEditorStateChange();
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    void logFrameNavigation(const WebFrameProxy&, const URL& pageURL, const WebCore::ResourceRequest&, const URL& redirectURL);
+#endif
+
     WeakPtr<PageClient> m_pageClient;
     Ref<API::PageConfiguration> m_configuration;
 

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (239815 => 239816)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-01-10 03:28:48 UTC (rev 239816)
@@ -548,6 +548,15 @@
     parameters.shouldDisableServiceWorkerProcessTerminationDelay = m_shouldDisableServiceWorkerProcessTerminationDelay;
 #endif
 
+    if (m_websiteDataStore)
+        parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectory = m_websiteDataStore->websiteDataStore().resolvedResourceLoadStatisticsDirectory();
+    if (parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectory.isEmpty())
+        parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectory = API::WebsiteDataStore::defaultResourceLoadStatisticsDirectory();
+
+    SandboxExtension::createHandleForReadWriteDirectory(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectory, parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectoryExtensionHandle);
+
+    parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatistics = false; // FIXME(193297): Turn on when the feature is on.
+
     // Add any platform specific parameters
     platformInitializeNetworkProcess(parameters);
 

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (239815 => 239816)


--- trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2019-01-10 03:08:07 UTC (rev 239815)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2019-01-10 03:28:48 UTC (rev 239816)
@@ -83,6 +83,11 @@
     if (!httpsProxy.isValid() && isSafari)
         httpsProxy = URL(URL(), [defaults stringForKey:(NSString *)WebKit2HTTPSProxyDefaultsKey]);
 
+    auto resourceLoadStatisticsDirectory = m_configuration->resourceLoadStatisticsDirectory();
+    SandboxExtension::Handle resourceLoadStatisticsDirectoryHandle;
+    if (!resourceLoadStatisticsDirectory.isEmpty())
+        SandboxExtension::createHandleForReadWriteDirectory(resourceLoadStatisticsDirectory, resourceLoadStatisticsDirectoryHandle);
+
     WebsiteDataStoreParameters parameters;
     parameters.networkSessionParameters = {
         m_sessionID,
@@ -95,6 +100,9 @@
         Seconds { [defaults integerForKey:WebKitNetworkLoadThrottleLatencyMillisecondsDefaultsKey] / 1000. },
         WTFMove(httpProxy),
         WTFMove(httpsProxy),
+        WTFMove(resourceLoadStatisticsDirectory),
+        WTFMove(resourceLoadStatisticsDirectoryHandle),
+        false // FIXME(193297): Switch to m_configuration->resourceLoadStatisticsEnabled()
     };
 
     auto cookieFile = resolvedCookieStorageFile();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to