Skip to content

Commit

Permalink
Merge r228828 - Make WebResourceLoadStatisticsStore::processStatistic…
Browse files Browse the repository at this point in the history
…sAndDataRecords() call WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed() in a proper callback

https://bugs.webkit.org/show_bug.cgi?id=182719
<rdar://problem/37517370>

Reviewed by Brent Fulgham.

Source/WebKit:

This will allow the page notification, statistics pruning, and persistence write
to be done at the right time and hopefully stabilize the layout tests including:
http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html

* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
    Now takes a callback parameter.
(WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
* UIProcess/WebResourceLoadStatisticsStore.h:
    Now calls WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed()
    in a callback provided to WebResourceLoadStatisticsStore::removeDataRecords().

LayoutTests:

* platform/mac-wk2/TestExpectations:
    Marked http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html
    as [ Pass ].
* platform/wk2/TestExpectations:
    Marked http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html
    as [ Pass ]. This should have been done already in r227223:
    https://bugs.webkit.org/show_bug.cgi?id=181822
  • Loading branch information
johnwilander authored and carlosgcampos committed Feb 26, 2018
1 parent 2d6034e commit c0b9b46
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 16 deletions.
16 changes: 16 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
2018-02-20 John Wilander <wilander@apple.com>

Make WebResourceLoadStatisticsStore::processStatisticsAndDataRecords() call WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed() in a proper callback
https://bugs.webkit.org/show_bug.cgi?id=182719
<rdar://problem/37517370>

Reviewed by Brent Fulgham.

* platform/mac-wk2/TestExpectations:
Marked http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html
as [ Pass ].
* platform/wk2/TestExpectations:
Marked http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html
as [ Pass ]. This should have been done already in r227223:
https://bugs.webkit.org/show_bug.cgi?id=181822

2018-02-19 Dean Jackson <dino@apple.com>

Handle all writing-modes in downcast
Expand Down
2 changes: 1 addition & 1 deletion LayoutTests/platform/wk2/TestExpectations
Expand Up @@ -693,7 +693,7 @@ http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-uni
http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html [ Pass ]
http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html [ Pass ]
http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html [ Pass ]
webkit.org/b/181223 http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html [ Skip ]
http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html [ Pass ]
http/tests/resourceLoadStatistics/grandfathering.html [ Pass ]
webkit.org/b/180703 http/tests/resourceLoadStatistics/telemetry-generation.html [ Pass Failure ]
http/tests/resourceLoadStatistics/prune-statistics.html [ Pass ]
Expand Down
20 changes: 20 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,23 @@
2018-02-20 John Wilander <wilander@apple.com>

Make WebResourceLoadStatisticsStore::processStatisticsAndDataRecords() call WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed() in a proper callback
https://bugs.webkit.org/show_bug.cgi?id=182719
<rdar://problem/37517370>

Reviewed by Brent Fulgham.

This will allow the page notification, statistics pruning, and persistence write
to be done at the right time and hopefully stabilize the layout tests including:
http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html

* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
Now takes a callback parameter.
(WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
* UIProcess/WebResourceLoadStatisticsStore.h:
Now calls WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed()
in a callback provided to WebResourceLoadStatisticsStore::removeDataRecords().

2018-02-21 Carlos Garcia Campos <cgarcia@igalia.com>

Unreviewed. Update OptionsGTK.cmake and NEWS for 2.19.91 release.
Expand Down
42 changes: 28 additions & 14 deletions Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
Expand Up @@ -185,12 +185,14 @@ WebResourceLoadStatisticsStore::~WebResourceLoadStatisticsStore()
m_persistentStorage.finishAllPendingWorkSynchronously();
}

void WebResourceLoadStatisticsStore::removeDataRecords()
void WebResourceLoadStatisticsStore::removeDataRecords(CompletionHandler<void()>&& callback)
{
ASSERT(!RunLoop::isMain());

if (!shouldRemoveDataRecords())
if (!shouldRemoveDataRecords()) {
callback();
return;
}

#if ENABLE(NETSCAPE_PLUGIN_API)
m_activePluginTokens.clear();
Expand All @@ -199,19 +201,22 @@ void WebResourceLoadStatisticsStore::removeDataRecords()
#endif

auto prevalentResourceDomains = topPrivatelyControlledDomainsToRemoveWebsiteDataFor();
if (prevalentResourceDomains.isEmpty())
if (prevalentResourceDomains.isEmpty()) {
callback();
return;

}

setDataRecordsBeingRemoved(true);

RunLoop::main().dispatch([prevalentResourceDomains = crossThreadCopy(prevalentResourceDomains), this, protectedThis = makeRef(*this)] () mutable {
WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, [this, protectedThis = WTFMove(protectedThis)](const HashSet<String>& domainsWithDeletedWebsiteData) mutable {
m_statisticsQueue->dispatch([this, protectedThis = WTFMove(protectedThis), topDomains = crossThreadCopy(domainsWithDeletedWebsiteData)] () mutable {
RunLoop::main().dispatch([prevalentResourceDomains = crossThreadCopy(prevalentResourceDomains), callback = WTFMove(callback), this, protectedThis = makeRef(*this)] () mutable {
WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, [callback = WTFMove(callback), this, protectedThis = WTFMove(protectedThis)](const HashSet<String>& domainsWithDeletedWebsiteData) mutable {
m_statisticsQueue->dispatch([topDomains = crossThreadCopy(domainsWithDeletedWebsiteData), callback = WTFMove(callback), this, protectedThis = WTFMove(protectedThis)] () mutable {
for (auto& prevalentResourceDomain : topDomains) {
auto& statistic = ensureResourceStatisticsForPrimaryDomain(prevalentResourceDomain);
++statistic.dataRecordsRemoved;
}
setDataRecordsBeingRemoved(false);
callback();
});
});
});
Expand Down Expand Up @@ -264,17 +269,26 @@ void WebResourceLoadStatisticsStore::processStatisticsAndDataRecords()
setPrevalentResource(resourceStatistic);
}
}
removeDataRecords();

if (m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned) {
removeDataRecords([this, protectedThis = makeRef(*this)] {
ASSERT(!RunLoop::isMain());

pruneStatisticsIfNeeded();
pruneStatisticsIfNeeded();
m_persistentStorage.scheduleOrWriteMemoryStore(ResourceLoadStatisticsPersistentStorage::ForceImmediateWrite::No);

if (m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned) {
RunLoop::main().dispatch([] {
WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
RunLoop::main().dispatch([] {
WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
});
});
}
} else {
removeDataRecords([this, protectedThis = makeRef(*this)] {
ASSERT(!RunLoop::isMain());

m_persistentStorage.scheduleOrWriteMemoryStore(ResourceLoadStatisticsPersistentStorage::ForceImmediateWrite::No);
pruneStatisticsIfNeeded();
m_persistentStorage.scheduleOrWriteMemoryStore(ResourceLoadStatisticsPersistentStorage::ForceImmediateWrite::No);
});
}
}

void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&& origins)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
Expand Up @@ -150,7 +150,7 @@ class WebResourceLoadStatisticsStore final : public IPC::Connection::WorkQueueMe
private:
WebResourceLoadStatisticsStore(const String&, Function<void(const String&)>&& testingCallback, bool isEphemeral, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&&, HasStorageAccessForFrameHandler&&, GrantStorageAccessForFrameHandler&&, RemovePrevalentDomainsHandler&&);

void removeDataRecords();
void removeDataRecords(CompletionHandler<void()>&&);

// IPC::MessageReceiver
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
Expand Down

0 comments on commit c0b9b46

Please sign in to comment.