Diff
Modified: trunk/Source/WebKit/ChangeLog (253483 => 253484)
--- trunk/Source/WebKit/ChangeLog 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/ChangeLog 2019-12-13 18:13:21 UTC (rev 253484)
@@ -1,3 +1,76 @@
+2019-12-13 Kate Cheney <[email protected]>
+
+ Create WebKit API calls for ITP Data
+ https://bugs.webkit.org/show_bug.cgi?id=204932
+ <rdar://problem/57632753>
+
+ Reviewed by Alex Christensen.
+
+ This patch exposes ITP data captured in the network process through the
+ Objective C API using two new classes: _WKResourceLoadStatisticsFirstParty
+ and _WKResourceLoadStatisticsThirdParty.
+
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
+ * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
+ (WebKit::ensureThirdPartyDataForSpecificFirstPartyDomain):
+ (WebKit::getThirdPartyDataForSpecificFirstPartyDomains):
+ (WebKit::ResourceLoadStatisticsMemoryStore::aggregatedThirdPartyData const):
+ * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
+ * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
+ Updated mentions of ThirdPartyData to include the
+ WebResourceLoadStatisticsStore:: class specifier after relocating
+ ThirdPartyData.
+
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::aggregatedThirdPartyData):
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+ Updated the data to be sent via completion handler from
+ WebResourceLoadStatisticsStore so that calls to
+ aggregatedThirdPartyData() are happening on a background thread.
+
+ * Shared/API/APIObject.h:
+ * Shared/Cocoa/APIObject.mm:
+ (API::Object::newObject):
+ * UIProcess/API/APIResourceLoadStatisticsFirstParty.h: Added.
+ * UIProcess/API/APIResourceLoadStatisticsThirdParty.h: Added.
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (-[WKWebsiteDataStore _getResourceLoadStatisticsDataSummary:]):
+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+ * UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstParty.h: Added.
+ * UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstParty.mm: Added.
+ (-[_WKResourceLoadStatisticsFirstParty dealloc]):
+ (-[_WKResourceLoadStatisticsFirstParty firstPartyDomain]):
+ (-[_WKResourceLoadStatisticsFirstParty storageAccess]):
+ (-[_WKResourceLoadStatisticsFirstParty _apiObject]):
+ * UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstPartyInternal.h: Added.
+ * UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdParty.h: Added.
+ * UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdParty.mm: Added.
+ (-[_WKResourceLoadStatisticsThirdParty dealloc]):
+ (-[_WKResourceLoadStatisticsThirdParty thirdPartyDomain]):
+ (-[_WKResourceLoadStatisticsThirdParty underFirstParties]):
+ (-[_WKResourceLoadStatisticsThirdParty _apiObject]):
+ * UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdPartyInternal.h: Added.
+ _WKResourceLoadStatisticsFirstParty and _WKResourceLoadStatisticsThirdParty
+ represent first and third party domains respectively which hold ITP
+ data and are strongly typed to ensure the correct data is being
+ exposed via API. The function and parameter names for storage access
+ specify "third party" because each WKITPFirstParty holds data relevent
+ to a specific third party and storage access would not make sense in
+ just a first party context.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::getResourceLoadStatisticsDataSummary):
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/NetworkProcess.messages.in:
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::getResourceLoadStatisticsDataSummary):
+ * UIProcess/Network/NetworkProcessProxy.h:
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::getResourceLoadStatisticsDataSummary):
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+ * WebKit.xcodeproj/project.pbxproj:
+
2019-12-13 Eric Carlson <[email protected]>
Add infrastructure needed for playing media player in the GPU process
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (253483 => 253484)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2019-12-13 18:13:21 UTC (rev 253484)
@@ -786,7 +786,7 @@
return SQLiteStatement(database, makeString("SELECT mostRecentUserInteractionTime FROM ObservedDomains INNER JOIN (SELECT ", joinSubStatisticsForSorting(), ") as q ON ObservedDomains.domainID = q.domainID LIMIT 1 OFFSET ?"));
}
-Vector<ThirdPartyDataForSpecificFirstParty> ResourceLoadStatisticsDatabaseStore::getThirdPartyDataForSpecificFirstPartyDomains(unsigned thirdPartyDomainID, const RegistrableDomain& thirdPartyDomain) const
+Vector<WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty> ResourceLoadStatisticsDatabaseStore::getThirdPartyDataForSpecificFirstPartyDomains(unsigned thirdPartyDomainID, const RegistrableDomain& thirdPartyDomain) const
{
if (m_getAllSubStatisticsStatement.bindInt(1, thirdPartyDomainID) != SQLITE_OK
|| m_getAllSubStatisticsStatement.bindInt(2, thirdPartyDomainID) != SQLITE_OK
@@ -794,10 +794,10 @@
RELEASE_LOG_ERROR(Network, "ResourceLoadStatisticsDatabaseStore::getThirdPartyDataForSpecificFirstPartyDomain, error message: %{public}s", m_database.lastErrorMsg());
ASSERT_NOT_REACHED();
}
- Vector<ThirdPartyDataForSpecificFirstParty> thirdPartyDataForSpecificFirstPartyDomains;
+ Vector<WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty> thirdPartyDataForSpecificFirstPartyDomains;
while (m_getAllSubStatisticsStatement.step() == SQLITE_ROW) {
RegistrableDomain firstPartyDomain = RegistrableDomain::uncheckedCreateFromRegistrableDomainString(getDomainStringFromDomainID(m_getAllSubStatisticsStatement.getColumnInt(0)));
- thirdPartyDataForSpecificFirstPartyDomains.appendIfNotContains(ThirdPartyDataForSpecificFirstParty { firstPartyDomain, hasStorageAccess(firstPartyDomain, thirdPartyDomain) });
+ thirdPartyDataForSpecificFirstPartyDomains.appendIfNotContains(WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty { firstPartyDomain, hasStorageAccess(firstPartyDomain, thirdPartyDomain) });
}
resetStatement(m_getAllSubStatisticsStatement);
return thirdPartyDataForSpecificFirstPartyDomains;
@@ -808,11 +808,11 @@
return timesUnderFirstParty > 0;
}
-Vector<ThirdPartyData> ResourceLoadStatisticsDatabaseStore::aggregatedThirdPartyData() const
+Vector<WebResourceLoadStatisticsStore::ThirdPartyData> ResourceLoadStatisticsDatabaseStore::aggregatedThirdPartyData() const
{
ASSERT(!RunLoop::isMain());
- Vector<ThirdPartyData> thirdPartyDataList;
+ Vector<WebResourceLoadStatisticsStore::ThirdPartyData> thirdPartyDataList;
SQLiteStatement sortedStatistics(m_database, makeString("SELECT ", joinSubStatisticsForSorting()));
if (sortedStatistics.prepare() != SQLITE_OK
|| sortedStatistics.bindText(1, "%")
@@ -825,7 +825,7 @@
if (hasBeenThirdParty(sortedStatistics.getColumnInt(1))) {
auto thirdPartyDomainID = sortedStatistics.getColumnInt(0);
auto thirdPartyDomain = RegistrableDomain::uncheckedCreateFromRegistrableDomainString(getDomainStringFromDomainID(thirdPartyDomainID));
- thirdPartyDataList.append(ThirdPartyData { thirdPartyDomain, getThirdPartyDataForSpecificFirstPartyDomains(thirdPartyDomainID, thirdPartyDomain) });
+ thirdPartyDataList.append(WebResourceLoadStatisticsStore::ThirdPartyData { thirdPartyDomain, getThirdPartyDataForSpecificFirstPartyDomains(thirdPartyDomainID, thirdPartyDomain) });
}
}
return thirdPartyDataList;
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h (253483 => 253484)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -85,7 +85,7 @@
void clear(CompletionHandler<void()>&&) override;
bool isEmpty() const override;
- Vector<ThirdPartyData> aggregatedThirdPartyData() const override;
+ Vector<WebResourceLoadStatisticsStore::ThirdPartyData> aggregatedThirdPartyData() const override;
void updateCookieBlocking(CompletionHandler<void()>&&) override;
void classifyPrevalentResources() override;
@@ -139,7 +139,7 @@
void openITPDatabase();
bool isCorrectTableSchema();
bool hasStorageAccess(const TopFrameDomain&, const SubFrameDomain&) const;
- Vector<ThirdPartyDataForSpecificFirstParty> getThirdPartyDataForSpecificFirstPartyDomains(unsigned, const RegistrableDomain&) const;
+ Vector<WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty> getThirdPartyDataForSpecificFirstPartyDomains(unsigned, const RegistrableDomain&) const;
void openAndDropOldDatabaseIfNecessary();
String getDomainStringFromDomainID(unsigned) const;
String getSubStatisticStatement(const String&) const;
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp (253483 => 253484)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp 2019-12-13 18:13:21 UTC (rev 253484)
@@ -103,15 +103,15 @@
WebResourceLoadStatisticsTelemetry::calculateAndSubmit(*this);
}
-static void ensureThirdPartyDataForSpecificFirstPartyDomain(Vector<ThirdPartyDataForSpecificFirstParty>& thirdPartyDataForSpecificFirstPartyDomain, const RegistrableDomain& firstPartyDomain, bool thirdPartyHasStorageAccess)
+static void ensureThirdPartyDataForSpecificFirstPartyDomain(Vector<WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty>& thirdPartyDataForSpecificFirstPartyDomain, const RegistrableDomain& firstPartyDomain, bool thirdPartyHasStorageAccess)
{
- ThirdPartyDataForSpecificFirstParty thirdPartyDataForSpecificFirstParty { firstPartyDomain, thirdPartyHasStorageAccess };
+ WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty thirdPartyDataForSpecificFirstParty { firstPartyDomain, thirdPartyHasStorageAccess };
thirdPartyDataForSpecificFirstPartyDomain.appendIfNotContains(thirdPartyDataForSpecificFirstParty);
}
-static Vector<ThirdPartyDataForSpecificFirstParty> getThirdPartyDataForSpecificFirstPartyDomains(const ResourceLoadStatistics& thirdPartyStatistic)
+static Vector<WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty> getThirdPartyDataForSpecificFirstPartyDomains(const ResourceLoadStatistics& thirdPartyStatistic)
{
- Vector<ThirdPartyDataForSpecificFirstParty> thirdPartyDataForSpecificFirstPartyDomains;
+ Vector<WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty> thirdPartyDataForSpecificFirstPartyDomains;
for (auto firstPartyDomain : thirdPartyStatistic.subframeUnderTopFrameDomains)
ensureThirdPartyDataForSpecificFirstPartyDomain(thirdPartyDataForSpecificFirstPartyDomains, firstPartyDomain, thirdPartyStatistic.storageAccessUnderTopFrameDomains.contains(firstPartyDomain));
@@ -130,14 +130,14 @@
|| !statistic.subresourceUniqueRedirectsTo.isEmpty();
}
-Vector<ThirdPartyData> ResourceLoadStatisticsMemoryStore::aggregatedThirdPartyData() const
+Vector<WebResourceLoadStatisticsStore::ThirdPartyData> ResourceLoadStatisticsMemoryStore::aggregatedThirdPartyData() const
{
ASSERT(!RunLoop::isMain());
- Vector<ThirdPartyData> thirdPartyDataList;
+ Vector<WebResourceLoadStatisticsStore::ThirdPartyData> thirdPartyDataList;
for (auto& statistic : m_resourceStatisticsMap.values()) {
if (hasBeenThirdParty(statistic))
- thirdPartyDataList.append(ThirdPartyData { statistic.registrableDomain, getThirdPartyDataForSpecificFirstPartyDomains(statistic) });
+ thirdPartyDataList.append(WebResourceLoadStatisticsStore::ThirdPartyData { statistic.registrableDomain, getThirdPartyDataForSpecificFirstPartyDomains(statistic) });
}
std::sort(thirdPartyDataList.rbegin(), thirdPartyDataList.rend());
return thirdPartyDataList;
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h (253483 => 253484)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -56,7 +56,7 @@
void clear(CompletionHandler<void()>&&) override;
bool isEmpty() const override;
- Vector<ThirdPartyData> aggregatedThirdPartyData() const override;
+ Vector<WebResourceLoadStatisticsStore::ThirdPartyData> aggregatedThirdPartyData() const override;
const HashMap<RegistrableDomain, WebCore::ResourceLoadStatistics>& data() const { return m_resourceStatisticsMap; }
std::unique_ptr<WebCore::KeyedEncoder> createEncoderFromData() const;
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h (253483 => 253484)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -98,7 +98,7 @@
virtual void clear(CompletionHandler<void()>&&) = 0;
virtual bool isEmpty() const = 0;
- virtual Vector<ThirdPartyData> aggregatedThirdPartyData() const = 0;
+ virtual Vector<WebResourceLoadStatisticsStore::ThirdPartyData> aggregatedThirdPartyData() const = 0;
virtual void updateCookieBlocking(CompletionHandler<void()>&&) = 0;
void updateCookieBlockingForDomains(const RegistrableDomainsToBlockCookiesFor&, CompletionHandler<void()>&&);
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (253483 => 253484)
--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2019-12-13 18:13:21 UTC (rev 253484)
@@ -1152,9 +1152,22 @@
const_cast<WebResourceLoadStatisticsStore*>(this)->networkSession()->notifyPageStatisticsTelemetryFinished(numberOfPrevalentResources, numberOfPrevalentResourcesWithUserInteraction, numberOfPrevalentResourcesWithoutUserInteraction, topPrevalentResourceWithUserInteractionDaysSinceUserInteraction, medianDaysSinceUserInteractionPrevalentResourceWithUserInteraction, top3NumberOfPrevalentResourcesWithUI, top3MedianSubFrameWithoutUI, top3MedianSubResourceWithoutUI, top3MedianUniqueRedirectsWithoutUI, top3MedianDataRecordsRemovedWithoutUI);
}
-Vector<ThirdPartyData> WebResourceLoadStatisticsStore::aggregatedThirdPartyData()
+void WebResourceLoadStatisticsStore::aggregatedThirdPartyData(CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&& completionHandler)
{
- return m_statisticsStore->aggregatedThirdPartyData();
+ ASSERT(RunLoop::isMain());
+
+ postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
+ if (!m_statisticsStore) {
+ postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable {
+ completionHandler({ });
+ });
+ return;
+ }
+ auto thirdPartyData = m_statisticsStore->aggregatedThirdPartyData();
+ postTaskReply([thirdPartyData = WTFMove(thirdPartyData), completionHandler = WTFMove(completionHandler)]() mutable {
+ completionHandler(WTFMove(thirdPartyData));
+ });
+ });
}
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (253483 => 253484)
--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -27,6 +27,9 @@
#if ENABLE(RESOURCE_LOAD_STATISTICS)
+#include "ArgumentCoders.h"
+#include "Decoder.h"
+#include "Encoder.h"
#include "StorageAccessStatus.h"
#include "WebPageProxyIdentifier.h"
#include "WebsiteDataType.h"
@@ -78,6 +81,30 @@
RegistrableDomainsToBlockCookiesFor isolatedCopy() const { return { domainsToBlockAndDeleteCookiesFor.isolatedCopy(), domainsToBlockButKeepCookiesFor.isolatedCopy(), domainsWithUserInteractionAsFirstParty.isolatedCopy() }; }
};
+class WebResourceLoadStatisticsStore final : public ThreadSafeRefCounted<WebResourceLoadStatisticsStore, WTF::DestructionThread::Main> {
+public:
+ using ResourceLoadStatistics = WebCore::ResourceLoadStatistics;
+ using RegistrableDomain = WebCore::RegistrableDomain;
+ using TopFrameDomain = WebCore::RegistrableDomain;
+ using SubFrameDomain = WebCore::RegistrableDomain;
+ using SubResourceDomain = WebCore::RegistrableDomain;
+ using RedirectDomain = WebCore::RegistrableDomain;
+ using RedirectedFromDomain = WebCore::RegistrableDomain;
+ using RedirectedToDomain = WebCore::RegistrableDomain;
+ using NavigatedFromDomain = WebCore::RegistrableDomain;
+ using NavigatedToDomain = WebCore::RegistrableDomain;
+ using DomainInNeedOfStorageAccess = WebCore::RegistrableDomain;
+ using OpenerDomain = WebCore::RegistrableDomain;
+ using StorageAccessWasGranted = WebCore::StorageAccessWasGranted;
+ using StorageAccessPromptWasShown = WebCore::StorageAccessPromptWasShown;
+
+ static Ref<WebResourceLoadStatisticsStore> create(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory, ShouldIncludeLocalhost shouldIncludeLocalhost)
+ {
+ return adoptRef(*new WebResourceLoadStatisticsStore(networkSession, resourceLoadStatisticsDirectory, shouldIncludeLocalhost));
+ }
+
+ ~WebResourceLoadStatisticsStore();
+
struct ThirdPartyDataForSpecificFirstParty {
WebCore::RegistrableDomain firstPartyDomain;
bool storageAccessGranted;
@@ -87,6 +114,27 @@
return makeString("Has been granted storage access under ", firstPartyDomain.string(), ": ", storageAccessGranted ? '1' : '0');
}
+ void encode(IPC::Encoder& encoder) const
+ {
+ encoder << firstPartyDomain;
+ encoder << storageAccessGranted;
+ }
+
+ static Optional<ThirdPartyDataForSpecificFirstParty> decode(IPC::Decoder& decoder)
+ {
+ Optional<WebCore::RegistrableDomain> decodedDomain;
+ decoder >> decodedDomain;
+ if (!decodedDomain)
+ return WTF::nullopt;
+
+ Optional<bool> decodedStorageAccess;
+ decoder >> decodedStorageAccess;
+ if (!decodedStorageAccess)
+ return WTF::nullopt;
+
+ return {{ WTFMove(*decodedDomain), WTFMove(*decodedStorageAccess) }};
+ }
+
bool operator==(ThirdPartyDataForSpecificFirstParty const other) const
{
return firstPartyDomain == other.firstPartyDomain && storageAccessGranted == other.storageAccessGranted;
@@ -112,36 +160,33 @@
return stringBuilder.toString();
}
- bool operator<(const ThirdPartyData &other) const
+ void encode(IPC::Encoder& encoder) const
{
- return underFirstParties.size() < other.underFirstParties.size();
+ encoder << thirdPartyDomain;
+ encoder << underFirstParties;
}
-};
-class WebResourceLoadStatisticsStore final : public ThreadSafeRefCounted<WebResourceLoadStatisticsStore, WTF::DestructionThread::Main> {
-public:
- using ResourceLoadStatistics = WebCore::ResourceLoadStatistics;
- using RegistrableDomain = WebCore::RegistrableDomain;
- using TopFrameDomain = WebCore::RegistrableDomain;
- using SubFrameDomain = WebCore::RegistrableDomain;
- using SubResourceDomain = WebCore::RegistrableDomain;
- using RedirectDomain = WebCore::RegistrableDomain;
- using RedirectedFromDomain = WebCore::RegistrableDomain;
- using RedirectedToDomain = WebCore::RegistrableDomain;
- using NavigatedFromDomain = WebCore::RegistrableDomain;
- using NavigatedToDomain = WebCore::RegistrableDomain;
- using DomainInNeedOfStorageAccess = WebCore::RegistrableDomain;
- using OpenerDomain = WebCore::RegistrableDomain;
- using StorageAccessWasGranted = WebCore::StorageAccessWasGranted;
- using StorageAccessPromptWasShown = WebCore::StorageAccessPromptWasShown;
+ static Optional<ThirdPartyData> decode(IPC::Decoder& decoder)
+ {
+ Optional<WebCore::RegistrableDomain> decodedDomain;
+ decoder >> decodedDomain;
+ if (!decodedDomain)
+ return WTF::nullopt;
- static Ref<WebResourceLoadStatisticsStore> create(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory, ShouldIncludeLocalhost shouldIncludeLocalhost)
+ Optional<Vector<ThirdPartyDataForSpecificFirstParty>> decodedFirstParties;
+ decoder >> decodedFirstParties;
+ if (!decodedFirstParties)
+ return WTF::nullopt;
+
+ return {{ WTFMove(*decodedDomain), WTFMove(*decodedFirstParties) }};
+ }
+
+ bool operator<(const ThirdPartyData &other) const
{
- return adoptRef(*new WebResourceLoadStatisticsStore(networkSession, resourceLoadStatisticsDirectory, shouldIncludeLocalhost));
+ return underFirstParties.size() < other.underFirstParties.size();
}
+};
- ~WebResourceLoadStatisticsStore();
-
void didDestroyNetworkSession();
static const OptionSet<WebsiteDataType>& monitoredDataTypes();
@@ -235,7 +280,7 @@
void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&&);
void requestStorageAccessUnderOpener(DomainInNeedOfStorageAccess&&, WebCore::PageIdentifier openerID, OpenerDomain&&);
- Vector<ThirdPartyData> aggregatedThirdPartyData();
+ void aggregatedThirdPartyData(CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&&);
private:
explicit WebResourceLoadStatisticsStore(NetworkSession&, const String&, ShouldIncludeLocalhost);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (253483 => 253484)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2019-12-13 18:13:21 UTC (rev 253484)
@@ -752,6 +752,19 @@
}
}
+void NetworkProcess::getResourceLoadStatisticsDataSummary(PAL::SessionID sessionID, CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&& completionHandler)
+{
+ if (auto* networkSession = this->networkSession(sessionID)) {
+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
+ resourceLoadStatistics->aggregatedThirdPartyData(WTFMove(completionHandler));
+ else
+ completionHandler({ });
+ } else {
+ ASSERT_NOT_REACHED();
+ completionHandler({ });
+ }
+}
+
void NetworkProcess::resetParametersToDefaultValues(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
{
if (auto* networkSession = this->networkSession(sessionID)) {
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (253483 => 253484)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -231,6 +231,7 @@
void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, CompletionHandler<void()>&&);
void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&);
void scheduleClearInMemoryAndPersistent(PAL::SessionID, Optional<WallTime> modifiedSince, ShouldGrandfatherStatistics, CompletionHandler<void()>&&);
+ void getResourceLoadStatisticsDataSummary(PAL::SessionID, CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&&);
void scheduleCookieBlockingUpdate(PAL::SessionID, CompletionHandler<void()>&&);
void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, CompletionHandler<void()>&&);
void submitTelemetry(PAL::SessionID, CompletionHandler<void()>&&);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (253483 => 253484)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2019-12-13 18:13:21 UTC (rev 253484)
@@ -113,6 +113,7 @@
SetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, Seconds seconds) -> () Async
SetGrandfathered(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain, bool isGrandfathered) -> () Async
SetUseITPDatabase(PAL::SessionID sessionID, bool value) -> () Async
+ GetResourceLoadStatisticsDataSummary(PAL::SessionID sessionID) -> (Vector<WebKit::WebResourceLoadStatisticsStore::ThirdPartyData> thirdPartyData) Async
SetGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds) -> () Async
SetMaxStatisticsEntries(PAL::SessionID sessionID, uint64_t maximumEntryCount) -> () Async
SetMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID sessionID, Seconds seconds) -> () Async
Modified: trunk/Source/WebKit/Shared/API/APIObject.h (253483 => 253484)
--- trunk/Source/WebKit/Shared/API/APIObject.h 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/Shared/API/APIObject.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -153,6 +153,8 @@
Preferences,
RequestStorageAccessConfirmResultListener,
ResourceLoadStatisticsStore,
+ ResourceLoadStatisticsFirstParty,
+ ResourceLoadStatisticsThirdParty,
RunBeforeUnloadConfirmPanelResultListener,
RunJavaScriptAlertResultListener,
RunJavaScriptConfirmResultListener,
Modified: trunk/Source/WebKit/Shared/Cocoa/APIObject.mm (253483 => 253484)
--- trunk/Source/WebKit/Shared/Cocoa/APIObject.mm 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/Shared/Cocoa/APIObject.mm 2019-12-13 18:13:21 UTC (rev 253484)
@@ -80,6 +80,8 @@
#import "_WKInspectorInternal.h"
#import "_WKInternalDebugFeatureInternal.h"
#import "_WKProcessPoolConfigurationInternal.h"
+#import "_WKResourceLoadStatisticsFirstPartyInternal.h"
+#import "_WKResourceLoadStatisticsThirdPartyInternal.h"
#import "_WKUserContentWorldInternal.h"
#import "_WKUserInitiatedActionInternal.h"
#import "_WKUserStyleSheetInternal.h"
@@ -325,6 +327,14 @@
wrapper = [_WKCustomHeaderFields alloc];
break;
+ case Type::ResourceLoadStatisticsFirstParty:
+ wrapper = [_WKResourceLoadStatisticsFirstParty alloc];
+ break;
+
+ case Type::ResourceLoadStatisticsThirdParty:
+ wrapper = [_WKResourceLoadStatisticsThirdParty alloc];
+ break;
+
case Type::UserContentWorld:
wrapper = [_WKUserContentWorld alloc];
break;
Added: trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsFirstParty.h (0 => 253484)
--- trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsFirstParty.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsFirstParty.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#pragma once
+
+#include "APIObject.h"
+#include "WebResourceLoadStatisticsStore.h"
+#include <wtf/text/WTFString.h>
+
+namespace API {
+
+class ResourceLoadStatisticsFirstParty final : public ObjectImpl<Object::Type::ResourceLoadStatisticsFirstParty> {
+public:
+ static Ref<ResourceLoadStatisticsFirstParty> create(const WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty firstPartyData)
+ {
+ return adoptRef(*new ResourceLoadStatisticsFirstParty(firstPartyData));
+ }
+
+ ResourceLoadStatisticsFirstParty(const WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty firstPartyData)
+ : m_firstPartyData(firstPartyData)
+ {
+ }
+
+ const WTF::String& firstPartyDomain() const { return m_firstPartyData.firstPartyDomain.string(); }
+ bool storageAccess() const { return m_firstPartyData.storageAccessGranted; }
+
+private:
+ const WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty m_firstPartyData;
+
+};
+
+} // namespace API
Added: trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsThirdParty.h (0 => 253484)
--- trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsThirdParty.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsThirdParty.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#pragma once
+
+#include "APIObject.h"
+#include "WebResourceLoadStatisticsStore.h"
+#include <wtf/text/WTFString.h>
+
+namespace API {
+
+class ResourceLoadStatisticsThirdParty final : public ObjectImpl<Object::Type::ResourceLoadStatisticsThirdParty> {
+public:
+ static Ref<ResourceLoadStatisticsThirdParty> create(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData&& thirdPartyData)
+ {
+ return adoptRef(*new ResourceLoadStatisticsThirdParty(WTFMove(thirdPartyData)));
+ }
+
+ ResourceLoadStatisticsThirdParty(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData&& thirdPartyData)
+ : m_thirdPartyData(WTFMove(thirdPartyData))
+ {
+ }
+
+ const WTF::String& thirdPartyDomain() const { return m_thirdPartyData.thirdPartyDomain.string(); }
+ const Vector<WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty>& underFirstParties() const { return m_thirdPartyData.underFirstParties; }
+
+private:
+ const WebKit::WebResourceLoadStatisticsStore::ThirdPartyData m_thirdPartyData;
+};
+
+} // namespace API
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (253483 => 253484)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2019-12-13 18:13:21 UTC (rev 253484)
@@ -39,6 +39,7 @@
#import "WebResourceLoadStatisticsStore.h"
#import "WebResourceLoadStatisticsTelemetry.h"
#import "WebsiteDataFetchOption.h"
+#import "_WKResourceLoadStatisticsThirdPartyInternal.h"
#import "_WKWebsiteDataStoreConfigurationInternal.h"
#import "_WKWebsiteDataStoreDelegate.h"
#import <WebCore/Credential.h>
@@ -518,6 +519,21 @@
#endif
}
+- (void)_getResourceLoadStatisticsDataSummary:(void (^)(NSArray<_WKResourceLoadStatisticsThirdParty *> *))completionHandler
+{
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+ _websiteDataStore->getResourceLoadStatisticsDataSummary([completionHandler = makeBlockPtr(completionHandler)] (auto&& thirdPartyDomains) {
+ NSMutableArray<_WKResourceLoadStatisticsThirdParty *> *apiThirdParties = [[[NSMutableArray alloc] initWithCapacity:thirdPartyDomains.size()] autorelease];
+ for (auto& thirdParty : thirdPartyDomains)
+ [apiThirdParties addObject:wrapper(API::ResourceLoadStatisticsThirdParty::create(WTFMove(thirdParty)))];
+
+ completionHandler(apiThirdParties);
+ });
+#else
+ completionHandler(nil);
+#endif
+}
+
- (void)_isRegisteredAsSubresourceUnderFirstParty:(NSURL *)firstPartyURL thirdParty:(NSURL *)thirdPartyURL completionHandler:(void (^)(BOOL))completionHandler
{
#if ENABLE(RESOURCE_LOAD_STATISTICS)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (253483 => 253484)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -29,6 +29,7 @@
@class _WKWebsiteDataStoreConfiguration;
@class WKWebView;
+@class _WKResourceLoadStatisticsThirdParty;
@protocol _WKWebsiteDataStoreDelegate;
@@ -71,6 +72,7 @@
- (void)_logUserInteraction:(NSURL *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_setPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(10.15), ios(13.0));
- (void)_getIsPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(10.15), ios(13.0));
+- (void)_getResourceLoadStatisticsDataSummary:(void (^)(NSArray<_WKResourceLoadStatisticsThirdParty *> *))completionHandler WK_API_AVAILABLE(macos(10.15), ios(13.0));
- (void)_clearPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_clearResourceLoadStatistics:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_isRegisteredAsSubresourceUnderFirstParty:(NSURL *)firstPartyURL thirdParty:(NSURL *)thirdPartyURL completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
Added: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstParty.h (0 => 253484)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstParty.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstParty.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 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.
+ */
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface _WKResourceLoadStatisticsFirstParty : NSObject
+
+@property (nonatomic, readonly) NSString *firstPartyDomain;
+@property (nonatomic, readonly) BOOL thirdPartyStorageAccessGranted;
+
+@end
+
+NS_ASSUME_NONNULL_END
Added: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstParty.mm (0 => 253484)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstParty.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstParty.mm 2019-12-13 18:13:21 UTC (rev 253484)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 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 "_WKResourceLoadStatisticsFirstPartyInternal.h"
+
+@implementation _WKResourceLoadStatisticsFirstParty
+
+- (void)dealloc
+{
+ _firstParty->API::ResourceLoadStatisticsFirstParty::~ResourceLoadStatisticsFirstParty();
+ [super dealloc];
+}
+
+- (NSString *)firstPartyDomain
+{
+ return _firstParty->firstPartyDomain();
+}
+
+- (BOOL)storageAccess
+{
+ return _firstParty->storageAccess();
+}
+
+- (API::Object&)_apiObject
+{
+ return *_firstParty;
+}
+
+@end
+
Added: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstPartyInternal.h (0 => 253484)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstPartyInternal.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstPartyInternal.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#pragma once
+
+#import "APIResourceLoadStatisticsFirstParty.h"
+#import "WKObject.h"
+#import "_WKResourceLoadStatisticsFirstParty.h"
+
+namespace WebKit {
+
+template<> struct WrapperTraits<API::ResourceLoadStatisticsFirstParty> {
+ using WrapperClass = _WKResourceLoadStatisticsFirstParty;
+};
+
+}
+
+@interface _WKResourceLoadStatisticsFirstParty () <WKObject> {
+@package
+ API::ObjectStorage<API::ResourceLoadStatisticsFirstParty> _firstParty;
+}
+@end
Added: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdParty.h (0 => 253484)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdParty.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdParty.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 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 "_WKResourceLoadStatisticsFirstParty.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface _WKResourceLoadStatisticsThirdParty : NSObject
+
+@property (nonatomic, readonly) NSString *thirdPartyDomain;
+@property (nonatomic, readonly) NSArray<_WKResourceLoadStatisticsFirstParty *> *underFirstParties;
+
+@end
+
+NS_ASSUME_NONNULL_END
Added: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdParty.mm (0 => 253484)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdParty.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdParty.mm 2019-12-13 18:13:21 UTC (rev 253484)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 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 "_WKResourceLoadStatisticsThirdPartyInternal.h"
+
+#import "APIArray.h"
+#import "_WKResourceLoadStatisticsFirstParty.h"
+
+@implementation _WKResourceLoadStatisticsThirdParty
+
+- (void)dealloc
+{
+ _thirdParty->API::ResourceLoadStatisticsThirdParty::~ResourceLoadStatisticsThirdParty();
+ [super dealloc];
+}
+
+- (NSString *)thirdPartyDomain
+{
+ return _thirdParty->thirdPartyDomain();
+}
+
+- (NSArray<_WKResourceLoadStatisticsFirstParty *> *)underFirstParties
+{
+ auto apiFirstParties = _thirdParty->underFirstParties();
+ NSMutableArray<_WKResourceLoadStatisticsFirstParty *> *apiUnderFirstParties = [NSMutableArray arrayWithCapacity:apiFirstParties.size()];
+ for (const auto& thirdPartyDataUnderFirstParty : apiFirstParties)
+ [apiUnderFirstParties addObject:wrapper(API::ResourceLoadStatisticsFirstParty::create(thirdPartyDataUnderFirstParty))];
+
+ return apiUnderFirstParties;
+}
+
+- (API::Object&)_apiObject
+{
+ return *_thirdParty;
+}
+
+
+@end
+
Added: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdPartyInternal.h (0 => 253484)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdPartyInternal.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdPartyInternal.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#pragma once
+
+#import "APIResourceLoadStatisticsThirdParty.h"
+#import "WKObject.h"
+#import "_WKResourceLoadStatisticsFirstPartyInternal.h"
+#import "_WKResourceLoadStatisticsThirdParty.h"
+
+namespace WebKit {
+
+template<> struct WrapperTraits<API::ResourceLoadStatisticsThirdParty> {
+ using WrapperClass = _WKResourceLoadStatisticsThirdParty;
+};
+
+}
+
+@interface _WKResourceLoadStatisticsThirdParty () <WKObject> {
+@package
+ API::ObjectStorage<API::ResourceLoadStatisticsThirdParty> _thirdParty;
+}
+
+@end
+
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (253483 => 253484)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2019-12-13 18:13:21 UTC (rev 253484)
@@ -814,6 +814,16 @@
sendWithAsyncReply(Messages::NetworkProcess::GetAllStorageAccessEntries(sessionID), WTFMove(completionHandler));
}
+void NetworkProcessProxy::getResourceLoadStatisticsDataSummary(PAL::SessionID sessionID, CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&& completionHandler)
+{
+ if (!canSendMessage()) {
+ completionHandler({ });
+ return;
+ }
+
+ sendWithAsyncReply(Messages::NetworkProcess::GetResourceLoadStatisticsDataSummary(sessionID), WTFMove(completionHandler));
+}
+
void NetworkProcessProxy::setCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler)
{
if (!canSendMessage()) {
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (253483 => 253484)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -135,6 +135,7 @@
void setPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
void setPrevalentResourceForDebugMode(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
void setVeryPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
+ void getResourceLoadStatisticsDataSummary(PAL::SessionID, CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&&);
void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String> domains)>&&);
void requestStorageAccessConfirm(WebPageProxyIdentifier, WebCore::FrameIdentifier, const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&);
void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&);
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (253483 => 253484)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2019-12-13 18:13:21 UTC (rev 253484)
@@ -1510,6 +1510,16 @@
}
}
+void WebsiteDataStore::getResourceLoadStatisticsDataSummary(CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&& completionHandler)
+{
+ ASSERT(RunLoop::isMain());
+
+ for (auto& processPool : processPools()) {
+ if (auto* process = processPool->networkProcess())
+ process->getResourceLoadStatisticsDataSummary(m_sessionID, WTFMove(completionHandler));
+ }
+}
+
void WebsiteDataStore::scheduleClearInMemoryAndPersistent(ShouldGrandfatherStatistics shouldGrandfather, CompletionHandler<void()>&& completionHandler)
{
ASSERT(RunLoop::isMain());
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (253483 => 253484)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2019-12-13 18:13:21 UTC (rev 253484)
@@ -29,6 +29,7 @@
#include "NetworkSessionCreationParameters.h"
#include "WebDeviceOrientationAndMotionAccessController.h"
#include "WebPageProxyIdentifier.h"
+#include "WebResourceLoadStatisticsStore.h"
#include "WebsiteDataStoreClient.h"
#include "WebsiteDataStoreConfiguration.h"
#include <WebCore/Cookie.h>
@@ -160,6 +161,7 @@
void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&);
void scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfatherStatistics, CompletionHandler<void()>&&);
void scheduleClearInMemoryAndPersistent(ShouldGrandfatherStatistics, CompletionHandler<void()>&&);
+ void getResourceLoadStatisticsDataSummary(CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&&);
void scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&&);
void submitTelemetry();
void setGrandfathered(const URL&, bool, CompletionHandler<void()>&&);
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (253483 => 253484)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-12-13 18:13:21 UTC (rev 253484)
@@ -939,6 +939,14 @@
46C392292316EC4D008EED9B /* WebPageProxyIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C392282316EC4D008EED9B /* WebPageProxyIdentifier.h */; };
46DF063C1F3905F8001980BB /* NetworkCORSPreflightChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */; };
46F9B26323526EF3006FE5FA /* WebBackForwardCacheEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 46F9B26223526ED0006FE5FA /* WebBackForwardCacheEntry.h */; };
+ 49BCA19223A177660028A836 /* APIResourceLoadStatisticsFirstParty.h in Headers */ = {isa = PBXBuildFile; fileRef = 49BCA19123A177660028A836 /* APIResourceLoadStatisticsFirstParty.h */; };
+ 49BCA19523A18CFD0028A836 /* _WKResourceLoadStatisticsFirstPartyInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 49BCA19023A175490028A836 /* _WKResourceLoadStatisticsFirstPartyInternal.h */; };
+ 49BCA19723A1930D0028A836 /* APIResourceLoadStatisticsThirdParty.h in Headers */ = {isa = PBXBuildFile; fileRef = 49BCA19623A18F620028A836 /* APIResourceLoadStatisticsThirdParty.h */; };
+ 49FBEFFD239B011D00BD032F /* _WKResourceLoadStatisticsFirstParty.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49FBEFFC239B011D00BD032F /* _WKResourceLoadStatisticsFirstParty.mm */; };
+ 49FBEFFF239B012F00BD032F /* _WKResourceLoadStatisticsThirdParty.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49FBEFFE239B012F00BD032F /* _WKResourceLoadStatisticsThirdParty.mm */; };
+ 49FBF000239B1F7500BD032F /* _WKResourceLoadStatisticsThirdParty.h in Headers */ = {isa = PBXBuildFile; fileRef = 49FBEFFA239AD97800BD032F /* _WKResourceLoadStatisticsThirdParty.h */; };
+ 49FBF001239B1F8D00BD032F /* _WKResourceLoadStatisticsFirstParty.h in Headers */ = {isa = PBXBuildFile; fileRef = 49FBEFFB239ADB1800BD032F /* _WKResourceLoadStatisticsFirstParty.h */; };
+ 49FBF009239F08E000BD032F /* _WKResourceLoadStatisticsThirdPartyInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 49FBF008239F08E000BD032F /* _WKResourceLoadStatisticsThirdPartyInternal.h */; };
4A3CC18B19B0640F00D14AEF /* UserMediaPermissionRequestManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A410F3A19AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.h */; };
4A3CC18D19B0641900D14AEF /* UserMediaPermissionRequestProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A410F3C19AF7B04002EBAB5 /* UserMediaPermissionRequestProxy.h */; };
4A3CC18F19B07B8A00D14AEF /* WKUserMediaPermissionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A410F3619AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3366,6 +3374,14 @@
46DF06391F3905E5001980BB /* NetworkCORSPreflightChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCORSPreflightChecker.cpp; sourceTree = "<group>"; };
46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCORSPreflightChecker.h; sourceTree = "<group>"; };
46F9B26223526ED0006FE5FA /* WebBackForwardCacheEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardCacheEntry.h; sourceTree = "<group>"; };
+ 49BCA19023A175490028A836 /* _WKResourceLoadStatisticsFirstPartyInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKResourceLoadStatisticsFirstPartyInternal.h; sourceTree = "<group>"; };
+ 49BCA19123A177660028A836 /* APIResourceLoadStatisticsFirstParty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APIResourceLoadStatisticsFirstParty.h; sourceTree = "<group>"; };
+ 49BCA19623A18F620028A836 /* APIResourceLoadStatisticsThirdParty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APIResourceLoadStatisticsThirdParty.h; sourceTree = "<group>"; };
+ 49FBEFFA239AD97800BD032F /* _WKResourceLoadStatisticsThirdParty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKResourceLoadStatisticsThirdParty.h; sourceTree = "<group>"; };
+ 49FBEFFB239ADB1800BD032F /* _WKResourceLoadStatisticsFirstParty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKResourceLoadStatisticsFirstParty.h; sourceTree = "<group>"; };
+ 49FBEFFC239B011D00BD032F /* _WKResourceLoadStatisticsFirstParty.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKResourceLoadStatisticsFirstParty.mm; sourceTree = "<group>"; };
+ 49FBEFFE239B012F00BD032F /* _WKResourceLoadStatisticsThirdParty.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKResourceLoadStatisticsThirdParty.mm; sourceTree = "<group>"; };
+ 49FBF008239F08E000BD032F /* _WKResourceLoadStatisticsThirdPartyInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKResourceLoadStatisticsThirdPartyInternal.h; sourceTree = "<group>"; };
4A410F3519AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserMediaPermissionRequest.cpp; sourceTree = "<group>"; };
4A410F3619AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserMediaPermissionRequest.h; sourceTree = "<group>"; };
4A410F3919AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaPermissionRequestManagerProxy.cpp; sourceTree = "<group>"; };
@@ -6661,6 +6677,12 @@
A55BA80C1BA12BE1007CD33D /* _WKRemoteWebInspectorViewController.h */,
A55BA80D1BA12BE1007CD33D /* _WKRemoteWebInspectorViewController.mm */,
990E1E082384A88B004602DF /* _WKRemoteWebInspectorViewControllerPrivate.h */,
+ 49FBEFFB239ADB1800BD032F /* _WKResourceLoadStatisticsFirstParty.h */,
+ 49FBEFFC239B011D00BD032F /* _WKResourceLoadStatisticsFirstParty.mm */,
+ 49BCA19023A175490028A836 /* _WKResourceLoadStatisticsFirstPartyInternal.h */,
+ 49FBEFFA239AD97800BD032F /* _WKResourceLoadStatisticsThirdParty.h */,
+ 49FBEFFE239B012F00BD032F /* _WKResourceLoadStatisticsThirdParty.mm */,
+ 49FBF008239F08E000BD032F /* _WKResourceLoadStatisticsThirdPartyInternal.h */,
1A002D3F196B329400B9AD44 /* _WKSessionState.h */,
1A002D3E196B329400B9AD44 /* _WKSessionState.mm */,
1A002D42196B337000B9AD44 /* _WKSessionStateInternal.h */,
@@ -8329,6 +8351,8 @@
1AFDD3141891B54000153970 /* APIPolicyClient.h */,
7CE4D21D1A4914CA00C7F152 /* APIProcessPoolConfiguration.cpp */,
7CE4D21E1A4914CA00C7F152 /* APIProcessPoolConfiguration.h */,
+ 49BCA19123A177660028A836 /* APIResourceLoadStatisticsFirstParty.h */,
+ 49BCA19623A18F620028A836 /* APIResourceLoadStatisticsThirdParty.h */,
1AFDE65F1954E9B100C48FFA /* APISessionState.cpp */,
1AFDE6601954E9B100C48FFA /* APISessionState.h */,
1A4D664718A2D91A00D82E21 /* APIUIClient.h */,
@@ -9666,6 +9690,10 @@
990E1E092384AA57004602DF /* _WKRemoteWebInspectorViewControllerPrivate.h in Headers */,
377216B81A4E6BE000DCA718 /* _WKRenderingProgressEvents.h in Headers */,
1F604BAA1889FBB800EE0395 /* _WKRenderingProgressEventsInternal.h in Headers */,
+ 49FBF001239B1F8D00BD032F /* _WKResourceLoadStatisticsFirstParty.h in Headers */,
+ 49BCA19523A18CFD0028A836 /* _WKResourceLoadStatisticsFirstPartyInternal.h in Headers */,
+ 49FBF000239B1F7500BD032F /* _WKResourceLoadStatisticsThirdParty.h in Headers */,
+ 49FBF009239F08E000BD032F /* _WKResourceLoadStatisticsThirdPartyInternal.h in Headers */,
376311FD1A3FB5F7005A2E51 /* _WKSameDocumentNavigationType.h in Headers */,
376311FE1A3FB600005A2E51 /* _WKSameDocumentNavigationTypeInternal.h in Headers */,
1A002D44196B338900B9AD44 /* _WKSessionState.h in Headers */,
@@ -9760,6 +9788,8 @@
1AC1336C18565C7A00F3EC05 /* APIPageHandle.h in Headers */,
1AFDD3151891B54000153970 /* APIPolicyClient.h in Headers */,
7CE4D2201A4914CA00C7F152 /* APIProcessPoolConfiguration.h in Headers */,
+ 49BCA19223A177660028A836 /* APIResourceLoadStatisticsFirstParty.h in Headers */,
+ 49BCA19723A1930D0028A836 /* APIResourceLoadStatisticsThirdParty.h in Headers */,
F634445612A885C8000612D8 /* APISecurityOrigin.h in Headers */,
1AFDE6621954E9B100C48FFA /* APISessionState.h in Headers */,
1A4D664818A2D91A00D82E21 /* APIUIClient.h in Headers */,
@@ -11680,6 +11710,8 @@
buildActionMask = 2147483647;
files = (
5CBD595C2280EDF4002B22AA /* _WKCustomHeaderFields.mm in Sources */,
+ 49FBEFFD239B011D00BD032F /* _WKResourceLoadStatisticsFirstParty.mm in Sources */,
+ 49FBEFFF239B012F00BD032F /* _WKResourceLoadStatisticsThirdParty.mm in Sources */,
99E7189A21F79D9E0055E975 /* _WKTouchEventGenerator.mm in Sources */,
2D92A784212B6AB100F493FD /* ActivityAssertion.cpp in Sources */,
2D92A77B212B6A7100F493FD /* ArgumentCoders.cpp in Sources */,
Modified: trunk/Tools/ChangeLog (253483 => 253484)
--- trunk/Tools/ChangeLog 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Tools/ChangeLog 2019-12-13 18:13:21 UTC (rev 253484)
@@ -1,3 +1,21 @@
+2019-12-13 Kate Cheney <[email protected]>
+
+ Create WebKit API calls for ITP Data
+ https://bugs.webkit.org/show_bug.cgi?id=204932
+ <rdar://problem/57632753>
+
+ Reviewed by Alex Christensen.
+
+ Added a test to check that the ITP data summary was being properly
+ aggregated and sent to the UIProcess, and to make sure the API works
+ as expected. Added interface declarations to the file to allow for
+ use of the _WKResourceLoadStatisticsFirstParty and
+ _WKResourceLoadStatisticsThirdParty classes without having
+ to import the header files.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
+ (TEST):
+
2019-12-13 Devin Rousso <[email protected]>
Prefix CSS selectors with all applicable CSS groupings when generating a ChangeLog
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm (253483 => 253484)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm 2019-12-13 17:53:34 UTC (rev 253483)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm 2019-12-13 18:13:21 UTC (rev 253484)
@@ -40,6 +40,16 @@
static bool finishedNavigation = false;
+@interface _WKResourceLoadStatisticsFirstParty : NSObject
+@property (nonatomic, readonly) NSString *firstPartyDomain;
+@property (nonatomic, readonly) BOOL thirdPartyStorageAccessGranted;
+@end
+
+@interface _WKResourceLoadStatisticsThirdParty : NSObject
+@property (nonatomic, readonly) NSString *thirdPartyDomain;
+@property (nonatomic, readonly) NSArray<_WKResourceLoadStatisticsFirstParty *> *underFirstParties;
+@end
+
@interface DisableITPDuringNavigationDelegate : NSObject <WKNavigationDelegate>
@end
@@ -650,3 +660,196 @@
TestWebKitAPI::Util::run(&doneFlag);
}
+
+TEST(ResourceLoadStatistics, GetResourceLoadStatisticsDataSummary)
+{
+ auto *sharedProcessPool = [WKProcessPool _sharedProcessPool];
+ auto *dataStore = [WKWebsiteDataStore defaultDataStore];
+
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [configuration setProcessPool: sharedProcessPool];
+ configuration.get().websiteDataStore = dataStore;
+
+ auto webView1 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ auto webView3 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+ [webView1 loadHTMLString:@"WebKit Test" baseURL:[NSURL URLWithString:@"http://webkit.org"]];
+ [webView1 _test_waitForDidFinishNavigation];
+ [webView2 loadHTMLString:@"WebKit Test" baseURL:[NSURL URLWithString:@"http://webkit2.org"]];
+ [webView2 _test_waitForDidFinishNavigation];
+ [webView3 loadHTMLString:@"WebKit Test" baseURL:[NSURL URLWithString:@"http://webkit3.org"]];
+ [webView3 _test_waitForDidFinishNavigation];
+
+ [dataStore _setResourceLoadStatisticsEnabled:YES];
+
+ static bool doneFlag = false;
+ [dataStore _clearResourceLoadStatistics:^(void) {
+ doneFlag = true;
+ }];
+
+ static bool statisticsUpdated = false;
+ [dataStore _setResourceLoadStatisticsTestingCallback:^(WKWebsiteDataStore *, NSString *message) {
+ if (![message isEqualToString:@"Statistics Updated"])
+ return;
+ statisticsUpdated = true;
+ }];
+
+ TestWebKitAPI::Util::run(&doneFlag);
+
+ // Seed test data in the web process' observer.
+
+ // evil1
+ doneFlag = false;
+ [sharedProcessPool _seedResourceLoadStatisticsForTestingWithFirstParty:[NSURL URLWithString:@"http://webkit.org"] thirdParty:[NSURL URLWithString:@"http://evil1.com"] shouldScheduleNotification:NO completionHandler: ^() {
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+
+ doneFlag = false;
+ [sharedProcessPool _seedResourceLoadStatisticsForTestingWithFirstParty:[NSURL URLWithString:@"http://webkit2.org"] thirdParty:[NSURL URLWithString:@"http://evil1.com"] shouldScheduleNotification:NO completionHandler: ^() {
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+
+
+ // evil2
+ doneFlag = false;
+ [sharedProcessPool _seedResourceLoadStatisticsForTestingWithFirstParty:[NSURL URLWithString:@"http://webkit.org"] thirdParty:[NSURL URLWithString:@"http://evil2.com"] shouldScheduleNotification:NO completionHandler: ^() {
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+
+
+ // evil3
+ doneFlag = false;
+ [sharedProcessPool _seedResourceLoadStatisticsForTestingWithFirstParty:[NSURL URLWithString:@"http://webkit.org"] thirdParty:[NSURL URLWithString:@"http://evil3.com"] shouldScheduleNotification:NO completionHandler: ^() {
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+ doneFlag = false;
+ [sharedProcessPool _seedResourceLoadStatisticsForTestingWithFirstParty:[NSURL URLWithString:@"http://webkit2.org"] thirdParty:[NSURL URLWithString:@"http://evil3.com"] shouldScheduleNotification:NO completionHandler: ^() {
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+ doneFlag = false;
+ [sharedProcessPool _seedResourceLoadStatisticsForTestingWithFirstParty:[NSURL URLWithString:@"http://webkit3.org"] thirdParty:[NSURL URLWithString:@"http://evil3.com"] shouldScheduleNotification:NO completionHandler: ^() {
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+
+ statisticsUpdated = false;
+ [webView1 loadHTMLString:@"<body><script>close();</script></body>" baseURL:[NSURL URLWithString:@"http://webkit.org"]];
+ [webView2 loadHTMLString:@"<body><script>close();</script></body>" baseURL:[NSURL URLWithString:@"http://webkit2.org"]];
+ [webView3 loadHTMLString:@"<body><script>close();</script></body>" baseURL:[NSURL URLWithString:@"http://webkit3.org"]];
+
+ // Wait for the statistics to be updated in the network process.
+ TestWebKitAPI::Util::run(&statisticsUpdated);
+
+ // Check that the third-party evil1 is now registered as subresource.
+ doneFlag = false;
+ [dataStore _isRegisteredAsSubresourceUnderFirstParty:[NSURL URLWithString:@"http://webkit.org"] thirdParty:[NSURL URLWithString:@"http://evil1.com"] completionHandler: ^(BOOL isRegistered) {
+ EXPECT_TRUE(isRegistered);
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+ doneFlag = false;
+ [dataStore _isRegisteredAsSubresourceUnderFirstParty:[NSURL URLWithString:@"http://webkit2.org"] thirdParty:[NSURL URLWithString:@"http://evil1.com"] completionHandler: ^(BOOL isRegistered) {
+ EXPECT_TRUE(isRegistered);
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+
+
+ // Check that the third-party evil2 is now registered as subresource.
+ doneFlag = false;
+ [dataStore _isRegisteredAsSubresourceUnderFirstParty:[NSURL URLWithString:@"http://webkit.org"] thirdParty:[NSURL URLWithString:@"http://evil2.com"] completionHandler: ^(BOOL isRegistered) {
+ EXPECT_TRUE(isRegistered);
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+
+
+ // Check that the third-party evil3 is now registered as subresource.
+ doneFlag = false;
+ [dataStore _isRegisteredAsSubresourceUnderFirstParty:[NSURL URLWithString:@"http://webkit.org"] thirdParty:[NSURL URLWithString:@"http://evil3.com"] completionHandler: ^(BOOL isRegistered) {
+ EXPECT_TRUE(isRegistered);
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+ doneFlag = false;
+ [dataStore _isRegisteredAsSubresourceUnderFirstParty:[NSURL URLWithString:@"http://webkit2.org"] thirdParty:[NSURL URLWithString:@"http://evil3.com"] completionHandler: ^(BOOL isRegistered) {
+ EXPECT_TRUE(isRegistered);
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+ doneFlag = false;
+ [dataStore _isRegisteredAsSubresourceUnderFirstParty:[NSURL URLWithString:@"http://webkit3.org"] thirdParty:[NSURL URLWithString:@"http://evil3.com"] completionHandler: ^(BOOL isRegistered) {
+ EXPECT_TRUE(isRegistered);
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+
+
+ // Collect the ITP data summary which should include all third parties in the
+ // order: [evil3.com, evil1.com, evil2.com] sorted by number of first parties
+ // it appears under or redirects to
+ doneFlag = false;
+ [dataStore _getResourceLoadStatisticsDataSummary:^void(NSArray<_WKResourceLoadStatisticsThirdParty *> *thirdPartyData)
+ {
+ NSEnumerator *thirdPartyDomains = [thirdPartyData objectEnumerator];
+
+ // evil3
+ _WKResourceLoadStatisticsThirdParty *evil3ThirdParty = [thirdPartyDomains nextObject];
+ EXPECT_WK_STREQ(evil3ThirdParty.thirdPartyDomain, @"evil3.com");
+
+ NSEnumerator *evil3Enumerator = [evil3ThirdParty.underFirstParties objectEnumerator];
+ _WKResourceLoadStatisticsFirstParty *evil3FirstParty1 = [evil3Enumerator nextObject];
+ _WKResourceLoadStatisticsFirstParty *evil3FirstParty2 = [evil3Enumerator nextObject];
+ _WKResourceLoadStatisticsFirstParty *evil3FirstParty3 = [evil3Enumerator nextObject];
+
+ ASSERT_TRUE(evil3FirstParty1 != nil);
+ ASSERT_TRUE(evil3FirstParty2 != nil);
+ ASSERT_TRUE(evil3FirstParty3 != nil);
+
+ EXPECT_WK_STREQ(evil3FirstParty1.firstPartyDomain, @"webkit2.org");
+ EXPECT_WK_STREQ(evil3FirstParty2.firstPartyDomain, @"webkit3.org");
+ EXPECT_WK_STREQ(evil3FirstParty3.firstPartyDomain, @"webkit.org");
+
+ EXPECT_FALSE(evil3FirstParty1.thirdPartyStorageAccessGranted);
+ EXPECT_FALSE(evil3FirstParty2.thirdPartyStorageAccessGranted);
+ EXPECT_FALSE(evil3FirstParty3.thirdPartyStorageAccessGranted);
+
+ // evil1
+ _WKResourceLoadStatisticsThirdParty *evil1ThirdParty = [thirdPartyDomains nextObject];
+ EXPECT_WK_STREQ(evil1ThirdParty.thirdPartyDomain, @"evil1.com");
+
+ NSEnumerator *evil1Enumerator = [evil1ThirdParty.underFirstParties objectEnumerator];
+ _WKResourceLoadStatisticsFirstParty *evil1FirstParty1= [evil1Enumerator nextObject];
+ _WKResourceLoadStatisticsFirstParty *evil1FirstParty2 = [evil1Enumerator nextObject];
+
+ ASSERT_TRUE(evil1FirstParty1 != nil);
+ ASSERT_TRUE(evil1FirstParty2 != nil);
+
+ EXPECT_WK_STREQ(evil1FirstParty1.firstPartyDomain, @"webkit2.org");
+ EXPECT_WK_STREQ(evil1FirstParty2.firstPartyDomain, @"webkit.org");
+
+ EXPECT_FALSE(evil1FirstParty1.thirdPartyStorageAccessGranted);
+ EXPECT_FALSE(evil1FirstParty2.thirdPartyStorageAccessGranted);
+
+ // evil2
+ _WKResourceLoadStatisticsThirdParty *evil2ThirdParty = [thirdPartyDomains nextObject];
+ EXPECT_WK_STREQ(evil2ThirdParty.thirdPartyDomain, @"evil2.com");
+
+ NSEnumerator *evil2Enumerator = [evil2ThirdParty.underFirstParties objectEnumerator];
+ _WKResourceLoadStatisticsFirstParty *evil2FirstParty1 = [evil2Enumerator nextObject];
+
+ ASSERT_TRUE(evil2FirstParty1 != nil);
+
+ EXPECT_WK_STREQ(evil2FirstParty1.firstPartyDomain, @"webkit.org");
+ EXPECT_FALSE(evil2FirstParty1.thirdPartyStorageAccessGranted);
+ doneFlag = true;
+ }];
+
+ TestWebKitAPI::Util::run(&doneFlag);
+}