Diff
Modified: trunk/Source/WebKit2/ChangeLog (219070 => 219071)
--- trunk/Source/WebKit2/ChangeLog 2017-07-03 11:26:36 UTC (rev 219070)
+++ trunk/Source/WebKit2/ChangeLog 2017-07-03 16:02:45 UTC (rev 219071)
@@ -1,3 +1,54 @@
+2017-07-03 Chris Dumez <[email protected]>
+
+ Drop ResourceLoadStatisticsStore's statisticsLock
+ https://bugs.webkit.org/show_bug.cgi?id=174080
+
+ Reviewed by Brent Fulgham.
+
+ Drop ResourceLoadStatisticsStore's statisticsLock. It added complexity and was only needed
+ do that the SPI exposed to WebKitTestRunner would query the store synchronously from the
+ main thread. Instead, I made the SPI asynchronous and make sure we always access the store
+ from the same background thread. As a result, there is no longer any need for locking.
+
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (-[WKWebsiteDataStore _resourceLoadStatisticsIsPrevalentResource:completionHandler:]):
+ (-[WKWebsiteDataStore _resourceLoadStatisticsHadUserInteraction:completionHandler:]):
+ (-[WKWebsiteDataStore _resourceLoadStatisticsIsGrandfathered:completionHandler:]):
+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+ * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
+ (WebKit::ResourceLoadStatisticsStore::isPrevalentResource):
+ (WebKit::ResourceLoadStatisticsStore::isGrandFathered):
+ (WebKit::ResourceLoadStatisticsStore::ensureResourceStatisticsForPrimaryDomain):
+ (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
+ (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
+ (WebKit::ResourceLoadStatisticsStore::clearInMemory):
+ (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
+ (WebKit::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
+ (WebKit::ResourceLoadStatisticsStore::processStatistics):
+ (WebKit::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
+ (WebKit::ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry):
+ (WebKit::ResourceLoadStatisticsStore::updateStatisticsForRemovedDataRecords):
+ (WebKit::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
+ * UIProcess/Storage/ResourceLoadStatisticsStore.h:
+ * UIProcess/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
+ (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
+ (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
+ (WebKit::WebResourceLoadStatisticsStore::clearInMemoryData):
+ (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
+ (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
+ (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
+ (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
+ (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
+ (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
+ (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
+ (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
+ (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
+ (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
+ (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
+ (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
+ * UIProcess/WebResourceLoadStatisticsStore.h:
+
2017-07-03 Wenson Hsieh <[email protected]>
Pasting single words copied to UIPasteboard inserts URLs in editable areas
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (219070 => 219071)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2017-07-03 11:26:36 UTC (rev 219070)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2017-07-03 16:02:45 UTC (rev 219071)
@@ -219,13 +219,18 @@
store->clearPrevalentResource(URL(URL(), host));
}
-- (BOOL)_resourceLoadStatisticsIsPrevalentResource:(NSString *)host
+- (void)_resourceLoadStatisticsIsPrevalentResource:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler
{
auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
- if (!store)
- return NO;
+ if (!store) {
+ completionHandler(NO);
+ return;
+ }
- return store->isPrevalentResource(URL(URL(), host));
+ auto completionHandlerCopy = makeBlockPtr(completionHandler);
+ store->isPrevalentResource(URL(URL(), host), [completionHandlerCopy](bool isPrevalentResource) {
+ completionHandlerCopy(isPrevalentResource);
+ });
}
- (void)_resourceLoadStatisticsSetHadUserInteraction:(BOOL)value forHost:(NSString *)host
@@ -240,13 +245,18 @@
store->clearUserInteraction(URL(URL(), host));
}
-- (BOOL)_resourceLoadStatisticsHadUserInteraction:(NSString *)host
+- (void)_resourceLoadStatisticsHadUserInteraction:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler
{
auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
- if (!store)
- return NO;
+ if (!store) {
+ completionHandler(NO);
+ return;
+ }
- return store->hasHadUserInteraction(URL(URL(), host));
+ auto completionHandlerCopy = makeBlockPtr(completionHandler);
+ store->hasHadUserInteraction(URL(URL(), host), [completionHandlerCopy](bool hasHadUserInteraction) {
+ completionHandlerCopy(hasHadUserInteraction);
+ });
}
- (void)_resourceLoadStatisticsSetIsGrandfathered:(BOOL)value forHost:(NSString *)host
@@ -258,13 +268,18 @@
store->setGrandfathered(URL(URL(), host), value);
}
-- (BOOL)_resourceLoadStatisticsIsGrandfathered:(NSString *)host
+- (void)_resourceLoadStatisticsIsGrandfathered:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler
{
auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
- if (!store)
- return NO;
+ if (!store) {
+ completionHandler(NO);
+ return;
+ }
- return store->isGrandfathered(URL(URL(), host));
+ auto completionHandlerCopy = makeBlockPtr(completionHandler);
+ store->isGrandfathered(URL(URL(), host), [completionHandlerCopy](bool isGrandfathered) {
+ completionHandlerCopy(isGrandfathered);
+ });
}
- (void)_resourceLoadStatisticsSetSubframeUnderTopFrameOrigin:(NSString *)topFrameHostName forHost:(NSString *)host
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (219070 => 219071)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2017-07-03 11:26:36 UTC (rev 219070)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2017-07-03 16:02:45 UTC (rev 219071)
@@ -45,11 +45,11 @@
// ResourceLoadStatistics SPI for testing.
- (void)_resourceLoadStatisticsSetIsPrevalentResource:(BOOL)value forHost:(NSString *)host WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
-- (BOOL)_resourceLoadStatisticsIsPrevalentResource:(NSString *)host WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_resourceLoadStatisticsIsPrevalentResource:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_resourceLoadStatisticsSetHadUserInteraction:(BOOL)value forHost:(NSString *)host WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
-- (BOOL)_resourceLoadStatisticsHadUserInteraction:(NSString *)host WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_resourceLoadStatisticsHadUserInteraction:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_resourceLoadStatisticsSetIsGrandfathered:(BOOL)value forHost:(NSString *)host WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
-- (BOOL)_resourceLoadStatisticsIsGrandfathered:(NSString *)host WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_resourceLoadStatisticsIsGrandfathered:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_resourceLoadStatisticsSetSubframeUnderTopFrameOrigin:(NSString *)topFrameHostName forHost:(NSString *)host WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_resourceLoadStatisticsSetSubresourceUnderTopFrameOrigin:(NSString *)topFrameHostName forHost:(NSString *)host WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_resourceLoadStatisticsSetSubresourceUniqueRedirectTo:(NSString *)hostNameRedirectedTo forHost:(NSString *)host WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
Modified: trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.cpp (219070 => 219071)
--- trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.cpp 2017-07-03 11:26:36 UTC (rev 219070)
+++ trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.cpp 2017-07-03 16:02:45 UTC (rev 219071)
@@ -52,7 +52,7 @@
bool ResourceLoadStatisticsStore::isPrevalentResource(const String& primaryDomain) const
{
- auto locker = holdLock(m_statisticsLock);
+ ASSERT(!RunLoop::isMain());
auto mapEntry = m_resourceStatisticsMap.find(primaryDomain);
if (mapEntry == m_resourceStatisticsMap.end())
return false;
@@ -59,10 +59,20 @@
return mapEntry->value.isPrevalentResource;
}
+
+bool ResourceLoadStatisticsStore::isGrandFathered(const String& primaryDomain) const
+{
+ ASSERT(!RunLoop::isMain());
+ auto mapEntry = m_resourceStatisticsMap.find(primaryDomain);
+ if (mapEntry == m_resourceStatisticsMap.end())
+ return false;
+
+ return mapEntry->value.grandfathered;
+}
ResourceLoadStatistics& ResourceLoadStatisticsStore::ensureResourceStatisticsForPrimaryDomain(const String& primaryDomain)
{
- ASSERT(m_statisticsLock.isLocked());
+ ASSERT(!RunLoop::isMain());
auto addResult = m_resourceStatisticsMap.ensure(primaryDomain, [&primaryDomain] {
return ResourceLoadStatistics(primaryDomain);
});
@@ -76,8 +86,6 @@
{
ASSERT(!RunLoop::isMain());
auto encoder = KeyedEncoder::encoder();
-
- auto locker = holdLock(m_statisticsLock);
encoder->encodeUInt32("version", statisticsModelVersion);
encoder->encodeDouble("endOfGrandfatheringTimestamp", m_endOfGrandfatheringTimestamp.secondsSinceEpoch().value());
@@ -91,7 +99,6 @@
void ResourceLoadStatisticsStore::readDataFromDecoder(KeyedDecoder& decoder)
{
ASSERT(!RunLoop::isMain());
- ASSERT(m_statisticsLock.isLocked());
if (m_resourceStatisticsMap.size())
return;
@@ -118,16 +125,12 @@
Vector<String> prevalentResourceDomainsWithoutUserInteraction;
prevalentResourceDomainsWithoutUserInteraction.reserveInitialCapacity(loadedStatistics.size());
-
- {
- auto locker = holdLock(m_statisticsLock);
- for (auto& statistics : loadedStatistics) {
- if (statistics.isPrevalentResource && !statistics.hadUserInteraction) {
- prevalentResourceDomainsWithoutUserInteraction.uncheckedAppend(statistics.highLevelDomain);
- statistics.isMarkedForCookiePartitioning = true;
- }
- m_resourceStatisticsMap.set(statistics.highLevelDomain, WTFMove(statistics));
+ for (auto& statistics : loadedStatistics) {
+ if (statistics.isPrevalentResource && !statistics.hadUserInteraction) {
+ prevalentResourceDomainsWithoutUserInteraction.uncheckedAppend(statistics.highLevelDomain);
+ statistics.isMarkedForCookiePartitioning = true;
}
+ m_resourceStatisticsMap.set(statistics.highLevelDomain, WTFMove(statistics));
}
fireShouldPartitionCookiesHandler({ }, prevalentResourceDomainsWithoutUserInteraction, true);
@@ -136,10 +139,7 @@
void ResourceLoadStatisticsStore::clearInMemory()
{
ASSERT(!RunLoop::isMain());
- {
- auto locker = holdLock(m_statisticsLock);
m_resourceStatisticsMap.clear();
- }
fireShouldPartitionCookiesHandler({ }, { }, true);
}
@@ -157,7 +157,6 @@
void ResourceLoadStatisticsStore::mergeStatistics(const Vector<ResourceLoadStatistics>& statistics)
{
ASSERT(!RunLoop::isMain());
- auto locker = holdLock(m_statisticsLock);
for (auto& statistic : statistics) {
auto result = m_resourceStatisticsMap.ensure(statistic.highLevelDomain, [&statistic] {
return ResourceLoadStatistics(statistic.highLevelDomain);
@@ -224,7 +223,6 @@
Vector<String> domainsToRemove;
Vector<String> domainsToAdd;
- auto locker = holdLock(m_statisticsLock);
for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
bool shouldPartition = shouldPartitionCookies(resourceStatistic);
if (resourceStatistic.isMarkedForCookiePartitioning && !shouldPartition) {
@@ -256,7 +254,6 @@
m_shouldPartitionCookiesForDomainsHandler(domainsToRemove, domainsToAdd, clearFirst);
});
- auto locker = holdLock(m_statisticsLock);
if (clearFirst) {
for (auto& resourceStatistic : m_resourceStatisticsMap.values())
resourceStatistic.isMarkedForCookiePartitioning = false;
@@ -296,7 +293,6 @@
void ResourceLoadStatisticsStore::processStatistics(WTF::Function<void(ResourceLoadStatistics&)>&& processFunction)
{
ASSERT(!RunLoop::isMain());
- auto locker = holdLock(m_statisticsLock);
for (auto& resourceStatistic : m_resourceStatisticsMap.values())
processFunction(resourceStatistic);
}
@@ -321,6 +317,8 @@
Vector<String> ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor()
{
+ ASSERT(!RunLoop::isMain());
+
bool shouldCheckForGrandfathering = m_endOfGrandfatheringTimestamp > WallTime::now();
bool shouldClearGrandfathering = !shouldCheckForGrandfathering && m_endOfGrandfatheringTimestamp;
@@ -328,7 +326,6 @@
m_endOfGrandfatheringTimestamp = { };
Vector<String> prevalentResources;
- auto locker = holdLock(m_statisticsLock);
for (auto& statistic : m_resourceStatisticsMap.values()) {
if (statistic.isPrevalentResource
&& !hasHadRecentUserInteraction(statistic)
@@ -345,7 +342,6 @@
Vector<PrevalentResourceTelemetry> ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry() const
{
ASSERT(!RunLoop::isMain());
- auto locker = holdLock(m_statisticsLock);
Vector<PrevalentResourceTelemetry> sorted;
for (auto& statistic : m_resourceStatisticsMap.values()) {
if (!statistic.isPrevalentResource)
@@ -375,7 +371,7 @@
void ResourceLoadStatisticsStore::updateStatisticsForRemovedDataRecords(const HashSet<String>& prevalentResourceDomains)
{
- auto locker = holdLock(m_statisticsLock);
+ ASSERT(!RunLoop::isMain());
for (auto& prevalentResourceDomain : prevalentResourceDomains) {
ResourceLoadStatistics& statistic = ensureResourceStatisticsForPrimaryDomain(prevalentResourceDomain);
++statistic.dataRecordsRemoved;
@@ -384,7 +380,7 @@
void ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore(HashSet<String>&& topPrivatelyControlledDomainsToGrandfather)
{
- auto locker = holdLock(m_statisticsLock);
+ ASSERT(!RunLoop::isMain());
for (auto& topPrivatelyControlledDomain : topPrivatelyControlledDomainsToGrandfather) {
ResourceLoadStatistics& statistic = ensureResourceStatisticsForPrimaryDomain(topPrivatelyControlledDomain);
statistic.grandfathered = true;
@@ -417,9 +413,4 @@
m_dataRecordsRemovalPending = false;
}
-WTF::RecursiveLockAdapter<Lock>& ResourceLoadStatisticsStore::statisticsLock()
-{
- return m_statisticsLock;
}
-
-}
Modified: trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h (219070 => 219071)
--- trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h 2017-07-03 11:26:36 UTC (rev 219070)
+++ trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h 2017-07-03 16:02:45 UTC (rev 219071)
@@ -29,7 +29,6 @@
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/MonotonicTime.h>
-#include <wtf/RecursiveLockAdapter.h>
#include <wtf/WallTime.h>
#include <wtf/text/WTFString.h>
@@ -69,6 +68,7 @@
void setResourceStatisticsForPrimaryDomain(const String&, WebCore::ResourceLoadStatistics&&);
bool isPrevalentResource(const String&) const;
+ bool isGrandFathered(const String&) const;
void mergeStatistics(const Vector<WebCore::ResourceLoadStatistics>&);
@@ -99,14 +99,11 @@
bool shouldRemoveDataRecords() const;
void dataRecordsBeingRemoved();
void dataRecordsWereRemoved();
-
- WTF::RecursiveLockAdapter<Lock>& statisticsLock();
private:
ResourceLoadStatisticsStore() = default;
HashMap<String, WebCore::ResourceLoadStatistics> m_resourceStatisticsMap;
- mutable WTF::RecursiveLockAdapter<Lock> m_statisticsLock;
WTF::Function<void()> m_dataAddedHandler;
WTF::Function<void(const Vector<String>&, const Vector<String>&, bool clearFirst)> m_shouldPartitionCookiesForDomainsHandler;
Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp (219070 => 219071)
--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp 2017-07-03 11:26:36 UTC (rev 219070)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp 2017-07-03 16:02:45 UTC (rev 219071)
@@ -155,7 +155,6 @@
void WebResourceLoadStatisticsStore::processStatisticsAndDataRecords()
{
m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this)] () {
- auto locker = holdLock(coreStore().statisticsLock());
if (shouldClassifyResourcesBeforeDataRecordsRemoval) {
coreStore().processStatistics([this] (ResourceLoadStatistics& resourceStatistic) {
classifyResource(resourceStatistic);
@@ -275,7 +274,6 @@
return;
}
- auto locker = holdLock(coreStore().statisticsLock());
coreStore().clearInMemory();
coreStore().readDataFromDecoder(*decoder);
@@ -291,7 +289,6 @@
if (!decoder)
return;
- auto locker = holdLock(coreStore().statisticsLock());
coreStore().readDataFromDecoder(*decoder);
}
@@ -402,7 +399,7 @@
void WebResourceLoadStatisticsStore::clearInMemoryData()
{
- auto locker = holdLock(coreStore().statisticsLock());
+ ASSERT(!RunLoop::isMain());
coreStore().clearInMemory();
}
@@ -504,7 +501,6 @@
void WebResourceLoadStatisticsStore::submitTelemetry()
{
m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this)] {
- auto locker = holdLock(coreStore().statisticsLock());
WebResourceLoadStatisticsTelemetry::calculateAndSubmit(coreStore());
});
}
@@ -515,12 +511,9 @@
return;
m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), primaryDomainString = primaryDomain(url).isolatedCopy()] {
- {
- auto locker = holdLock(coreStore().statisticsLock());
- auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomainString);
- statistics.hadUserInteraction = true;
- statistics.mostRecentUserInteractionTime = WallTime::now();
- }
+ auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomainString);
+ statistics.hadUserInteraction = true;
+ statistics.mostRecentUserInteractionTime = WallTime::now();
coreStore().fireShouldPartitionCookiesHandler({ primaryDomainString }, { }, false);
});
@@ -531,21 +524,27 @@
if (url.isBlankURL() || url.isEmpty())
return;
- auto locker = holdLock(coreStore().statisticsLock());
- auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
- statistics.hadUserInteraction = false;
- statistics.mostRecentUserInteractionTime = { };
+ m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), url = "" {
+ auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+ statistics.hadUserInteraction = false;
+ statistics.mostRecentUserInteractionTime = { };
+ });
}
-bool WebResourceLoadStatisticsStore::hasHadUserInteraction(const URL& url)
+void WebResourceLoadStatisticsStore::hasHadUserInteraction(const URL& url, WTF::Function<void (bool)>&& completionHandler)
{
- if (url.isBlankURL() || url.isEmpty())
- return false;
+ if (url.isBlankURL() || url.isEmpty()) {
+ completionHandler(false);
+ return;
+ }
- auto locker = holdLock(coreStore().statisticsLock());
- // FIXME: Why is this potentially creating a store entry just for querying?
- auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
- return coreStore().hasHadRecentUserInteraction(statistics);
+ m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), url = "" completionHandler = WTFMove(completionHandler)] () mutable {
+ // FIXME: Why is this potentially creating a store entry just for querying?
+ auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+ RunLoop::main().dispatch([hasHadUserInteraction = coreStore().hasHadRecentUserInteraction(statistics), completionHandler = WTFMove(completionHandler)] {
+ completionHandler(hasHadUserInteraction);
+ });
+ });
}
void WebResourceLoadStatisticsStore::setPrevalentResource(const URL& url)
@@ -553,20 +552,25 @@
if (url.isBlankURL() || url.isEmpty())
return;
- auto locker = holdLock(coreStore().statisticsLock());
- auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
- statistics.isPrevalentResource = true;
+ m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), url = "" {
+ auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+ statistics.isPrevalentResource = true;
+ });
}
-bool WebResourceLoadStatisticsStore::isPrevalentResource(const URL& url)
+void WebResourceLoadStatisticsStore::isPrevalentResource(const URL& url, WTF::Function<void (bool)>&& completionHandler)
{
- if (url.isBlankURL() || url.isEmpty())
- return false;
+ if (url.isBlankURL() || url.isEmpty()) {
+ completionHandler(false);
+ return;
+ }
- auto locker = holdLock(coreStore().statisticsLock());
- // FIXME: Why is this potentially creating a store entry just for querying?
- auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
- return statistics.isPrevalentResource;
+ m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), url = "" completionHandler = WTFMove(completionHandler)] () mutable {
+ bool prevalentResource = coreStore().isPrevalentResource(primaryDomain(url));
+ RunLoop::main().dispatch([prevalentResource, completionHandler = WTFMove(completionHandler)] {
+ completionHandler(prevalentResource);
+ });
+ });
}
void WebResourceLoadStatisticsStore::clearPrevalentResource(const URL& url)
@@ -574,9 +578,10 @@
if (url.isBlankURL() || url.isEmpty())
return;
- auto locker = holdLock(coreStore().statisticsLock());
- auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
- statistics.isPrevalentResource = false;
+ m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), url = "" {
+ auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+ statistics.isPrevalentResource = false;
+ });
}
void WebResourceLoadStatisticsStore::setGrandfathered(const URL& url, bool value)
@@ -584,20 +589,25 @@
if (url.isBlankURL() || url.isEmpty())
return;
- auto locker = holdLock(coreStore().statisticsLock());
- auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
- statistics.grandfathered = value;
+ m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), url = "" value] {
+ auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+ statistics.grandfathered = value;
+ });
}
-bool WebResourceLoadStatisticsStore::isGrandfathered(const URL& url)
+void WebResourceLoadStatisticsStore::isGrandfathered(const URL& url, WTF::Function<void (bool)>&& completionHandler)
{
- if (url.isBlankURL() || url.isEmpty())
- return false;
+ if (url.isBlankURL() || url.isEmpty()) {
+ completionHandler(false);
+ return;
+ }
- auto locker = holdLock(coreStore().statisticsLock());
- // FIXME: Why is this potentially creating a store entry just for querying?
- auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
- return statistics.grandfathered;
+ m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler), url = "" () mutable {
+ bool grandFathered = coreStore().isGrandFathered(primaryDomain(url));
+ RunLoop::main().dispatch([grandFathered, completionHandler = WTFMove(completionHandler)] {
+ completionHandler(grandFathered);
+ });
+ });
}
void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame)
@@ -606,7 +616,6 @@
return;
m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), primaryTopFrameDomainString = primaryDomain(topFrame).isolatedCopy(), primarySubFrameDomainString = primaryDomain(subframe).isolatedCopy()] {
- auto locker = holdLock(coreStore().statisticsLock());
auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primarySubFrameDomainString);
statistics.subframeUnderTopFrameOrigins.add(primaryTopFrameDomainString);
});
@@ -618,7 +627,6 @@
return;
m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), primaryTopFrameDomainString = primaryDomain(topFrame).isolatedCopy(), primarySubresourceDomainString = primaryDomain(subresource).isolatedCopy()] {
- auto locker = holdLock(coreStore().statisticsLock());
auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomainString);
statistics.subresourceUnderTopFrameOrigins.add(primaryTopFrameDomainString);
});
@@ -630,7 +638,6 @@
return;
m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), primaryRedirectDomainString = primaryDomain(hostNameRedirectedTo).isolatedCopy(), primarySubresourceDomainString = primaryDomain(subresource).isolatedCopy()] {
- auto locker = holdLock(coreStore().statisticsLock());
auto& statistics = coreStore().ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomainString);
statistics.subresourceUniqueRedirectsTo.add(primaryRedirectDomainString);
});
Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h (219070 => 219071)
--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h 2017-07-03 11:26:36 UTC (rev 219070)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h 2017-07-03 16:02:45 UTC (rev 219071)
@@ -77,12 +77,12 @@
void logUserInteraction(const WebCore::URL&);
void clearUserInteraction(const WebCore::URL&);
- bool hasHadUserInteraction(const WebCore::URL&);
+ void hasHadUserInteraction(const WebCore::URL&, WTF::Function<void (bool)>&&);
void setPrevalentResource(const WebCore::URL&);
- bool isPrevalentResource(const WebCore::URL&);
+ void isPrevalentResource(const WebCore::URL&, WTF::Function<void (bool)>&&);
void clearPrevalentResource(const WebCore::URL&);
void setGrandfathered(const WebCore::URL&, bool);
- bool isGrandfathered(const WebCore::URL&);
+ void isGrandfathered(const WebCore::URL&, WTF::Function<void (bool)>&&);
void setSubframeUnderTopFrameOrigin(const WebCore::URL& subframe, const WebCore::URL& topFrame);
void setSubresourceUnderTopFrameOrigin(const WebCore::URL& subresource, const WebCore::URL& topFrame);
void setSubresourceUniqueRedirectTo(const WebCore::URL& subresource, const WebCore::URL& hostNameRedirectedTo);
Modified: trunk/Tools/ChangeLog (219070 => 219071)
--- trunk/Tools/ChangeLog 2017-07-03 11:26:36 UTC (rev 219070)
+++ trunk/Tools/ChangeLog 2017-07-03 16:02:45 UTC (rev 219071)
@@ -1,3 +1,17 @@
+2017-07-03 Chris Dumez <[email protected]>
+
+ Drop ResourceLoadStatisticsStore's statisticsLock
+ https://bugs.webkit.org/show_bug.cgi?id=174080
+
+ Reviewed by Brent Fulgham.
+
+ Port WebKitTestRunner to new Asynchronous Cocoa SPI.
+
+ * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+ (WTR::TestController::isStatisticsPrevalentResource):
+ (WTR::TestController::isStatisticsHasHadUserInteraction):
+ (WTR::TestController::isStatisticsGrandfathered):
+
2017-07-03 Wenson Hsieh <[email protected]>
Pasting single words copied to UIPasteboard inserts URLs in editable areas
Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (219070 => 219071)
--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2017-07-03 11:26:36 UTC (rev 219070)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2017-07-03 16:02:45 UTC (rev 219071)
@@ -229,7 +229,15 @@
bool TestController::isStatisticsPrevalentResource(WKStringRef hostName)
{
- return [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsIsPrevalentResource:toNSString(hostName)];
+ __block bool isDataReady = false;
+ __block bool isPrevalentResource = false;
+ [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsIsPrevalentResource:toNSString(hostName) completionHandler:^(BOOL _isPrevalentResource) {
+ isPrevalentResource = _isPrevalentResource;
+ isDataReady = true;
+ }];
+ platformRunUntil(isDataReady, 0);
+
+ return isPrevalentResource;
}
void TestController::setStatisticsHasHadUserInteraction(WKStringRef hostName, bool value)
@@ -239,7 +247,15 @@
bool TestController::isStatisticsHasHadUserInteraction(WKStringRef hostName)
{
- return [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsHadUserInteraction:toNSString(hostName)];
+ __block bool isDataReady = false;
+ __block bool hasHadUserInteraction = false;
+ [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsHadUserInteraction:toNSString(hostName) completionHandler:^(BOOL _hasHadUserInteraction) {
+ hasHadUserInteraction = _hasHadUserInteraction;
+ isDataReady = true;
+ }];
+ platformRunUntil(isDataReady, 0);
+
+ return hasHadUserInteraction;
}
void TestController::setStatisticsGrandfathered(WKStringRef hostName, bool value)
@@ -249,7 +265,15 @@
bool TestController::isStatisticsGrandfathered(WKStringRef hostName)
{
- return [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsIsGrandfathered:toNSString(hostName)];
+ __block bool isDataReady = false;
+ __block bool isGrandfathered = false;
+ [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsIsGrandfathered:toNSString(hostName) completionHandler:^(BOOL _isGrandfathered) {
+ isGrandfathered = _isGrandfathered;
+ isDataReady = true;
+ }];
+ platformRunUntil(isDataReady, 0);
+
+ return isGrandfathered;
}
void TestController::setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)