Diff
Modified: trunk/Source/WebCore/ChangeLog (249919 => 249920)
--- trunk/Source/WebCore/ChangeLog 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebCore/ChangeLog 2019-09-16 21:21:29 UTC (rev 249920)
@@ -1,3 +1,18 @@
+2019-09-16 Chris Dumez <[email protected]>
+
+ Simplify WebResourceLoadObserver now that we have one WebProcess per session
+ https://bugs.webkit.org/show_bug.cgi?id=201821
+
+ Reviewed by Brent Fulgham.
+
+ * Modules/websockets/WebSocket.cpp:
+ (WebCore::WebSocket::connect):
+ * loader/ResourceLoadObserver.h:
+ (WebCore::ResourceLoadObserver::logWebSocketLoading):
+ (WebCore::ResourceLoadObserver::statisticsForURL):
+ * testing/Internals.cpp:
+ (WebCore::Internals::resourceLoadStatisticsForURL):
+
2019-09-16 ChangSeok Oh <[email protected]>
[GTK] Remove GraphicsContext3D dependency from the outside of WebGL
Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (249919 => 249920)
--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2019-09-16 21:21:29 UTC (rev 249920)
@@ -298,8 +298,8 @@
}
}
- RunLoop::main().dispatch([targetURL = m_url.isolatedCopy(), mainFrameURL = context.url().isolatedCopy(), sessionID = context.sessionID()]() {
- ResourceLoadObserver::shared().logWebSocketLoading(targetURL, mainFrameURL, sessionID);
+ RunLoop::main().dispatch([targetURL = m_url.isolatedCopy(), mainFrameURL = context.url().isolatedCopy()]() {
+ ResourceLoadObserver::shared().logWebSocketLoading(targetURL, mainFrameURL);
});
if (is<Document>(context)) {
Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (249919 => 249920)
--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp 2019-09-16 21:21:29 UTC (rev 249920)
@@ -47,4 +47,9 @@
return *sharedObserver();
}
+ResourceLoadObserver* ResourceLoadObserver::sharedIfExists()
+{
+ return sharedObserver();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (249919 => 249920)
--- trunk/Source/WebCore/loader/ResourceLoadObserver.h 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h 2019-09-16 21:21:29 UTC (rev 249920)
@@ -26,7 +26,6 @@
#pragma once
#include "ResourceLoadStatistics.h"
-#include <pal/SessionID.h>
#include <wtf/Forward.h>
namespace WebCore {
@@ -40,12 +39,13 @@
WTF_MAKE_FAST_ALLOCATED;
public:
WEBCORE_EXPORT static ResourceLoadObserver& shared();
+ WEBCORE_EXPORT static ResourceLoadObserver* sharedIfExists();
WEBCORE_EXPORT static void setShared(ResourceLoadObserver&);
virtual ~ResourceLoadObserver() { }
virtual void logSubresourceLoading(const Frame*, const ResourceRequest& /* newRequest */, const ResourceResponse& /* redirectResponse */) { }
- virtual void logWebSocketLoading(const URL& /* targetURL */, const URL& /* mainFrameURL */, PAL::SessionID) { }
+ virtual void logWebSocketLoading(const URL& /* targetURL */, const URL& /* mainFrameURL */) { }
virtual void logUserInteractionWithReducedTimeResolution(const Document&) { }
virtual void logFontLoad(const Document&, const String& /* familyName */, bool /* loadStatus */) { }
virtual void logCanvasRead(const Document&) { }
@@ -53,15 +53,11 @@
virtual void logNavigatorAPIAccessed(const Document&, const ResourceLoadStatistics::NavigatorAPI) { }
virtual void logScreenAPIAccessed(const Document&, const ResourceLoadStatistics::ScreenAPI) { }
- virtual String statisticsForURL(PAL::SessionID, const URL&) { return { }; }
+ virtual String statisticsForURL(const URL&) { return { }; }
virtual void updateCentralStatisticsStore() { }
virtual void clearState() { }
virtual bool hasStatistics() const { return false; }
-
-#if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
- virtual void setShouldLogUserInteraction(bool) { }
-#endif
};
} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.cpp (249919 => 249920)
--- trunk/Source/WebCore/testing/Internals.cpp 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebCore/testing/Internals.cpp 2019-09-16 21:21:29 UTC (rev 249920)
@@ -4467,11 +4467,7 @@
String Internals::resourceLoadStatisticsForURL(const DOMURL& url)
{
- auto* document = contextDocument();
- if (!document)
- return emptyString();
-
- return ResourceLoadObserver::shared().statisticsForURL(document->sessionID(), url.href());
+ return ResourceLoadObserver::shared().statisticsForURL(url.href());
}
void Internals::setResourceLoadStatisticsEnabled(bool enable)
Modified: trunk/Source/WebKit/ChangeLog (249919 => 249920)
--- trunk/Source/WebKit/ChangeLog 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebKit/ChangeLog 2019-09-16 21:21:29 UTC (rev 249920)
@@ -1,3 +1,41 @@
+2019-09-16 Chris Dumez <[email protected]>
+
+ Simplify WebResourceLoadObserver now that we have one WebProcess per session
+ https://bugs.webkit.org/show_bug.cgi?id=201821
+
+ Reviewed by Brent Fulgham.
+
+ Simplify WebResourceLoadObserver now that we have one WebProcess per session.
+ No need to pass sessionIDs around or store statistics per sessionID.
+ Also, only initialize the WebResourceLoadObserver if both ITP is enabled and
+ we're not in a WebContent process used for an ephemeral session.
+
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated):
+ * NetworkProcess/NetworkConnectionToWebProcess.h:
+ * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+ * WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp:
+ (WebKit::WebResourceLoadObserver::requestStorageAccessUnderOpener):
+ (WebKit::WebResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain):
+ (WebKit::WebResourceLoadObserver::scheduleNotificationIfNeeded):
+ (WebKit::WebResourceLoadObserver::statisticsForURL):
+ (WebKit::WebResourceLoadObserver::takeStatistics):
+ (WebKit::WebResourceLoadObserver::clearState):
+ (WebKit::WebResourceLoadObserver::logFontLoad):
+ (WebKit::WebResourceLoadObserver::logCanvasRead):
+ (WebKit::WebResourceLoadObserver::logCanvasWriteOrMeasure):
+ (WebKit::WebResourceLoadObserver::logNavigatorAPIAccessed):
+ (WebKit::WebResourceLoadObserver::logScreenAPIAccessed):
+ (WebKit::WebResourceLoadObserver::logSubresourceLoading):
+ (WebKit::WebResourceLoadObserver::logWebSocketLoading):
+ (WebKit::WebResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+ * WebProcess/WebCoreSupport/WebResourceLoadObserver.h:
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::setWebsiteDataStoreParameters):
+
2019-09-16 David Kilzer <[email protected]>
Fix build failure in MockNfcService.mm
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (249919 => 249920)
--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2019-09-16 21:21:29 UTC (rev 249920)
@@ -256,7 +256,7 @@
});
}
-void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&& origins)
+void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(Vector<ResourceLoadStatistics>&& statistics)
{
ASSERT(RunLoop::isMain());
@@ -263,13 +263,13 @@
// It is safe to move the origins to the background queue without isolated copy here because this is an r-value
// coming from IPC. ResourceLoadStatistics only contains strings which are safe to move to other threads as long
// as nobody on this thread holds a reference to those strings.
- postTask([this, origins = WTFMove(origins)]() mutable {
+ postTask([this, statistics = WTFMove(statistics)]() mutable {
if (!m_statisticsStore || !is<ResourceLoadStatisticsMemoryStore>(*m_statisticsStore))
return;
auto& memoryStore = downcast<ResourceLoadStatisticsMemoryStore>(*m_statisticsStore);
- memoryStore.mergeStatistics(WTFMove(origins));
+ memoryStore.mergeStatistics(WTFMove(statistics));
// We can cancel any pending request to process statistics since we're doing it synchronously below.
memoryStore.cancelPendingStatisticsProcessingRequest();
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (249919 => 249920)
--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h 2019-09-16 21:21:29 UTC (rev 249920)
@@ -186,7 +186,7 @@
void sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample) const;
void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) const;
- void resourceLoadStatisticsUpdated(Vector<ResourceLoadStatistics>&&);
+ void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&&);
void requestStorageAccessUnderOpener(DomainInNeedOfStorageAccess&&, WebCore::PageIdentifier openerID, OpenerDomain&&);
private:
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (249919 => 249920)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2019-09-16 21:21:29 UTC (rev 249920)
@@ -691,13 +691,11 @@
}
}
-void NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated(WebResourceLoadObserver::PerSessionResourceLoadData&& statistics)
+void NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated(Vector<ResourceLoadStatistics>&& statistics)
{
- for (auto& iter : statistics) {
- if (auto* networkSession = networkProcess().networkSession(iter.first)) {
- if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
- resourceLoadStatistics->resourceLoadStatisticsUpdated(WTFMove(iter.second));
- }
+ if (auto* networkSession = this->networkSession()) {
+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
+ resourceLoadStatistics->resourceLoadStatisticsUpdated(WTFMove(statistics));
}
}
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (249919 => 249920)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h 2019-09-16 21:21:29 UTC (rev 249920)
@@ -240,7 +240,7 @@
void clearPageSpecificDataForResourceLoadStatistics(WebCore::PageIdentifier);
void logUserInteraction(const RegistrableDomain&);
- void resourceLoadStatisticsUpdated(WebResourceLoadObserver::PerSessionResourceLoadData&&);
+ void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&&);
void hasStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, WebCore::FrameIdentifier, WebCore::PageIdentifier, CompletionHandler<void(bool)>&&);
void requestStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, WebCore::FrameIdentifier, WebCore::PageIdentifier, WebPageProxyIdentifier, CompletionHandler<void(WebCore::StorageAccessWasGranted, WebCore::StorageAccessPromptWasShown)>&&);
void requestStorageAccessUnderOpener(WebCore::RegistrableDomain&& domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::RegistrableDomain&& openerDomain);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (249919 => 249920)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2019-09-16 21:21:29 UTC (rev 249920)
@@ -59,10 +59,7 @@
RemoveStorageAccessForFrame(WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID);
ClearPageSpecificDataForResourceLoadStatistics(WebCore::PageIdentifier pageID);
LogUserInteraction(WebCore::RegistrableDomain domain)
-
- # FIXME: Stop passing sessionIDs.
- ResourceLoadStatisticsUpdated(Vector<std::pair<PAL::SessionID, Vector<WebCore::ResourceLoadStatistics>>> statistics)
-
+ ResourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics> statistics)
HasStorageAccess(WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID) -> (bool hasStorageAccess) Async
RequestStorageAccess(WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier webPageID, WebKit::WebPageProxyIdentifier webPageProxyID) -> (enum:bool WebCore::StorageAccessWasGranted wasGranted, enum:bool WebCore::StorageAccessPromptWasShown promptWasShown) Async
RequestStorageAccessUnderOpener(WebCore::RegistrableDomain domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::RegistrableDomain openerDomain)
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp (249919 => 249920)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp 2019-09-16 21:21:29 UTC (rev 249920)
@@ -44,14 +44,18 @@
static const Seconds minimumNotificationInterval { 5_s };
-static bool is3xxRedirect(const ResourceResponse& response)
+#if !RELEASE_LOG_DISABLED
+bool WebResourceLoadObserver::shouldLogUserInteraction { false };
+
+void WebResourceLoadObserver::setShouldLogUserInteraction(bool value)
{
- return response.httpStatusCode() >= 300 && response.httpStatusCode() <= 399;
+ shouldLogUserInteraction = value;
}
+#endif
-static bool shouldLogResourceLoadStatistics(PAL::SessionID sessionID)
+static bool is3xxRedirect(const ResourceResponse& response)
{
- return DeprecatedGlobalSettings::resourceLoadStatisticsEnabled() && !sessionID.isEphemeral();
+ return response.httpStatusCode() >= 300 && response.httpStatusCode() <= 399;
}
WebResourceLoadObserver::WebResourceLoadObserver()
@@ -59,7 +63,7 @@
{
}
-void WebResourceLoadObserver::requestStorageAccessUnderOpener(PAL::SessionID, const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, Document& openerDocument)
+void WebResourceLoadObserver::requestStorageAccessUnderOpener(const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, Document& openerDocument)
{
auto openerUrl = openerDocument.url();
RegistrableDomain openerDomain { openerUrl };
@@ -73,21 +77,16 @@
}
}
-ResourceLoadStatistics& WebResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain(PAL::SessionID sessionID, const RegistrableDomain& domain)
+ResourceLoadStatistics& WebResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain(const RegistrableDomain& domain)
{
- auto addResult = m_perSessionResourceStatisticsMap.ensure(sessionID, [] {
- return makeUnique<HashMap<RegistrableDomain, ResourceLoadStatistics>>();
- });
-
- auto addDomainResult = addResult.iterator->value->ensure(domain, [&domain] {
+ return m_resourceStatisticsMap.ensure(domain, [&domain] {
return ResourceLoadStatistics(domain);
- });
- return addDomainResult.iterator->value;
+ }).iterator->value;
}
void WebResourceLoadObserver::scheduleNotificationIfNeeded()
{
- if (m_perSessionResourceStatisticsMap.isEmpty()) {
+ if (m_resourceStatisticsMap.isEmpty()) {
m_notificationTimer.stop();
return;
}
@@ -102,41 +101,29 @@
WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::ResourceLoadStatisticsUpdated(takeStatistics()), 0);
}
-String WebResourceLoadObserver::statisticsForURL(PAL::SessionID sessionID, const URL& url)
+String WebResourceLoadObserver::statisticsForURL(const URL& url)
{
- auto* resourceStatisticsByDomain = m_perSessionResourceStatisticsMap.get(sessionID);
- if (!resourceStatisticsByDomain)
+ auto iter = m_resourceStatisticsMap.find(RegistrableDomain { url });
+ if (iter == m_resourceStatisticsMap.end())
return emptyString();
- auto iter = resourceStatisticsByDomain->find(RegistrableDomain { url });
- if (iter == resourceStatisticsByDomain->end())
- return emptyString();
-
return makeString("Statistics for ", url.host().toString(), ":\n", iter->value.toString());
}
-auto WebResourceLoadObserver::takeStatistics() -> PerSessionResourceLoadData
+Vector<ResourceLoadStatistics> WebResourceLoadObserver::takeStatistics()
{
- PerSessionResourceLoadData perSessionStatistics;
-
- for (auto& iter : m_perSessionResourceStatisticsMap) {
- Vector<ResourceLoadStatistics> statistics;
- statistics.reserveInitialCapacity(iter.value->size());
-
- for (auto& statistic : iter.value->values())
- statistics.uncheckedAppend(WTFMove(statistic));
-
- perSessionStatistics.append(std::make_pair(iter.key, WTFMove(statistics)));
- }
-
- m_perSessionResourceStatisticsMap.clear();
- return perSessionStatistics;
+ Vector<ResourceLoadStatistics> statistics;
+ statistics.reserveInitialCapacity(m_resourceStatisticsMap.size());
+ for (auto& statistic : m_resourceStatisticsMap.values())
+ statistics.uncheckedAppend(WTFMove(statistic));
+ m_resourceStatisticsMap.clear();
+ return statistics;
}
void WebResourceLoadObserver::clearState()
{
m_notificationTimer.stop();
- m_perSessionResourceStatisticsMap.clear();
+ m_resourceStatisticsMap.clear();
m_lastReportedUserInteractionMap.clear();
}
@@ -143,11 +130,8 @@
void WebResourceLoadObserver::logFontLoad(const Document& document, const String& familyName, bool loadStatus)
{
#if ENABLE(WEB_API_STATISTICS)
- if (!shouldLogResourceLoadStatistics(document.sessionID()))
- return;
-
RegistrableDomain registrableDomain { document.url() };
- auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
+ auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain);
bool shouldCallNotificationCallback = false;
if (!loadStatus) {
if (statistics.fontsFailedToLoad.add(familyName).isNewEntry)
@@ -171,11 +155,8 @@
void WebResourceLoadObserver::logCanvasRead(const Document& document)
{
#if ENABLE(WEB_API_STATISTICS)
- if (!shouldLogResourceLoadStatistics(document.sessionID()))
- return;
-
RegistrableDomain registrableDomain { document.url() };
- auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID(), registrableDomain);
+ auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain);
RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
statistics.canvasActivityRecord.wasDataRead = true;
if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
@@ -188,11 +169,8 @@
void WebResourceLoadObserver::logCanvasWriteOrMeasure(const Document& document, const String& textWritten)
{
#if ENABLE(WEB_API_STATISTICS)
- if (!shouldLogResourceLoadStatistics(document.sessionID()))
- return;
-
RegistrableDomain registrableDomain { document.url() };
- auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
+ auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain);
bool shouldCallNotificationCallback = false;
RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
if (statistics.canvasActivityRecord.recordWrittenOrMeasuredText(textWritten))
@@ -210,11 +188,8 @@
void WebResourceLoadObserver::logNavigatorAPIAccessed(const Document& document, const ResourceLoadStatistics::NavigatorAPI functionName)
{
#if ENABLE(WEB_API_STATISTICS)
- if (!shouldLogResourceLoadStatistics(document.sessionID()))
- return;
-
RegistrableDomain registrableDomain { document.url() };
- auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
+ auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain);
bool shouldCallNotificationCallback = false;
if (!statistics.navigatorFunctionsAccessed.contains(functionName)) {
statistics.navigatorFunctionsAccessed.add(functionName);
@@ -234,11 +209,8 @@
void WebResourceLoadObserver::logScreenAPIAccessed(const Document& document, const ResourceLoadStatistics::ScreenAPI functionName)
{
#if ENABLE(WEB_API_STATISTICS)
- if (!shouldLogResourceLoadStatistics(document.sessionID()))
- return;
-
RegistrableDomain registrableDomain { document.url() };
- auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
+ auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain);
bool shouldCallNotificationCallback = false;
if (!statistics.screenFunctionsAccessed.contains(functionName)) {
statistics.screenFunctionsAccessed.add(functionName);
@@ -263,7 +235,7 @@
return;
auto* page = frame->page();
- if (!page || !shouldLogResourceLoadStatistics(page->sessionID()))
+ if (!page)
return;
bool isRedirect = is3xxRedirect(redirectResponse);
@@ -285,7 +257,7 @@
return;
{
- auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), targetDomain);
+ auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain);
auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
targetStatistics.lastSeen = lastSeen;
targetStatistics.subresourceUnderTopFrameDomains.add(topFrameDomain);
@@ -294,9 +266,9 @@
}
if (isRedirect) {
- auto& redirectingOriginStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), redirectedFromDomain);
+ auto& redirectingOriginStatistics = ensureResourceStatisticsForRegistrableDomain(redirectedFromDomain);
redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetDomain);
- auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), targetDomain);
+ auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain);
targetStatistics.subresourceUniqueRedirectsFrom.add(redirectedFromDomain);
scheduleNotificationIfNeeded();
@@ -303,11 +275,8 @@
}
}
-void WebResourceLoadObserver::logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL, PAL::SessionID sessionID)
+void WebResourceLoadObserver::logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL)
{
- if (!shouldLogResourceLoadStatistics(sessionID))
- return;
-
auto targetHost = targetURL.host();
auto mainFrameHost = mainFrameURL.host();
@@ -322,7 +291,7 @@
auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
- auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(sessionID, targetDomain);
+ auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain);
targetStatistics.lastSeen = lastSeen;
targetStatistics.subresourceUnderTopFrameDomains.add(topFrameDomain);
@@ -331,9 +300,6 @@
void WebResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Document& document)
{
- if (!document.sessionID().isValid() || !shouldLogResourceLoadStatistics(document.sessionID()))
- return;
-
auto& url = ""
if (url.protocolIsAbout() || url.isLocalFile() || url.isEmpty())
return;
@@ -346,7 +312,7 @@
m_lastReportedUserInteractionMap.set(topFrameDomain, newTime);
- auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID(), topFrameDomain);
+ auto& statistics = ensureResourceStatisticsForRegistrableDomain(topFrameDomain);
statistics.hadUserInteraction = true;
statistics.lastSeen = newTime;
statistics.mostRecentUserInteractionTime = newTime;
@@ -356,7 +322,7 @@
if (auto* openerDocument = opener->document()) {
if (auto* openerFrame = openerDocument->frame()) {
if (auto openerPageID = openerFrame->loader().client().pageID())
- requestStorageAccessUnderOpener(document.sessionID(), topFrameDomain, openerPageID.value(), *openerDocument);
+ requestStorageAccessUnderOpener(topFrameDomain, openerPageID.value(), *openerDocument);
}
}
}
@@ -367,7 +333,7 @@
WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::LogUserInteraction(topFrameDomain), 0);
#if !RELEASE_LOG_DISABLED
- if (m_shouldLogUserInteraction) {
+ if (shouldLogUserInteraction) {
auto counter = ++m_loggingCounter;
#define LOCAL_LOG(str, ...) \
RELEASE_LOG(ResourceLoadStatistics, "ResourceLoadObserver::logUserInteraction: counter = %" PRIu64 ": " str, counter, ##__VA_ARGS__)
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.h (249919 => 249920)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.h 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.h 2019-09-16 21:21:29 UTC (rev 249920)
@@ -36,12 +36,10 @@
class WebResourceLoadObserver final : public WebCore::ResourceLoadObserver {
public:
- using PerSessionResourceLoadData = Vector<std::pair<PAL::SessionID, Vector<WebCore::ResourceLoadStatistics>>>;
-
WebResourceLoadObserver();
void logSubresourceLoading(const WebCore::Frame*, const WebCore::ResourceRequest& newRequest, const WebCore::ResourceResponse& redirectResponse) final;
- void logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL, PAL::SessionID) final;
+ void logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL) final;
void logUserInteractionWithReducedTimeResolution(const WebCore::Document&) final;
void logFontLoad(const WebCore::Document&, const String& familyName, bool loadStatus) final;
void logCanvasRead(const WebCore::Document&) final;
@@ -50,23 +48,23 @@
void logScreenAPIAccessed(const WebCore::Document&, const WebCore::ResourceLoadStatistics::ScreenAPI) final;
#if !RELEASE_LOG_DISABLED
- void setShouldLogUserInteraction(bool shouldLogUserInteraction) final { m_shouldLogUserInteraction = shouldLogUserInteraction; }
+ static void setShouldLogUserInteraction(bool);
#endif
- String statisticsForURL(PAL::SessionID, const URL&) final;
+ String statisticsForURL(const URL&) final;
void updateCentralStatisticsStore() final;
void clearState() final;
- bool hasStatistics() const final { return !m_perSessionResourceStatisticsMap.isEmpty(); }
+ bool hasStatistics() const final { return !m_resourceStatisticsMap.isEmpty(); }
private:
- WebCore::ResourceLoadStatistics& ensureResourceStatisticsForRegistrableDomain(PAL::SessionID, const WebCore::RegistrableDomain&);
+ WebCore::ResourceLoadStatistics& ensureResourceStatisticsForRegistrableDomain(const WebCore::RegistrableDomain&);
void scheduleNotificationIfNeeded();
- PerSessionResourceLoadData takeStatistics();
- void requestStorageAccessUnderOpener(PAL::SessionID, const WebCore::RegistrableDomain& domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::Document& openerDocument);
+ Vector<WebCore::ResourceLoadStatistics> takeStatistics();
+ void requestStorageAccessUnderOpener(const WebCore::RegistrableDomain& domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::Document& openerDocument);
- HashMap<PAL::SessionID, std::unique_ptr<HashMap<WebCore::RegistrableDomain, WebCore::ResourceLoadStatistics>>> m_perSessionResourceStatisticsMap;
+ HashMap<WebCore::RegistrableDomain, WebCore::ResourceLoadStatistics> m_resourceStatisticsMap;
HashMap<WebCore::RegistrableDomain, WTF::WallTime> m_lastReportedUserInteractionMap;
WebCore::Timer m_notificationTimer;
@@ -73,7 +71,7 @@
#if !RELEASE_LOG_DISABLED
uint64_t m_loggingCounter { 0 };
- bool m_shouldLogUserInteraction { false };
+ static bool shouldLogUserInteraction;
#endif
};
Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (249919 => 249920)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2019-09-16 21:10:09 UTC (rev 249919)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2019-09-16 21:21:29 UTC (rev 249920)
@@ -215,10 +215,6 @@
#endif
m_plugInAutoStartOriginHashes.add(PAL::SessionID::defaultSessionID(), HashMap<unsigned, WallTime>());
-
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
- ResourceLoadObserver::setShared(*new WebResourceLoadObserver);
-#endif
Gigacage::forbidDisablingPrimitiveGigacage();
}
@@ -429,7 +425,7 @@
#endif
#if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
- ResourceLoadObserver::shared().setShouldLogUserInteraction(parameters.shouldLogUserInteraction);
+ WebResourceLoadObserver::setShouldLogUserInteraction(parameters.shouldLogUserInteraction);
#endif
RELEASE_LOG(Process, "%p - WebProcess::initializeWebProcess: Presenting process = %d", this, WebCore::presentingApplicationPID());
@@ -456,6 +452,11 @@
setResourceLoadStatisticsEnabled(parameters.resourceLoadStatisticsEnabled);
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+ if (parameters.resourceLoadStatisticsEnabled && !parameters.sessionID.isEphemeral())
+ ResourceLoadObserver::setShared(*new WebResourceLoadObserver);
+#endif
+
for (auto& supplement : m_supplements.values())
supplement->setWebsiteDataStore(parameters);
@@ -1659,7 +1660,8 @@
void WebProcess::clearResourceLoadStatistics()
{
#if ENABLE(RESOURCE_LOAD_STATISTICS)
- ResourceLoadObserver::shared().clearState();
+ if (auto* observer = ResourceLoadObserver::sharedIfExists())
+ observer->clearState();
#endif
}