[WK2] ResourceLoadStatistics should batch its writes
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Jul 2017 21:59:33 +0000 (21:59 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Jul 2017 21:59:33 +0000 (21:59 +0000)
commitfae09ed164d19d050496758f6dd9a4979f89cef3
tree933fe62ba43ffbe2f3d0182e4bec486817ce7a0b
parent8b1cd4f59ef3392d2aad6a66e76cfdf93cf8a000
[WK2] ResourceLoadStatistics should batch its writes
https://bugs.webkit.org/show_bug.cgi?id=174111
<rdar://problem/33115894>

Reviewed by Chris Dumez.

Revise the data writing operation to only write on a specific interval (currently
set to 5 minutes).

Also make 'writeStoreToDisk' simpler to use by moving the deleting (before write) and
creating (after write) of the FileMonitor into the method, rather than requiring this
knowledge in multiple places.

Make sure that we write our statistics file out before exiting so that we do not
lose any data if we exit before the five-minute window has elapsed.

* UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
(WebKit::ResourceLoadStatisticsStore::setWritePersistentStoreCallback): Deleted.
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords): Remove the stop
and start monitoring into 'writeStoreToDisk'. Also check if enough time has elapsed since
the last write to commit to disk.
(WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver): Remove the
stop and start monitoring into 'writeStoreToDisk'.
(WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk): Add the stop and start monitoring
commands here, so callers don't have to know to do so.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.cpp
Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h