Send delayed Ad Click Attribution conversion requests to the click source
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2019 21:10:03 +0000 (21:10 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2019 21:10:03 +0000 (21:10 +0000)
commitbbd184c0abd6b9167f3f411aa26d4dc6dbd86346
treeffdcf007c011e8ec706d600786b127d8173592dd
parenta495ca3a4dc87e94f52e4acb81a6b3ebe4108cc0
Send delayed Ad Click Attribution conversion requests to the click source
https://bugs.webkit.org/show_bug.cgi?id=196838
<rdar://problem/47650157>

Reviewed by Chris Dumez and Youenn Fablet.

Source/WebCore:

WebCore::AdClickAttribution now:
- Sets m_earliestTimeToSend correctly based on WallTime::now().
- Allows for a test override of the base URL for conversions.
- Holds state for whether or not a conversion request has been sent.
- Outputs m_earliestTimeToSend and m_conversion->hasBeenSent in toString().
- Returns m_earliestTimeToSend as a result of a call to
convertAndGetEarliestTimeToSend() which used to be called setConversion().

Test: http/tests/adClickAttribution/send-attribution-conversion-request.html

* loader/AdClickAttribution.cpp:
(WebCore::AdClickAttribution::convertAndGetEarliestTimeToSend):
(WebCore::AdClickAttribution::url const):
(WebCore::AdClickAttribution::urlForTesting const):
(WebCore::AdClickAttribution::markConversionAsSent):
(WebCore::AdClickAttribution::wasConversionSent const):
(WebCore::AdClickAttribution::toString const):
(WebCore::AdClickAttribution::setConversion): Deleted.
    Renamed convertAndGetEarliestTimeToSend().
* loader/AdClickAttribution.h:
(WebCore::AdClickAttribution::Conversion::Conversion):
(WebCore::AdClickAttribution::Conversion::encode const):
(WebCore::AdClickAttribution::Conversion::decode):
* platform/Timer.h:
    Now exports nextFireInterval.

Source/WebKit:

This patch schedules a conversion request with appropriate data going to the
click source as a result of an ad click conversion.

WebKit::AdClickAttributionManager makes use of existing WebKit::PingLoad
infrastructure to make the request. This will probably be reworked into a
dedicated load class further on.

New test infrastructure allows for an override of both the conversion URL
and the 24-48 hour timer.

* NetworkProcess/AdClickAttributionManager.cpp: Added.
(WebKit::AdClickAttributionManager::ensureDestinationMapForSource):
(WebKit::AdClickAttributionManager::store):
(WebKit::AdClickAttributionManager::startTimer):
    Convenience function to support test override.
(WebKit::AdClickAttributionManager::convert):
    This function now sets the timer.
(WebKit::AdClickAttributionManager::fireConversionRequest):
    Fire an individual request.
(WebKit::AdClickAttributionManager::firePendingConversionRequests):
    This is the timer function that iterates over all pending attributions.
(WebKit::AdClickAttributionManager::clear):
    Now clears the two new test settings members.
(WebKit::AdClickAttributionManager::toString const):
* NetworkProcess/AdClickAttributionManager.h: Renamed from Source/WebKit/NetworkProcess/NetworkAdClickAttribution.h.
(WebKit::AdClickAttributionManager::AdClickAttributionManager):
(WebKit::AdClickAttributionManager::setPingLoadFunction):
(WebKit::AdClickAttributionManager::setOverrideTimerForTesting):
(WebKit::AdClickAttributionManager::setConversionURLForTesting):
* NetworkProcess/NetworkAdClickAttribution.cpp: Renamed from Source/WebKit/NetworkProcess/NetworkAdClickAttribution.cpp.
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::storeAdClickAttribution):
(WebKit::NetworkProcess::dumpAdClickAttribution):
(WebKit::NetworkProcess::clearAdClickAttribution):
(WebKit::NetworkProcess::setAdClickAttributionOverrideTimerForTesting):
(WebKit::NetworkProcess::setAdClickAttributionConversionURLForTesting):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::NetworkSession):
(WebKit::NetworkSession::setAdClickAttributionOverrideTimerForTesting):
(WebKit::NetworkSession::setAdClickAttributionConversionURLForTesting):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/PingLoad.cpp:
(WebKit::PingLoad::PingLoad):
(WebKit::m_blobFiles):
(WebKit::PingLoad::initialize):
    The PingLoad constructor is now split in two to allow for construction
    without a WebKit::NetworkConnectionToWebProcess object. The body of
    the constructor was moved into the new initialize() function which is
    shared between constructors.
