Title: [242764] trunk/Source/WebKit
Revision
242764
Author
[email protected]
Date
2019-03-11 19:16:41 -0700 (Mon, 11 Mar 2019)

Log Message

Move NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm functionality into UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
https://bugs.webkit.org/show_bug.cgi?id=195117
<rdar://problem/48448715>

Reviewed by Brent Fulgham.

Reading of user defaults on Cocoa platforms should be done in the UI process and
forwarded to Resource Load Statistics in the network process through the
WebKit::NetworkSessionCreationParameters struct.

This patch does away with some old user defaults we don't use anymore. It also
changes the developer-facing default name to ITPManualPrevalentResource.

* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
    Removed the call to the old registerUserDefaultsIfNeeded().
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
    Removed the call to the old registerUserDefaultsIfNeeded().
* NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
    Removed the declaration of the old registerUserDefaultsIfNeeded().
* NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm: Removed.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
    Added an enum class EnableResourceLoadStatisticsDebugMode.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::encode const):
(WebKit::NetworkSessionCreationParameters::decode):
* NetworkProcess/NetworkSessionCreationParameters.h:
   The struct now has two new fields:
   - enableResourceLoadStatisticsDebugMode
   - resourceLoadStatisticsManualPrevalentResource
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
    Forwarding of the parameters.
* SourcesCocoa.txt:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureNetworkProcess):
    Forwarding of the parameters.
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::parameters):
    This is where user defaults for Resource Load Statistics are now read.
* WebKit.xcodeproj/project.pbxproj:

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (242763 => 242764)


