Diff
Modified: trunk/Source/WebKit2/ChangeLog (219202 => 219203)
--- trunk/Source/WebKit2/ChangeLog 2017-07-06 17:12:54 UTC (rev 219202)
+++ trunk/Source/WebKit2/ChangeLog 2017-07-06 17:23:07 UTC (rev 219203)
@@ -1,3 +1,40 @@
+2017-07-06 Chris Dumez <cdu...@apple.com>
+
+ WebResourceLoadStatisticsStore should only be constructed when the feature is enabled
+ https://bugs.webkit.org/show_bug.cgi?id=174189
+
+ Reviewed by Brent Fulgham.
+
+ Delay the construction of the WebResourceLoadStatisticsStore until the feature gets
+ enabled via WebsiteDataStore::setResourceLoadStatisticsEnabled(). Previously, we would
+ always construct a store and then have a boolean on the store to indicate if it is
+ enabled or not.
+
+ Also simplify the initialization process of the WebResourceLoadStatisticsStore, we
+ used to have:
+ 1. WebResourceLoadStatisticsStore constructor
+ 2. WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver()
+ 3. WebResourceLoadStatisticsStore::setResourceLoadStatisticsEnabled(true)
+
+ All 3 steps are now taken care of by the WebResourceLoadStatisticsStore constructor.
+
+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+ (WebKit::WebProcessPool::platformInitialize):
+ * UIProcess/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
+ (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
+ * UIProcess/WebResourceLoadStatisticsStore.h:
+ * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+ (WebKit::WebsiteDataStore::platformInitialize):
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::WebsiteDataStore):
+ (WebKit::WebsiteDataStore::resourceLoadStatisticsEnabled):
+ (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+ (WebKit::WebsiteDataStore::resourceLoadStatistics):
+ * UIProcess/wpe/WebProcessPoolWPE.cpp:
+ (WebKit::WebProcessPool::platformInitialize):
+
2017-07-06 Claudio Saavedra <csaave...@igalia.com>
[GTK] It should process MouseMoved events when the parent window is not active
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm (219202 => 219203)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2017-07-06 17:12:54 UTC (rev 219202)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2017-07-06 17:23:07 UTC (rev 219203)
@@ -148,8 +148,6 @@
#endif
setLegacyCustomProtocolManagerClient(std::make_unique<LegacyCustomProtocolManagerClient>());
-
- m_websiteDataStore->websiteDataStore().registerSharedResourceLoadObserver();
}
#if PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp (219202 => 219203)
--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp 2017-07-06 17:12:54 UTC (rev 219202)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp 2017-07-06 17:23:07 UTC (rev 219203)
@@ -87,12 +87,7 @@
return dataTypes;
}
-Ref<WebResourceLoadStatisticsStore> WebResourceLoadStatisticsStore::create(const String& resourceLoadStatisticsDirectory)
-{
- return adoptRef(*new WebResourceLoadStatisticsStore(resourceLoadStatisticsDirectory));
-}
-
-WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(const String& resourceLoadStatisticsDirectory)
+WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(const String& resourceLoadStatisticsDirectory, UpdatePartitionCookiesForDomainsHandler&& updatePartitionCookiesForDomainsHandler)
: m_resourceLoadStatisticsStore(ResourceLoadStatisticsStore::create())
, m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::Type::Serial, WorkQueue::QOS::Utility))
, m_statisticsStoragePath(resourceLoadStatisticsDirectory)
@@ -99,6 +94,47 @@
, m_telemetryOneShotTimer(RunLoop::main(), this, &WebResourceLoadStatisticsStore::telemetryTimerFired)
, m_telemetryRepeatedTimer(RunLoop::main(), this, &WebResourceLoadStatisticsStore::telemetryTimerFired)
{
+ ASSERT(RunLoop::isMain());
+
+#if PLATFORM(COCOA)
+ registerUserDefaultsIfNeeded();
+#endif
+
+ m_resourceLoadStatisticsStore->setNotificationCallback([this, protectedThis = makeRef(*this)] {
+ if (m_resourceLoadStatisticsStore->isEmpty())
+ return;
+ processStatisticsAndDataRecords();
+ });
+ m_resourceLoadStatisticsStore->setWritePersistentStoreCallback([this, protectedThis = makeRef(*this)] {
+ m_statisticsQueue->dispatch([this, protectedThis = protectedThis.copyRef()] {
+ stopMonitoringStatisticsStorage();
+ writeStoreToDisk();
+ startMonitoringStatisticsStorage();
+ });
+ });
+ m_resourceLoadStatisticsStore->setGrandfatherExistingWebsiteDataCallback([this, protectedThis = makeRef(*this)] {
+ grandfatherExistingWebsiteData();
+ });
+ m_resourceLoadStatisticsStore->setDeletePersistentStoreCallback([this, protectedThis = makeRef(*this)] {
+ m_statisticsQueue->dispatch([this, protectedThis = protectedThis.copyRef()] {
+ deleteStoreFromDisk();
+ });
+ });
+ m_resourceLoadStatisticsStore->setFireTelemetryCallback([this, protectedThis = makeRef(*this)] {
+ submitTelemetry();
+ });
+
+ if (updatePartitionCookiesForDomainsHandler) {
+ m_resourceLoadStatisticsStore->setShouldPartitionCookiesCallback([updatePartitionCookiesForDomainsHandler = WTFMove(updatePartitionCookiesForDomainsHandler)] (const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool shouldClearFirst) {
+ updatePartitionCookiesForDomainsHandler(domainsToRemove, domainsToAdd, shouldClearFirst);
+ });
+ }
+
+ m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this)] {
+ readDataFromDiskIfNeeded();
+ startMonitoringStatisticsStorage();
+ });
+
m_telemetryOneShotTimer.startOneShot(5_s);
m_telemetryRepeatedTimer.startRepeating(24_h);
}
@@ -186,72 +222,6 @@
processStatisticsAndDataRecords();
}
-void WebResourceLoadStatisticsStore::setResourceLoadStatisticsEnabled(bool enabled)
-{
- ASSERT(RunLoop::isMain());
-
- if (enabled == m_resourceLoadStatisticsEnabled)
- return;
-
- m_resourceLoadStatisticsEnabled = enabled;
-
- if (m_resourceLoadStatisticsEnabled) {
- readDataFromDiskIfNeeded();
- m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this)] {
- startMonitoringStatisticsStorage();
- });
- } else
- m_statisticsQueue->dispatch([statisticsStorageMonitor = WTFMove(m_statisticsStorageMonitor)] { });
-}
-
-bool WebResourceLoadStatisticsStore::resourceLoadStatisticsEnabled() const
-{
- return m_resourceLoadStatisticsEnabled;
-}
-
-void WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver()
-{
- ASSERT(RunLoop::isMain());
-
- m_resourceLoadStatisticsStore->setNotificationCallback([this, protectedThis = makeRef(*this)] {
- if (m_resourceLoadStatisticsStore->isEmpty())
- return;
- processStatisticsAndDataRecords();
- });
- m_resourceLoadStatisticsStore->setWritePersistentStoreCallback([this, protectedThis = makeRef(*this)] {
- m_statisticsQueue->dispatch([this, protectedThis = protectedThis.copyRef()] {
- stopMonitoringStatisticsStorage();
- writeStoreToDisk();
- startMonitoringStatisticsStorage();
- });
- });
- m_resourceLoadStatisticsStore->setGrandfatherExistingWebsiteDataCallback([this, protectedThis = makeRef(*this)] {
- grandfatherExistingWebsiteData();
- });
- m_resourceLoadStatisticsStore->setDeletePersistentStoreCallback([this, protectedThis = makeRef(*this)] {
- m_statisticsQueue->dispatch([this, protectedThis = protectedThis.copyRef()] {
- deleteStoreFromDisk();
- });
- });
- m_resourceLoadStatisticsStore->setFireTelemetryCallback([this, protectedThis = makeRef(*this)] {
- submitTelemetry();
- });
-
-#if PLATFORM(COCOA)
- registerUserDefaultsIfNeeded();
-#endif
-}
-
-void WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver(WTF::Function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)>&& shouldPartitionCookiesForDomainsHandler)
-{
- ASSERT(RunLoop::isMain());
-
- registerSharedResourceLoadObserver();
- m_resourceLoadStatisticsStore->setShouldPartitionCookiesCallback([shouldPartitionCookiesForDomainsHandler = WTFMove(shouldPartitionCookiesForDomainsHandler)] (const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst) {
- shouldPartitionCookiesForDomainsHandler(domainsToRemove, domainsToAdd, clearFirst);
- });
-}
-
void WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData()
{
// Switch to the main thread to get the default website data store
@@ -282,37 +252,34 @@
void WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded()
{
- if (!m_resourceLoadStatisticsEnabled)
+ ASSERT(!RunLoop::isMain());
+
+ String resourceLog = persistentStoragePath(ASCIILiteral("full_browsing_session"));
+ if (resourceLog.isEmpty() || !fileExists(resourceLog)) {
+ grandfatherExistingWebsiteData();
return;
+ }
- m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this)] {
- String resourceLog = persistentStoragePath(ASCIILiteral("full_browsing_session"));
- if (resourceLog.isEmpty() || !fileExists(resourceLog)) {
- grandfatherExistingWebsiteData();
- return;
- }
+ if (!hasStatisticsFileChangedSinceLastSync(resourceLog)) {
+ // No need to grandfather in this case.
+ return;
+ }
- if (!hasStatisticsFileChangedSinceLastSync(resourceLog)) {
- // No need to grandfather in this case.
- return;
- }
+ WallTime readTime = WallTime::now();
- WallTime readTime = WallTime::now();
+ auto decoder = createDecoderFromDisk(resourceLog);
+ if (!decoder) {
+ grandfatherExistingWebsiteData();
+ return;
+ }
- auto decoder = createDecoderFromDisk(resourceLog);
- if (!decoder) {
- grandfatherExistingWebsiteData();
- return;
- }
-
- coreStore().clearInMemory();
- coreStore().readDataFromDecoder(*decoder);
+ coreStore().clearInMemory();
+ coreStore().readDataFromDecoder(*decoder);
- m_lastStatisticsFileSyncTime = readTime;
+ m_lastStatisticsFileSyncTime = readTime;
- if (coreStore().isEmpty())
- grandfatherExistingWebsiteData();
- });
+ if (coreStore().isEmpty())
+ grandfatherExistingWebsiteData();
}
void WebResourceLoadStatisticsStore::refreshFromDisk()
Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h (219202 => 219203)
--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h 2017-07-06 17:12:54 UTC (rev 219202)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h 2017-07-06 17:23:07 UTC (rev 219203)
@@ -57,17 +57,17 @@
class WebResourceLoadStatisticsStore final : public IPC::Connection::WorkQueueMessageReceiver {
public:
- static Ref<WebResourceLoadStatisticsStore> create(const String&);
+ using UpdatePartitionCookiesForDomainsHandler = WTF::Function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool shouldClearFirst)>;
+ static Ref<WebResourceLoadStatisticsStore> create(const String& resourceLoadStatisticsDirectory, UpdatePartitionCookiesForDomainsHandler&& updatePartitionCookiesForDomainsHandler = { })
+ {
+ return adoptRef(*new WebResourceLoadStatisticsStore(resourceLoadStatisticsDirectory, WTFMove(updatePartitionCookiesForDomainsHandler)));
+ }
+
static void setNotifyPagesWhenDataRecordsWereScanned(bool);
static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
static void setShouldSubmitTelemetry(bool);
virtual ~WebResourceLoadStatisticsStore();
-
- void setResourceLoadStatisticsEnabled(bool);
- bool resourceLoadStatisticsEnabled() const;
- void registerSharedResourceLoadObserver();
- void registerSharedResourceLoadObserver(WTF::Function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)>&& shouldPartitionCookiesForDomainsHandler);
-
+
void resourceLoadStatisticsUpdated(const Vector<WebCore::ResourceLoadStatistics>& origins);
void processWillOpenConnection(WebProcessProxy&, IPC::Connection&);
@@ -74,8 +74,6 @@
void processDidCloseConnection(WebProcessProxy&, IPC::Connection&);
void applicationWillTerminate();
- void readDataFromDiskIfNeeded();
-
void logUserInteraction(const WebCore::URL&);
void clearUserInteraction(const WebCore::URL&);
void hasHadUserInteraction(const WebCore::URL&, WTF::Function<void (bool)>&&);
@@ -102,12 +100,13 @@
void setGrandfatheringTime(Seconds);
private:
- explicit WebResourceLoadStatisticsStore(const String&);
+ WebResourceLoadStatisticsStore(const String&, UpdatePartitionCookiesForDomainsHandler&&);
ResourceLoadStatisticsStore& coreStore() { return m_resourceLoadStatisticsStore.get(); }
const ResourceLoadStatisticsStore& coreStore() const { return m_resourceLoadStatisticsStore.get(); }
void processStatisticsAndDataRecords();
+ void readDataFromDiskIfNeeded();
void classifyResource(WebCore::ResourceLoadStatistics&);
void removeDataRecords();
@@ -148,7 +147,6 @@
RefPtr<WebCore::FileMonitor> m_statisticsStorageMonitor;
String m_statisticsStoragePath;
WTF::WallTime m_lastStatisticsFileSyncTime;
- bool m_resourceLoadStatisticsEnabled { false };
RunLoop::Timer<WebResourceLoadStatisticsStore> m_telemetryOneShotTimer;
RunLoop::Timer<WebResourceLoadStatisticsStore> m_telemetryRepeatedTimer;
};
Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (219202 => 219203)
--- trunk/Source/WebKit2/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm 2017-07-06 17:12:54 UTC (rev 219202)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm 2017-07-06 17:23:07 UTC (rev 219203)
@@ -103,8 +103,6 @@
ASSERT(!dataStoresWithStorageManagers().contains(this));
dataStoresWithStorageManagers().append(this);
- if (m_resourceLoadStatistics)
- m_resourceLoadStatistics->readDataFromDiskIfNeeded();
}
void WebsiteDataStore::platformDestroy()
Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (219202 => 219203)
--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp 2017-07-06 17:12:54 UTC (rev 219202)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp 2017-07-06 17:23:07 UTC (rev 219203)
@@ -76,7 +76,6 @@
, m_sessionID(sessionID)
, m_configuration(WTFMove(configuration))
, m_storageManager(StorageManager::create(m_configuration.localStorageDirectory))
- , m_resourceLoadStatistics(WebResourceLoadStatisticsStore::create(m_configuration.resourceLoadStatisticsDirectory))
, m_queue(WorkQueue::create("com.apple.WebKit.WebsiteDataStore"))
{
platformInitialize();
@@ -1254,38 +1253,29 @@
bool WebsiteDataStore::resourceLoadStatisticsEnabled() const
{
- return m_resourceLoadStatistics ? m_resourceLoadStatistics->resourceLoadStatisticsEnabled() : false;
+ return !!m_resourceLoadStatistics;
}
void WebsiteDataStore::setResourceLoadStatisticsEnabled(bool enabled)
{
- if (!m_resourceLoadStatistics)
- return;
-
if (enabled == resourceLoadStatisticsEnabled())
return;
- // FIXME: We should probably only initialize m_resourceLoadStatistics when resource load statistics get enabled.
- m_resourceLoadStatistics->setResourceLoadStatisticsEnabled(enabled);
+ if (enabled) {
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(m_configuration.resourceLoadStatisticsDirectory, [this] (const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool shouldClearFirst) {
+ updateCookiePartitioningForTopPrivatelyOwnedDomains(domainsToRemove, domainsToAdd, shouldClearFirst);
+ });
+#else
+ m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(m_configuration.resourceLoadStatisticsDirectory);
+#endif
+ } else
+ m_resourceLoadStatistics = nullptr;
for (auto& processPool : processPools())
processPool->setResourceLoadStatisticsEnabled(enabled);
}
-void WebsiteDataStore::registerSharedResourceLoadObserver()
-{
- if (!m_resourceLoadStatistics)
- return;
-
-#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
- m_resourceLoadStatistics->registerSharedResourceLoadObserver([this] (const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool shouldClearFirst) {
- updateCookiePartitioningForTopPrivatelyOwnedDomains(domainsToRemove, domainsToAdd, shouldClearFirst);
- });
-#else
- m_resourceLoadStatistics->registerSharedResourceLoadObserver();
-#endif
-}
-
DatabaseProcessCreationParameters WebsiteDataStore::databaseProcessParameters()
{
resolveDirectoriesIfNecessary();
Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h (219202 => 219203)
--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h 2017-07-06 17:12:54 UTC (rev 219202)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h 2017-07-06 17:23:07 UTC (rev 219203)
@@ -90,7 +90,6 @@
bool resourceLoadStatisticsEnabled() const;
void setResourceLoadStatisticsEnabled(bool);
WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); }
- void registerSharedResourceLoadObserver();
static void cloneSessionData(WebPageProxy& sourcePage, WebPageProxy& newPage);
@@ -161,7 +160,7 @@
bool m_hasResolvedDirectories { false };
const RefPtr<StorageManager> m_storageManager;
- const RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics;
+ RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics;
Ref<WorkQueue> m_queue;
Modified: trunk/Source/WebKit2/UIProcess/wpe/WebProcessPoolWPE.cpp (219202 => 219203)
--- trunk/Source/WebKit2/UIProcess/wpe/WebProcessPoolWPE.cpp 2017-07-06 17:12:54 UTC (rev 219202)
+++ trunk/Source/WebKit2/UIProcess/wpe/WebProcessPoolWPE.cpp 2017-07-06 17:23:07 UTC (rev 219203)
@@ -75,7 +75,6 @@
g_unsetenv("WEBKIT_INSPECTOR_SERVER");
}
#endif
- m_websiteDataStore->websiteDataStore().registerSharedResourceLoadObserver();
}
WTF::String WebProcessPool::legacyPlatformDefaultApplicationCacheDirectory()