* NetworkProcess/PingLoad.h:
* Sources.txt:
    Removed NetworkProcess/NetworkAdClickAttribution.cpp and added
    NetworkProcess/NetworkAdClickAttribution.cpp.
* UIProcess/API/C/WKPage.cpp:
(WKPageSetAdClickAttributionOverrideTimerForTesting):
(WKPageSetAdClickAttributionConversionURLForTesting):
* UIProcess/API/C/WKPagePrivate.h:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::dumpAdClickAttribution): Deleted.
(WebKit::NetworkProcessProxy::clearAdClickAttribution): Deleted.
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dumpAdClickAttribution):
(WebKit::WebPageProxy::clearAdClickAttribution):
(WebKit::WebPageProxy::setAdClickAttributionOverrideTimerForTesting):
(WebKit::WebPageProxy::setAdClickAttributionConversionURLForTesting):
* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::dumpAdClickAttribution): Deleted.
(WebKit::WebProcessPool::clearAdClickAttribution): Deleted.
* UIProcess/WebProcessPool.h:
* WebKit.xcodeproj/project.pbxproj:

Tools:

This patch adds test infrastructure to override the default behavior in
WebKit::NetworkAdClickAttribution.

* TestWebKitAPI/Tests/WebCore/AdClickAttribution.cpp:
(TestWebKitAPI::TEST):
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::dumpAdClickAttribution):
(WTR::TestRunner::clearAdClickAttribution):
(WTR::TestRunner::setAdClickAttributionOverrideTimerForTesting):
(WTR::TestRunner::setAdClickAttributionConversionURLForTesting):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setAdClickAttributionOverrideTimerForTesting):
(WTR::TestController::setAdClickAttributionConversionURLForTesting):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

* http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority-expected.txt:
* http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority-expected.txt:
* http/tests/adClickAttribution/resources/conversionFilePath.php: Added.
* http/tests/adClickAttribution/resources/conversionReport.php: Added.
* http/tests/adClickAttribution/resources/getConversionData.php: Added.
* http/tests/adClickAttribution/send-attribution-conversion-request-expected.txt: Added.
* http/tests/adClickAttribution/send-attribution-conversion-request.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244288 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority-expected.txt
LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority-expected.txt
LayoutTests/http/tests/adClickAttribution/resources/conversionFilePath.php [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/resources/conversionReport.php [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/resources/getConversionData.php [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/AdClickAttribution.cpp
Source/WebCore/loader/AdClickAttribution.h
Source/WebCore/platform/Timer.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/AdClickAttributionManager.cpp [new file with mode: 0644]
Source/WebKit/NetworkProcess/AdClickAttributionManager.h [moved from Source/WebKit/NetworkProcess/NetworkAdClickAttribution.h with 60% similarity]
Source/WebKit/NetworkProcess/NetworkAdClickAttribution.cpp [deleted file]
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/NetworkProcess/NetworkSession.cpp
Source/WebKit/NetworkProcess/NetworkSession.h
Source/WebKit/NetworkProcess/PingLoad.cpp
Source/WebKit/NetworkProcess/PingLoad.h
Source/WebKit/Sources.txt
Source/WebKit/UIProcess/API/C/WKPage.cpp
Source/WebKit/UIProcess/API/C/WKPagePrivate.h
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/AdClickAttribution.cpp
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp