Changeset 244818 in webkit


Ignore:
Timestamp:
Apr 30, 2019 7:28:07 PM (5 years ago)
Author:
wilander@apple.com
Message:

Add logging of Ad Click Attribution errors and events to a dedicated channel
https://bugs.webkit.org/show_bug.cgi?id=197332
<rdar://problem/49918800>

Reviewed by Youenn Fablet.

Source/WebCore:

This patch adds an experimental Ad Click Attribution debug mode which
logs information.

No new tests.

  • loader/AdClickAttribution.cpp:

(WebCore::AdClickAttribution::parseConversionRequest):
(WebCore::AdClickAttribution::debugModeEnabled):

  • loader/AdClickAttribution.h:
  • page/RuntimeEnabledFeatures.h:

(WebCore::RuntimeEnabledFeatures::adClickAttributionDebugModeEnabled const):
(WebCore::RuntimeEnabledFeatures::setAdClickAttributionDebugModeEnabled):

  • platform/Logging.h:

Source/WebKit:

This patch adds an experimental Ad Click Attribution debug mode which
logs information. Most changes are just log output in the various
functions in WebKit::AdClickAttributionManager.

The constructor to WebKit::AdClickAttributionManager now takes a
PAL::SessionID so that the log functions can make sure they don't
output anything in ephemeral sessions.

WebProcessPool::platformInitializeNetworkProcess() now picks up the
debug mode setting from the incoming
WebKit::NetworkProcessCreationParameters object.

NetworkResourceLoader::handleAdClickAttributionConversion() was
moved to AdClickAttributionManager::handleConversion() to keep all
the logging in one file.

  • NetworkProcess/AdClickAttributionManager.cpp:

(WebKit::AdClickAttributionManager::storeUnconverted):
(WebKit::AdClickAttributionManager::handleConversion):
(WebKit::AdClickAttributionManager::convert):
(WebKit::AdClickAttributionManager::fireConversionRequest):
(WebKit::AdClickAttributionManager::firePendingConversionRequests):
(WebKit::AdClickAttributionManager::clearExpired):
(WebKit::AdClickAttributionManager::debugModeEnabled const):

  • NetworkProcess/AdClickAttributionManager.h:

(WebKit::AdClickAttributionManager::AdClickAttributionManager):
(WebKit::AdClickAttributionManager::m_sessionID):

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::initializeNetworkProcess):

  • NetworkProcess/NetworkProcessCreationParameters.cpp:

(WebKit::NetworkProcessCreationParameters::encode const):
(WebKit::NetworkProcessCreationParameters::decode):

  • NetworkProcess/NetworkProcessCreationParameters.h:
  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest):
(WebKit::NetworkResourceLoader::handleAdClickAttributionConversion): Deleted.

  • NetworkProcess/NetworkSession.cpp:

(WebKit::NetworkSession::NetworkSession):
(WebKit::NetworkSession::handleAdClickAttributionConversion):
(WebKit::NetworkSession::convertAdClickAttribution): Deleted.

  • NetworkProcess/NetworkSession.h:
  • Platform/Logging.h:
  • Shared/WebPreferences.yaml:
  • UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::WebProcessPool::platformInitializeNetworkProcess):

Source/WTF:

Added missing RELEASE_LOG_INFO and RELEASE_LOG_INFO_IF dummies
for RELEASE_LOG_DISABLED.

  • wtf/Assertions.h:
Location:
trunk/Source
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r244815 r244818  
     12019-04-30  John Wilander  <wilander@apple.com>
     2
     3        Add logging of Ad Click Attribution errors and events to a dedicated channel
     4        https://bugs.webkit.org/show_bug.cgi?id=197332
     5        <rdar://problem/49918800>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        Added missing RELEASE_LOG_INFO and RELEASE_LOG_INFO_IF dummies
     10        for RELEASE_LOG_DISABLED.
     11
     12        * wtf/Assertions.h:
     13
    1142019-04-30  Youenn Fablet  <youenn@apple.com>
    215
  • trunk/Source/WTF/wtf/Assertions.h

    r243141 r244818  
    491491#define RELEASE_LOG_ERROR(channel, ...) LOG_ERROR(__VA_ARGS__)
    492492#define RELEASE_LOG_FAULT(channel, ...) LOG_ERROR(__VA_ARGS__)
     493#define RELEASE_LOG_INFO(channel, ...) ((void)0)
    493494
    494495#define RELEASE_LOG_IF(isAllowed, channel, ...) ((void)0)
    495496#define RELEASE_LOG_ERROR_IF(isAllowed, channel, ...) do { if (isAllowed) RELEASE_LOG_ERROR(channel, __VA_ARGS__); } while (0)
     497#define RELEASE_LOG_INFO_IF(isAllowed, channel, ...) ((void)0)
    496498
    497499#define RELEASE_LOG_WITH_LEVEL(channel, level, ...) ((void)0)
  • trunk/Source/WebCore/ChangeLog

    r244817 r244818  
     12019-04-30  John Wilander  <wilander@apple.com>
     2
     3        Add logging of Ad Click Attribution errors and events to a dedicated channel
     4        https://bugs.webkit.org/show_bug.cgi?id=197332
     5        <rdar://problem/49918800>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        This patch adds an experimental Ad Click Attribution debug mode which
     10        logs information.
     11
     12        No new tests.
     13
     14        * loader/AdClickAttribution.cpp:
     15        (WebCore::AdClickAttribution::parseConversionRequest):
     16        (WebCore::AdClickAttribution::debugModeEnabled):
     17        * loader/AdClickAttribution.h:
     18        * page/RuntimeEnabledFeatures.h:
     19        (WebCore::RuntimeEnabledFeatures::adClickAttributionDebugModeEnabled const):
     20        (WebCore::RuntimeEnabledFeatures::setAdClickAttributionDebugModeEnabled):
     21        * platform/Logging.h:
     22
    1232019-04-30  Myles C. Maxfield  <mmaxfield@apple.com>
    224
  • trunk/Source/WebCore/loader/AdClickAttribution.cpp

    r244614 r244818  
    2727#include "AdClickAttribution.h"
    2828
     29#include "Logging.h"
     30#include "RuntimeEnabledFeatures.h"
    2931#include <wtf/RandomNumber.h>
    3032#include <wtf/URL.h>
     
    5153Optional<AdClickAttribution::Conversion> AdClickAttribution::parseConversionRequest(const URL& redirectURL)
    5254{
    53     if (!redirectURL.protocolIs("https"_s) || redirectURL.hasUsername() || redirectURL.hasPassword() || redirectURL.hasQuery() || redirectURL.hasFragment())
     55    if (!redirectURL.protocolIs("https"_s) || redirectURL.hasUsername() || redirectURL.hasPassword() || redirectURL.hasQuery() || redirectURL.hasFragment()) {
     56        RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Conversion was not accepted because the URL's protocol is not HTTPS or the URL contains one or more of username, password, query string, and fragment.");
    5457        return { };
     58    }
    5559
    5660    auto path = StringView(redirectURL.string()).substring(redirectURL.pathStart(), redirectURL.pathEnd() - redirectURL.pathStart());
    57     if (path.isEmpty() || !path.startsWith(adClickAttributionPathPrefix))
     61    if (path.isEmpty() || !path.startsWith(adClickAttributionPathPrefix)) {
     62        RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Conversion was not accepted because the URL path did not start with %{public}s.", adClickAttributionPathPrefix);
    5863        return { };
     64    }
    5965
    6066    auto prefixLength = sizeof(adClickAttributionPathPrefix) - 1;
    6167    if (path.length() == prefixLength + adClickConversionDataPathSegmentSize) {
    6268        auto conversionDataUInt64 = path.substring(prefixLength, adClickConversionDataPathSegmentSize).toUInt64Strict();
    63         if (!conversionDataUInt64 || *conversionDataUInt64 > MaxEntropy)
     69        if (!conversionDataUInt64 || *conversionDataUInt64 > MaxEntropy) {
     70            RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Conversion was not accepted because the conversion data could not be parsed or was higher than the allowed maximum of %{public}u.", MaxEntropy);
    6471            return { };
     72        }
    6573
    6674        return Conversion { static_cast<uint32_t>(*conversionDataUInt64), Priority { 0 } };
     
    6977    if (path.length() == prefixLength + adClickConversionDataPathSegmentSize + 1 + adClickPriorityPathSegmentSize) {
    7078        auto conversionDataUInt64 = path.substring(prefixLength, adClickConversionDataPathSegmentSize).toUInt64Strict();
    71         if (!conversionDataUInt64 || *conversionDataUInt64 > MaxEntropy)
     79        if (!conversionDataUInt64 || *conversionDataUInt64 > MaxEntropy) {
     80            RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Conversion was not accepted because the conversion data could not be parsed or was higher than the allowed maximum of %{public}u.", MaxEntropy);
    7281            return { };
     82        }
    7383
    7484        auto conversionPriorityUInt64 = path.substring(prefixLength + adClickConversionDataPathSegmentSize + 1, adClickPriorityPathSegmentSize).toUInt64Strict();
    75         if (!conversionPriorityUInt64 || *conversionPriorityUInt64 > MaxEntropy)
     85        if (!conversionPriorityUInt64 || *conversionPriorityUInt64 > MaxEntropy) {
     86            RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Conversion was not accepted because the priority could not be parsed or was higher than the allowed maximum of %{public}u.", MaxEntropy);
    7687            return { };
     88        }
    7789
    7890        return Conversion { static_cast<uint32_t>(*conversionDataUInt64), Priority { static_cast<uint32_t>(*conversionPriorityUInt64) } };
    7991    }
    8092
     93    RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Conversion was not accepted because the URL path contained unrecognized parts.");
    8194    return { };
    8295}
     
    8497Optional<Seconds> AdClickAttribution::convertAndGetEarliestTimeToSend(Conversion&& conversion)
    8598{
    86     if (!conversion.isValid() || (m_conversion && m_conversion->priority > conversion.priority))
     99    if (!conversion.isValid() || (m_conversion && m_conversion->priority >= conversion.priority))
    87100        return { };
    88101
     
    213226}
    214227
    215 }
     228bool AdClickAttribution::debugModeEnabled()
     229{
     230    return RuntimeEnabledFeatures::sharedFeatures().adClickAttributionDebugModeEnabled();
     231}
     232
     233}
  • trunk/Source/WebCore/loader/AdClickAttribution.h

    r244614 r244818  
    263263private:
    264264    bool isValid() const;
     265    static bool debugModeEnabled();
    265266
    266267    Campaign m_campaign;
  • trunk/Source/WebCore/page/RuntimeEnabledFeatures.h

    r244202 r244818  
    342342    bool adClickAttributionEnabled() const { return m_adClickAttributionEnabled; }
    343343    void setAdClickAttributionEnabled(bool isEnabled) { m_adClickAttributionEnabled = isEnabled; }
     344    bool adClickAttributionDebugModeEnabled() const { return m_adClickAttributionDebugModeEnabled; }
     345    void setAdClickAttributionDebugModeEnabled(bool isEnabled) { m_adClickAttributionDebugModeEnabled = isEnabled; }
    344346
    345347#if ENABLE(TOUCH_EVENTS)
     
    526528
    527529    bool m_adClickAttributionEnabled { false };
     530    bool m_adClickAttributionDebugModeEnabled { false };
    528531
    529532#if ENABLE(TOUCH_EVENTS)
  • trunk/Source/WebCore/platform/Logging.h

    r244092 r244818  
    3939
    4040#define WEBCORE_LOG_CHANNELS(M) \
     41    M(AdClickAttribution) \
    4142    M(Animations) \
    4243    M(ApplePay) \
  • trunk/Source/WebKit/ChangeLog

    r244814 r244818  
     12019-04-30  John Wilander  <wilander@apple.com>
     2
     3        Add logging of Ad Click Attribution errors and events to a dedicated channel
     4        https://bugs.webkit.org/show_bug.cgi?id=197332
     5        <rdar://problem/49918800>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        This patch adds an experimental Ad Click Attribution debug mode which
     10        logs information. Most changes are just log output in the various
     11        functions in WebKit::AdClickAttributionManager.
     12
     13        The constructor to WebKit::AdClickAttributionManager now takes a
     14        PAL::SessionID so that the log functions can make sure they don't
     15        output anything in ephemeral sessions.
     16
     17        WebProcessPool::platformInitializeNetworkProcess() now picks up the
     18        debug mode setting from the incoming
     19        WebKit::NetworkProcessCreationParameters object.
     20
     21        NetworkResourceLoader::handleAdClickAttributionConversion() was
     22        moved to AdClickAttributionManager::handleConversion() to keep all
     23        the logging in one file.
     24
     25        * NetworkProcess/AdClickAttributionManager.cpp:
     26        (WebKit::AdClickAttributionManager::storeUnconverted):
     27        (WebKit::AdClickAttributionManager::handleConversion):
     28        (WebKit::AdClickAttributionManager::convert):
     29        (WebKit::AdClickAttributionManager::fireConversionRequest):
     30        (WebKit::AdClickAttributionManager::firePendingConversionRequests):
     31        (WebKit::AdClickAttributionManager::clearExpired):
     32        (WebKit::AdClickAttributionManager::debugModeEnabled const):
     33        * NetworkProcess/AdClickAttributionManager.h:
     34        (WebKit::AdClickAttributionManager::AdClickAttributionManager):
     35        (WebKit::AdClickAttributionManager::m_sessionID):
     36        * NetworkProcess/NetworkProcess.cpp:
     37        (WebKit::NetworkProcess::initializeNetworkProcess):
     38        * NetworkProcess/NetworkProcessCreationParameters.cpp:
     39        (WebKit::NetworkProcessCreationParameters::encode const):
     40        (WebKit::NetworkProcessCreationParameters::decode):
     41        * NetworkProcess/NetworkProcessCreationParameters.h:
     42        * NetworkProcess/NetworkResourceLoader.cpp:
     43        (WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest):
     44        (WebKit::NetworkResourceLoader::handleAdClickAttributionConversion): Deleted.
     45        * NetworkProcess/NetworkSession.cpp:
     46        (WebKit::NetworkSession::NetworkSession):
     47        (WebKit::NetworkSession::handleAdClickAttributionConversion):
     48        (WebKit::NetworkSession::convertAdClickAttribution): Deleted.
     49        * NetworkProcess/NetworkSession.h:
     50        * Platform/Logging.h:
     51        * Shared/WebPreferences.yaml:
     52        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     53        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
     54
    1552019-04-30  Devin Rousso  <drousso@apple.com>
    256
  • trunk/Source/WebKit/NetworkProcess/AdClickAttributionManager.cpp

    r244614 r244818  
    2727#include "AdClickAttributionManager.h"
    2828
     29#include "Logging.h"
    2930#include <WebCore/FetchOptions.h>
    3031#include <WebCore/FormData.h>
     
    3334#include <WebCore/ResourceResponse.h>
    3435#include <WebCore/RuntimeApplicationChecks.h>
     36#include <WebCore/RuntimeEnabledFeatures.h>
    3537#include <wtf/text/StringBuilder.h>
    3638#include <wtf/text/StringHash.h>
     
    4446using Conversion = AdClickAttribution::Conversion;
    4547
     48constexpr Seconds debugModeSecondsUntilSend { 60_s };
     49
    4650void AdClickAttributionManager::storeUnconverted(AdClickAttribution&& attribution)
    4751{
    4852    clearExpired();
    49    
     53
     54    RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Storing an ad click.");
    5055    m_unconvertedAdClickAttributionMap.set(std::make_pair(attribution.source(), attribution.destination()), WTFMove(attribution));
    5156}
    5257
     58void AdClickAttributionManager::handleConversion(Conversion&& conversion, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest)
     59{
     60    if (m_sessionID.isEphemeral())
     61        return;
     62
     63    RegistrableDomain redirectDomain { redirectRequest.url() };
     64    auto& firstPartyURL = redirectRequest.firstPartyForCookies();
     65
     66    if (!redirectDomain.matches(requestURL)) {
     67        RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Conversion was not accepted because the HTTP redirect was not same-site.");
     68        return;
     69    }
     70
     71    if (redirectDomain.matches(firstPartyURL)) {
     72        RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Conversion was not accepted because it was requested in an HTTP redirect that is same-site as the first-party.");
     73        return;
     74    }
     75
     76    convert(AdClickAttribution::Source { WTFMove(redirectDomain) }, AdClickAttribution::Destination { firstPartyURL }, WTFMove(conversion));
     77}
     78
    5379void AdClickAttributionManager::startTimer(Seconds seconds)
    5480{
     
    6086    clearExpired();
    6187
    62     if (!conversion.isValid())
    63         return;
     88    if (!conversion.isValid()) {
     89        RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Got an invalid conversion.");
     90        return;
     91    }
     92
     93#if !RELEASE_LOG_DISABLED
     94    auto conversionData = conversion.data;
     95    auto conversionPriority = conversion.priority;
     96#endif
     97
     98    RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Got a conversion with conversion data: %{public}u and priority: %{public}u.", conversionData, conversionPriority);
    6499
    65100    auto secondsUntilSend = Seconds::infinity();
     
    74109            secondsUntilSend = *optionalSecondsUntilSend;
    75110            ASSERT(secondsUntilSend != Seconds::infinity());
    76         }
    77         // If there is no previously converted attribution for this pair, add the new one.
    78         // If the newly converted attribution has higher priority, replace the old one.
    79         if (previouslyConvertedAttributionIter == m_convertedAdClickAttributionMap.end()
    80             || previouslyUnconvertedAttribution.hasHigherPriorityThan(previouslyConvertedAttributionIter->value))
     111            RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Converted a stored ad click with conversion data: %{public}u and priority: %{public}u.", conversionData, conversionPriority);
     112        }
     113
     114        if (previouslyConvertedAttributionIter == m_convertedAdClickAttributionMap.end())
     115            m_convertedAdClickAttributionMap.add(pair, WTFMove(previouslyUnconvertedAttribution));
     116        else if (previouslyUnconvertedAttribution.hasHigherPriorityThan(previouslyConvertedAttributionIter->value)) {
     117            // If the newly converted attribution has higher priority, replace the old one.
    81118            m_convertedAdClickAttributionMap.set(pair, WTFMove(previouslyUnconvertedAttribution));
     119            RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Replaced a previously converted ad click with a new one with conversion data: %{public}u and priority: %{public}u because it had higher priority.", conversionData, conversionPriority);
     120        }
    82121    } else if (previouslyConvertedAttributionIter != m_convertedAdClickAttributionMap.end()) {
    83122        // If we have no newly converted attribution, re-convert the old one to respect the new priority.
     
    85124            secondsUntilSend = *optionalSecondsUntilSend;
    86125            ASSERT(secondsUntilSend != Seconds::infinity());
     126            RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "Re-converted an ad click with a new one with conversion data: %{public}u and priority: %{public}u because it had higher priority.", conversionData, conversionPriority);
    87127        }
    88128    }
     
    93133    if (m_firePendingConversionRequestsTimer.isActive() && m_firePendingConversionRequestsTimer.nextFireInterval() < secondsUntilSend)
    94134        return;
    95    
     135
     136    if (debugModeEnabled()) {
     137        RELEASE_LOG_INFO(AdClickAttribution, "Setting timer for firing conversion requests to the debug mode timeout of %{public}f seconds where the regular timeout would have been %{public}f seconds.", debugModeSecondsUntilSend.seconds(), secondsUntilSend.seconds());
     138        secondsUntilSend = debugModeSecondsUntilSend;
     139    }
     140
    96141    startTimer(secondsUntilSend);
    97142}
     
    134179#endif
    135180
     181    RELEASE_LOG_INFO_IF(debugModeEnabled(), AdClickAttribution, "About to fire an attribution request for a conversion.");
     182
    136183    m_pingLoadFunction(WTFMove(loadParameters), [](const WebCore::ResourceError& error, const WebCore::ResourceResponse& response) {
    137         // FIXME: Add logging of errors to a dedicated channel.
     184        RELEASE_LOG_ERROR_IF(!error.isNull(), AdClickAttribution, "Received error: '%{public}s' for ad click attribution request.", error.localizedDescription().utf8().data());
    138185        UNUSED_PARAM(response);
    139186        UNUSED_PARAM(error);
     
    156203
    157204        auto now = WallTime::now();
    158         if (*earliestTimeToSend <= now || m_isRunningTest) {
     205        if (*earliestTimeToSend <= now || m_isRunningTest || debugModeEnabled()) {
    159206            fireConversionRequest(attribution);
    160207            attribution.markConversionAsSent();
     
    248295}
    249296
     297bool AdClickAttributionManager::debugModeEnabled() const
     298{
     299    return RuntimeEnabledFeatures::sharedFeatures().adClickAttributionDebugModeEnabled() && !m_sessionID.isEphemeral();
     300}
     301
    250302} // namespace WebKit
  • trunk/Source/WebKit/NetworkProcess/AdClickAttributionManager.h

    r244614 r244818  
    3434#include <wtf/CompletionHandler.h>
    3535#include <wtf/HashMap.h>
     36#include <wtf/WeakPtr.h>
    3637#include <wtf/text/WTFString.h>
    3738
    3839namespace WebKit {
    3940
    40 class AdClickAttributionManager {
     41class AdClickAttributionManager : public CanMakeWeakPtr<AdClickAttributionManager> {
    4142public:
    4243
     
    4748    using Conversion = WebCore::AdClickAttribution::Conversion;
    4849
    49     AdClickAttributionManager()
     50    explicit AdClickAttributionManager(PAL::SessionID sessionID)
    5051        : m_firePendingConversionRequestsTimer(*this, &AdClickAttributionManager::firePendingConversionRequests)
    5152        , m_pingLoadFunction([](NetworkResourceLoadParameters&& params, CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&)>&& completionHandler) {
     
    5354            completionHandler(WebCore::ResourceError(), WebCore::ResourceResponse());
    5455        })
     56        , m_sessionID(sessionID)
    5557    {
    5658    }
    5759
    5860    void storeUnconverted(AdClickAttribution&&);
    59     void convert(const Source&, const Destination&, Conversion&&);
     61    void handleConversion(Conversion&&, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest);
    6062    void clear();
    6163    void clearForRegistrableDomain(const RegistrableDomain&);
     
    6870private:
    6971    void startTimer(Seconds);
     72    void convert(const Source&, const Destination&, Conversion&&);
    7073    void fireConversionRequest(const AdClickAttribution&);
    7174    void firePendingConversionRequests();
    7275    void clearExpired();
     76    bool debugModeEnabled() const;
    7377
    7478    HashMap<std::pair<Source, Destination>, AdClickAttribution> m_unconvertedAdClickAttributionMap;
     
    7882    bool m_isRunningTest { false };
    7983    Optional<URL> m_conversionBaseURLForTesting;
     84    PAL::SessionID m_sessionID;
    8085};
    8186   
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r244700 r244818  
    307307    WebCore::RuntimeEnabledFeatures::sharedFeatures().setIsITPFirstPartyWebsiteDataRemovalEnabled(parameters.isITPFirstPartyWebsiteDataRemovalEnabled);
    308308
     309    WebCore::RuntimeEnabledFeatures::sharedFeatures().setAdClickAttributionDebugModeEnabled(parameters.enableAdClickAttributionDebugMode);
     310
    309311    SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectoryExtensionHandle);
    310312
  • trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp

    r243427 r244818  
    9292    encoder << downloadMonitorSpeedMultiplier;
    9393    encoder << isITPFirstPartyWebsiteDataRemovalEnabled;
     94    encoder << enableAdClickAttributionDebugMode;
    9495}
    9596
     
    221222        return false;
    222223
     224    if (!decoder.decode(result.enableAdClickAttributionDebugMode))
     225        return false;
     226
    223227    return true;
    224228}
  • trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h

    r243427 r244818  
    110110    bool isITPFirstPartyWebsiteDataRemovalEnabled { true };
    111111    uint32_t downloadMonitorSpeedMultiplier { 1 };
     112    bool enableAdClickAttributionDebugMode { false };
    112113};
    113114
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r244700 r244818  
    601601}
    602602
    603 void NetworkResourceLoader::handleAdClickAttributionConversion(AdClickAttribution::Conversion&& conversion, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest)
    604 {
    605     ASSERT(!sessionID().isEphemeral());
    606 
    607     RegistrableDomain redirectDomain { redirectRequest.url() };
    608     auto& firstPartyURL = redirectRequest.firstPartyForCookies();
    609     NetworkSession* networkSession = nullptr;
    610     // The redirect has to be done by the same registrable domain and it has to be a third-party request.
    611     if (redirectDomain.matches(requestURL) && !redirectDomain.matches(firstPartyURL) && (networkSession = m_connection->networkProcess().networkSession(sessionID())))
    612         networkSession->convertAdClickAttribution(AdClickAttribution::Source { WTFMove(redirectDomain) }, AdClickAttribution::Destination { firstPartyURL }, WTFMove(conversion));
    613 }
    614 
    615603void NetworkResourceLoader::willSendRedirectedRequest(ResourceRequest&& request, ResourceRequest&& redirectRequest, ResourceResponse&& redirectResponse)
    616604{
     
    673661    }
    674662
    675     if (adClickConversion)
    676         handleAdClickAttributionConversion(WTFMove(*adClickConversion), request.url(), redirectRequest);
     663    NetworkSession* networkSession = nullptr;
     664    if (adClickConversion && (networkSession = m_connection->networkProcess().networkSession(sessionID())))
     665        networkSession->handleAdClickAttributionConversion(WTFMove(*adClickConversion), request.url(), redirectRequest);
     666
    677667    send(Messages::WebResourceLoader::WillSendRequest(redirectRequest, sanitizeResponseIfPossible(WTFMove(redirectResponse), ResourceResponse::SanitizationType::Redirection)));
    678668}
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r244700 r244818  
    3838#include <WebCore/CookieJar.h>
    3939#include <WebCore/NetworkStorageSession.h>
     40#include <WebCore/ResourceRequest.h>
    4041
    4142#if PLATFORM(COCOA)
     
    7576    : m_sessionID(sessionID)
    7677    , m_networkProcess(networkProcess)
    77     , m_adClickAttribution(makeUniqueRef<AdClickAttributionManager>())
     78    , m_adClickAttribution(makeUniqueRef<AdClickAttributionManager>(sessionID))
    7879{
    7980    m_adClickAttribution->setPingLoadFunction([this, weakThis = makeWeakPtr(this)](NetworkResourceLoadParameters&& loadParameters, CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&)>&& completionHandler) {
     
    150151}
    151152
    152 void NetworkSession::convertAdClickAttribution(const WebCore::AdClickAttribution::Source& source, const WebCore::AdClickAttribution::Destination& destination, WebCore::AdClickAttribution::Conversion&& conversion)
    153 {
    154     m_adClickAttribution->convert(source, destination, WTFMove(conversion));
     153void NetworkSession::handleAdClickAttributionConversion(AdClickAttribution::Conversion&& conversion, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest)
     154{
     155    m_adClickAttribution->handleConversion(WTFMove(conversion), requestURL, redirectRequest);
    155156}
    156157
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.h

    r244700 r244818  
    4040namespace WebCore {
    4141class NetworkStorageSession;
     42class ResourceRequest;
    4243enum class IncludeHttpOnlyCookies : bool;
    4344enum class ShouldSample : bool;
     
    8283#endif
    8384    void storeAdClickAttribution(WebCore::AdClickAttribution&&);
    84     void convertAdClickAttribution(const WebCore::AdClickAttribution::Source&, const WebCore::AdClickAttribution::Destination&, WebCore::AdClickAttribution::Conversion&&);
     85    void handleAdClickAttributionConversion(WebCore::AdClickAttribution::Conversion&&, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest);
    8586    void dumpAdClickAttribution(CompletionHandler<void(String)>&&);
    8687    void clearAdClickAttribution();
  • trunk/Source/WebKit/Platform/Logging.h

    r243453 r244818  
    4141
    4242#define WEBKIT2_LOG_CHANNELS(M) \
     43    M(AdClickAttribution) \
    4344    M(Automation) \
    4445    M(ActivityState) \
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r244702 r244818  
    14131413    category: experimental
    14141414
     1415AdClickAttributionDebugModeEnabled:
     1416    type: bool
     1417    defaultValue: false
     1418    humanReadableName: "Ad Click Attribution Debug Mode"
     1419    humanReadableDescription: "Enable Ad Click Attribution Debug Mode"
     1420    webcoreBinding: RuntimeEnabledFeatures
     1421    category: experimental
     1422
    14151423# For internal features:
    14161424# The type should be boolean.
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r243427 r244818  
    305305    if ([isITPFirstPartyWebsiteDataRemovalEnabledStr isEqual:@"0"])
    306306        parameters.isITPFirstPartyWebsiteDataRemovalEnabled = false;
     307
     308    parameters.enableAdClickAttributionDebugMode = [defaults boolForKey:[NSString stringWithFormat:@"Experimental%@", WebPreferencesKey::adClickAttributionDebugModeEnabledKey().createCFString().get()]];
    307309}
    308310
Note: See TracChangeset for help on using the changeset viewer.