--- trunk/Source/WebKit/ChangeLog	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/ChangeLog	2019-03-12 02:16:41 UTC (rev 242764)
@@ -1,3 +1,51 @@
+2019-03-11  John Wilander  <[email protected]>
+
+        Move NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm functionality into UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
+        https://bugs.webkit.org/show_bug.cgi?id=195117
+        <rdar://problem/48448715>
+
+        Reviewed by Brent Fulgham.
+
+        Reading of user defaults on Cocoa platforms should be done in the UI process and
+        forwarded to Resource Load Statistics in the network process through the
+        WebKit::NetworkSessionCreationParameters struct.
+
+        This patch does away with some old user defaults we don't use anymore. It also
+        changes the developer-facing default name to ITPManualPrevalentResource.
+
+        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+        (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
+            Removed the call to the old registerUserDefaultsIfNeeded().
+        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
+        (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
+            Removed the call to the old registerUserDefaultsIfNeeded().
+        * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
+            Removed the declaration of the old registerUserDefaultsIfNeeded().
+        * NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm: Removed.
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+            Added an enum class EnableResourceLoadStatisticsDebugMode.
+        * NetworkProcess/NetworkSession.cpp:
+        (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
+        * NetworkProcess/NetworkSession.h:
+        * NetworkProcess/NetworkSessionCreationParameters.cpp:
+        (WebKit::NetworkSessionCreationParameters::encode const):
+        (WebKit::NetworkSessionCreationParameters::decode):
+        * NetworkProcess/NetworkSessionCreationParameters.h:
+           The struct now has two new fields:
+           - enableResourceLoadStatisticsDebugMode
+           - resourceLoadStatisticsManualPrevalentResource
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+            Forwarding of the parameters.
+        * SourcesCocoa.txt:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::ensureNetworkProcess):
+            Forwarding of the parameters.
+        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+        (WebKit::WebsiteDataStore::parameters):
+            This is where user defaults for Resource Load Statistics are now read.
+        * WebKit.xcodeproj/project.pbxproj:
+
 2019-03-11  Zalan Bujtas  <[email protected]>
 
         [Synthetic Click] Dispatch mouseout soon after mouseup

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (242763 => 242764)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp	2019-03-12 02:16:41 UTC (rev 242764)
@@ -194,10 +194,6 @@
 {
     ASSERT(!RunLoop::isMain());
 
-#if PLATFORM(COCOA)
-    registerUserDefaultsIfNeeded();
-#endif
-
     if (!m_database.open(m_storageDirectoryPath)) {
         RELEASE_LOG_ERROR(Network, "%p - ResourceLoadStatisticsDatabaseStore::open failed, error message: %{public}s, database path: %{public}s", this, m_database.lastErrorMsg(), m_storageDirectoryPath.utf8().data());
         ASSERT_NOT_REACHED();

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp (242763 => 242764)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp	2019-03-12 02:16:41 UTC (rev 242764)
@@ -72,10 +72,6 @@
 {
     ASSERT(!RunLoop::isMain());
 
-#if PLATFORM(COCOA)
-    registerUserDefaultsIfNeeded();
-#endif
-
     workQueue.dispatchAfter(5_s, [weakThis = makeWeakPtr(*this)] {
         if (weakThis)
             weakThis->calculateAndSubmitTelemetry();

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h (242763 => 242764)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h	2019-03-12 02:16:41 UTC (rev 242764)
@@ -190,9 +190,6 @@
 
     bool hasStatisticsExpired(const ResourceLoadStatistics&) const;
     bool hasStatisticsExpired(WallTime mostRecentUserInteractionTime) const;
-#if PLATFORM(COCOA)
-    void registerUserDefaultsIfNeeded();
-#endif
     void scheduleStatisticsProcessingRequestIfNecessary();
     void mergeOperatingDates(Vector<OperatingDate>&&);
     virtual Vector<RegistrableDomain> ensurePrevalentResourcesForDebugMode() = 0;

Deleted: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm (242763 => 242764)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm	2019-03-12 02:16:41 UTC (rev 242764)
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2017-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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "ResourceLoadStatisticsStore.h"
-
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-
-#import <WebCore/RegistrableDomain.h>
-#import <wtf/text/StringBuilder.h>
-#import <wtf/text/WTFString.h>
-
-namespace WebKit {
-
-void ResourceLoadStatisticsStore::registerUserDefaultsIfNeeded()
-{
-    static dispatch_once_t initOnce;
-
-    dispatch_once(&initOnce, ^{
-        Seconds timeToLiveUserInteraction([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsTimeToLiveUserInteraction"]);
-        if (timeToLiveUserInteraction > 0_s && timeToLiveUserInteraction <= 24_h * 30)
-            setTimeToLiveUserInteraction(timeToLiveUserInteraction);
-
-        Seconds minimumTimeBetweenDataRecordsRemoval([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsMinimumTimeBetweenDataRecordsRemoval"]);
-        if (minimumTimeBetweenDataRecordsRemoval > 0_s && minimumTimeBetweenDataRecordsRemoval < 1_h)
-            setMinimumTimeBetweenDataRecordsRemoval(minimumTimeBetweenDataRecordsRemoval);
-
-        Seconds grandfatheringTime([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsGrandfatheringTime"]);
-        if (grandfatheringTime > 0_s && grandfatheringTime <= 24_h * 7)
-            setGrandfatheringTime(grandfatheringTime);
-
-        setResourceLoadStatisticsDebugMode([[NSUserDefaults standardUserDefaults] boolForKey:@"ItpDebugMode"]);
-        auto* debugManualPrevalentResource = [[NSUserDefaults standardUserDefaults] stringForKey:@"ItpManualPrevalentResource"];
-        if (debugManualPrevalentResource) {
-            URL url { URL(), debugManualPrevalentResource };
-            if (!url.isValid()) {
-                StringBuilder builder;
-                builder.appendLiteral("http://");
-                builder.append(debugManualPrevalentResource);
-                url = { URL(), builder.toString() };
-            }
-            if (url.isValid())
-                setPrevalentResourceForDebugMode(RegistrableDomain { url });
-        }
-
-        Seconds cacheMaxAgeCapForPrevalentResources([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsCacheMaxAgeCap"]);
-        if (cacheMaxAgeCapForPrevalentResources > 0_s && cacheMaxAgeCapForPrevalentResources <= 24_h * 365)
-            setCacheMaxAgeCap(cacheMaxAgeCapForPrevalentResources);
-        
-        Seconds clientSideCookiesAgeCap([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsClientSideCookiesAgeCap"]);
-        if (clientSideCookiesAgeCap > 0_s && clientSideCookiesAgeCap <= 24_h * 365)
-            setAgeCapForClientSideCookies(clientSideCookiesAgeCap);
-    });
-}
-
-}
-
-#endif

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (242763 => 242764)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2019-03-12 02:16:41 UTC (rev 242764)
@@ -59,6 +59,7 @@
 class WebProcessProxy;
 enum class ShouldGrandfatherStatistics : bool;
 enum class ShouldIncludeLocalhost : bool { No, Yes };
+enum class EnableResourceLoadStatisticsDebugMode : bool { No, Yes };
 
 class WebResourceLoadStatisticsStore final : public ThreadSafeRefCounted<WebResourceLoadStatisticsStore, WTF::DestructionThread::Main>, public IPC::MessageReceiver {
 public:

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (242763 => 242764)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2019-03-12 02:16:41 UTC (rev 242764)
@@ -100,6 +100,12 @@
         return;
 
     m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory, m_shouldIncludeLocalhostInResourceLoadStatistics);
+
+    if (m_enableResourceLoadStatisticsDebugMode == EnableResourceLoadStatisticsDebugMode::Yes)
+        m_resourceLoadStatistics->setResourceLoadStatisticsDebugMode(true, [] { });
+    // This should always be forwarded since debug mode may be enabled at runtime.
+    if (!m_resourceLoadStatisticsManualPrevalentResource.isEmpty())
+        m_resourceLoadStatistics->setPrevalentResourceForDebugMode(m_resourceLoadStatisticsManualPrevalentResource, [] { });
 }
 
 void NetworkSession::notifyResourceLoadStatisticsProcessed()

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (242763 => 242764)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2019-03-12 02:16:41 UTC (rev 242764)
@@ -93,6 +93,8 @@
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics;
     ShouldIncludeLocalhost m_shouldIncludeLocalhostInResourceLoadStatistics { ShouldIncludeLocalhost::Yes };
+    EnableResourceLoadStatisticsDebugMode m_enableResourceLoadStatisticsDebugMode { EnableResourceLoadStatisticsDebugMode::No };
+    WebCore::RegistrableDomain m_resourceLoadStatisticsManualPrevalentResource;
 #endif
     UniqueRef<NetworkAdClickAttribution> m_adClickAttribution;
 };

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp (242763 => 242764)


--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp	2019-03-12 02:16:41 UTC (rev 242764)
@@ -80,6 +80,8 @@
     encoder << resourceLoadStatisticsDirectoryExtensionHandle;
     encoder << enableResourceLoadStatistics;
     encoder << shouldIncludeLocalhostInResourceLoadStatistics;
+    encoder << enableResourceLoadStatisticsDebugMode;
+    encoder << resourceLoadStatisticsManualPrevalentResource;
 }
 
 Optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters::decode(IPC::Decoder& decoder)
@@ -178,6 +180,16 @@
     if (!shouldIncludeLocalhostInResourceLoadStatistics)
         return WTF::nullopt;
 
+    Optional<bool> enableResourceLoadStatisticsDebugMode;
+    decoder >> enableResourceLoadStatisticsDebugMode;
+    if (!enableResourceLoadStatisticsDebugMode)
+        return WTF::nullopt;
+
+    Optional<WebCore::RegistrableDomain> resourceLoadStatisticsManualPrevalentResource;
+    decoder >> resourceLoadStatisticsManualPrevalentResource;
+    if (!resourceLoadStatisticsManualPrevalentResource)
+        return WTF::nullopt;
+
     return {{
         sessionID
         , WTFMove(*boundInterfaceIdentifier)
@@ -203,6 +215,8 @@
         , WTFMove(*resourceLoadStatisticsDirectoryExtensionHandle)
         , WTFMove(*enableResourceLoadStatistics)
         , WTFMove(*shouldIncludeLocalhostInResourceLoadStatistics)
+        , WTFMove(*enableResourceLoadStatisticsDebugMode)
+        , WTFMove(*resourceLoadStatisticsManualPrevalentResource)
     }};
 }
 

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h (242763 => 242764)


--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h	2019-03-12 02:16:41 UTC (rev 242764)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "SandboxExtension.h"
+#include <WebCore/RegistrableDomain.h>
 #include <pal/SessionID.h>
 #include <wtf/Seconds.h>
 #include <wtf/URL.h>
@@ -82,6 +83,8 @@
     SandboxExtension::Handle resourceLoadStatisticsDirectoryExtensionHandle;
     bool enableResourceLoadStatistics { false };
     bool shouldIncludeLocalhostInResourceLoadStatistics { true };
+    bool enableResourceLoadStatisticsDebugMode { false };
+    WebCore::RegistrableDomain resourceLoadStatisticsManualPrevalentResource { };
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (242763 => 242764)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2019-03-12 02:16:41 UTC (rev 242764)
@@ -966,6 +966,8 @@
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     m_resourceLoadStatisticsDirectory = parameters.resourceLoadStatisticsDirectory;
     m_shouldIncludeLocalhostInResourceLoadStatistics = parameters.shouldIncludeLocalhostInResourceLoadStatistics ? ShouldIncludeLocalhost::Yes : ShouldIncludeLocalhost::No;
+    m_enableResourceLoadStatisticsDebugMode = parameters.enableResourceLoadStatisticsDebugMode ? EnableResourceLoadStatisticsDebugMode::Yes : EnableResourceLoadStatisticsDebugMode::No;
+    m_resourceLoadStatisticsManualPrevalentResource = parameters.resourceLoadStatisticsManualPrevalentResource;
     setResourceLoadStatisticsEnabled(parameters.enableResourceLoadStatistics);
 #endif
 

Modified: trunk/Source/WebKit/SourcesCocoa.txt (242763 => 242764)


--- trunk/Source/WebKit/SourcesCocoa.txt	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2019-03-12 02:16:41 UTC (rev 242764)
@@ -29,7 +29,6 @@
 NetworkProcess/cocoa/NetworkProcessCocoa.mm
 NetworkProcess/cocoa/NetworkSessionCocoa.mm
 
-NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm
 NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
 NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp
 

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (242763 => 242764)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-03-12 02:16:41 UTC (rev 242764)
@@ -575,16 +575,30 @@
 
     bool enableResourceLoadStatistics = false;
     bool shouldIncludeLocalhost = true;
+    bool enableResourceLoadStatisticsDebugMode = false;
+    WebCore::RegistrableDomain manualPrevalentResource { };
     if (withWebsiteDataStore) {
         enableResourceLoadStatistics = withWebsiteDataStore->resourceLoadStatisticsEnabled();
-        shouldIncludeLocalhost = withWebsiteDataStore->parameters().networkSessionParameters.shouldIncludeLocalhostInResourceLoadStatistics;
+        if (enableResourceLoadStatistics) {
+            auto networkSessionParameters = withWebsiteDataStore->parameters().networkSessionParameters;
+            shouldIncludeLocalhost = networkSessionParameters.shouldIncludeLocalhostInResourceLoadStatistics;
+            enableResourceLoadStatisticsDebugMode = networkSessionParameters.enableResourceLoadStatisticsDebugMode;
+            manualPrevalentResource = networkSessionParameters.resourceLoadStatisticsManualPrevalentResource;
+        }
     } else if (m_websiteDataStore) {
         enableResourceLoadStatistics = m_websiteDataStore->resourceLoadStatisticsEnabled();
-        shouldIncludeLocalhost = m_websiteDataStore->websiteDataStore().parameters().networkSessionParameters.shouldIncludeLocalhostInResourceLoadStatistics;
+        if (enableResourceLoadStatistics) {
+            auto networkSessionParameters = m_websiteDataStore->websiteDataStore().parameters().networkSessionParameters;
+            shouldIncludeLocalhost = networkSessionParameters.shouldIncludeLocalhostInResourceLoadStatistics;
+            enableResourceLoadStatisticsDebugMode = networkSessionParameters.enableResourceLoadStatisticsDebugMode;
+            manualPrevalentResource = networkSessionParameters.resourceLoadStatisticsManualPrevalentResource;
+        }
     }
 
     parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatistics = enableResourceLoadStatistics;
     parameters.defaultDataStoreParameters.networkSessionParameters.shouldIncludeLocalhostInResourceLoadStatistics = shouldIncludeLocalhost;
+    parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatisticsDebugMode = enableResourceLoadStatisticsDebugMode;
+    parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsManualPrevalentResource = manualPrevalentResource;
 
     // Add any platform specific parameters
     platformInitializeNetworkProcess(parameters);

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


--- trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2019-03-12 02:16:41 UTC (rev 242764)
@@ -30,6 +30,7 @@
 #import "StorageManager.h"
 #import "WebResourceLoadStatisticsStore.h"
 #import "WebsiteDataStoreParameters.h"
+#import <WebCore/RegistrableDomain.h>
 #import <WebCore/RuntimeApplicationChecks.h>
 #import <WebCore/SearchPopupMenuCocoa.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
@@ -36,6 +37,8 @@
 #import <wtf/FileSystem.h>
 #import <wtf/NeverDestroyed.h>
 #import <wtf/ProcessPrivilege.h>
+#import <wtf/URL.h>
+#import <wtf/text/StringBuilder.h>
 
 #if PLATFORM(IOS_FAMILY)
 #import <UIKit/UIApplication.h>
@@ -61,12 +64,28 @@
     resolveDirectoriesIfNecessary();
 
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-#if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
+    bool shouldLogCookieInformation = false;
+    bool enableResourceLoadStatisticsDebugMode = false;
+    WebCore::RegistrableDomain resourceLoadStatisticsManualPrevalentResource { };
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    enableResourceLoadStatisticsDebugMode = [defaults boolForKey:@"ITPDebugMode"];
+    auto* manualPrevalentResource = [defaults stringForKey:@"ITPManualPrevalentResource"];
+    if (manualPrevalentResource) {
+        URL url { URL(), manualPrevalentResource };
+        if (!url.isValid()) {
+            StringBuilder builder;
+            builder.appendLiteral("http://");
+            builder.append(manualPrevalentResource);
+            url = { URL(), builder.toString() };
+        }
+        if (url.isValid())
+            resourceLoadStatisticsManualPrevalentResource = WebCore::RegistrableDomain { url };
+    }
+#if !RELEASE_LOG_DISABLED
     static NSString * const WebKitLogCookieInformationDefaultsKey = @"WebKitLogCookieInformation";
-    bool shouldLogCookieInformation = [defaults boolForKey:WebKitLogCookieInformationDefaultsKey];
-#else
-    bool shouldLogCookieInformation = false;
+    shouldLogCookieInformation = [defaults boolForKey:WebKitLogCookieInformationDefaultsKey];
 #endif
+#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
 
     URL httpProxy = m_configuration->httpProxy();
     URL httpsProxy = m_configuration->httpsProxy();
@@ -88,6 +107,7 @@
     if (!resourceLoadStatisticsDirectory.isEmpty())
         SandboxExtension::createHandleForReadWriteDirectory(resourceLoadStatisticsDirectory, resourceLoadStatisticsDirectoryHandle);
 
+    bool shouldIncludeLocalhostInResourceLoadStatistics = isSafari;
     WebsiteDataStoreParameters parameters;
     parameters.networkSessionParameters = {
         m_sessionID,
@@ -103,7 +123,9 @@
         WTFMove(resourceLoadStatisticsDirectory),
         WTFMove(resourceLoadStatisticsDirectoryHandle),
         false,
-        isSafari
+        shouldIncludeLocalhostInResourceLoadStatistics,
+        enableResourceLoadStatisticsDebugMode,
+        WTFMove(resourceLoadStatisticsManualPrevalentResource)
     };
     finalizeApplicationIdentifiers();
 

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (242763 => 242764)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-03-12 01:58:17 UTC (rev 242763)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-03-12 02:16:41 UTC (rev 242764)
@@ -3569,7 +3569,6 @@
 		7AB6EA461EEAB6B000037B2B /* APIGeolocationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIGeolocationProvider.h; sourceTree = "<group>"; };
 		7ACE82E7221CAE06000DA94C /* ResourceLoadStatisticsStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ResourceLoadStatisticsStore.h; path = Classifier/ResourceLoadStatisticsStore.h; sourceTree = "<group>"; };
 		7ACE82E8221CAE07000DA94C /* ResourceLoadStatisticsStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ResourceLoadStatisticsStore.cpp; path = Classifier/ResourceLoadStatisticsStore.cpp; sourceTree = "<group>"; };
-		7ACE82E9221DE722000DA94C /* ResourceLoadStatisticsStoreCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = ResourceLoadStatisticsStoreCocoa.mm; path = Classifier/ResourceLoadStatisticsStoreCocoa.mm; sourceTree = "<group>"; };
 		7AF2361E1E79A3B400438A05 /* WebErrors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebErrors.cpp; sourceTree = "<group>"; };
 		7AF2361F1E79A3D800438A05 /* WebErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebErrors.h; sourceTree = "<group>"; };
 		7AF236221E79A43100438A05 /* WebErrorsCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebErrorsCocoa.mm; sourceTree = "<group>"; };
@@ -6977,7 +6976,6 @@
 				7AFBD36821E542E8005DBACB /* ResourceLoadStatisticsPersistentStorage.h */,
 				7ACE82E8221CAE07000DA94C /* ResourceLoadStatisticsStore.cpp */,
 				7ACE82E7221CAE06000DA94C /* ResourceLoadStatisticsStore.h */,
-				7ACE82E9221DE722000DA94C /* ResourceLoadStatisticsStoreCocoa.mm */,
 				7A41E9FA21F81DAC00B88CDB /* ShouldGrandfatherStatistics.h */,
 				7A3FECA121F7C09700F267CD /* StorageAccessStatus.h */,
 				7A843A1A21E41FB200DEF663 /* WebResourceLoadStatisticsStore.cpp */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to