Title: [233367] trunk/Source/WebKit
Revision
233367
Author
[email protected]
Date
2018-06-29 13:11:39 -0700 (Fri, 29 Jun 2018)

Log Message

Resource Load Statistics: Don't create a WebResourceLoadStatisticsStore for ephemeral sessions
https://bugs.webkit.org/show_bug.cgi?id=187154
<rdar://problem/41487250>

Reviewed by Brent Fulgham and Chris Dumez.

Most of the changes in this patch remove the boolean parameter for tracking
ephemeral sessions and the IsReadOnly enum.

* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _setResourceLoadStatisticsTestingCallback:]):
    Now returns early for ephemeral sessions.
* UIProcess/ResourceLoadStatisticsPersistentStorage.cpp:
(WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
(WebKit::ResourceLoadStatisticsPersistentStorage::writeMemoryStoreToDisk):
(WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
* UIProcess/ResourceLoadStatisticsPersistentStorage.h:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
* UIProcess/WebResourceLoadStatisticsStore.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
    Now returns early for ephemeral sessions.
(WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (233366 => 233367)


--- trunk/Source/WebKit/ChangeLog	2018-06-29 19:24:45 UTC (rev 233366)
+++ trunk/Source/WebKit/ChangeLog	2018-06-29 20:11:39 UTC (rev 233367)
@@ -1,3 +1,30 @@
+2018-06-29  John Wilander  <[email protected]>
+
+        Resource Load Statistics: Don't create a WebResourceLoadStatisticsStore for ephemeral sessions
+        https://bugs.webkit.org/show_bug.cgi?id=187154
+        <rdar://problem/41487250>
+
+        Reviewed by Brent Fulgham and Chris Dumez.
+
+        Most of the changes in this patch remove the boolean parameter for tracking
+        ephemeral sessions and the IsReadOnly enum.
+
+        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+        (-[WKWebsiteDataStore _setResourceLoadStatisticsTestingCallback:]):
+            Now returns early for ephemeral sessions.
+        * UIProcess/ResourceLoadStatisticsPersistentStorage.cpp:
+        (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
+        (WebKit::ResourceLoadStatisticsPersistentStorage::writeMemoryStoreToDisk):
+        (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
+        * UIProcess/ResourceLoadStatisticsPersistentStorage.h:
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
+            Now returns early for ephemeral sessions.
+        (WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback):
+
 2018-06-29  Chris Dumez  <[email protected]>
 
         Stop using lambdas for WebResourceLoadStatisticsStore to interact with its WebsiteDataStore

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (233366 => 233367)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm	2018-06-29 19:24:45 UTC (rev 233366)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm	2018-06-29 20:11:39 UTC (rev 233367)
@@ -321,6 +321,9 @@
 
 - (void)_setResourceLoadStatisticsTestingCallback:(void (^)(WKWebsiteDataStore *, NSString *))callback
 {
+    if (!_websiteDataStore->isPersistent())
+        return;
+
     if (callback) {
         _websiteDataStore->websiteDataStore().enableResourceLoadStatisticsAndSetTestingCallback([callback = makeBlockPtr(callback), self](const String& event) {
             callback(self, (NSString *)event);

Modified: trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.cpp (233366 => 233367)


--- trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.cpp	2018-06-29 19:24:45 UTC (rev 233366)
+++ trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.cpp	2018-06-29 20:11:39 UTC (rev 233367)
@@ -82,11 +82,10 @@
     return KeyedDecoder::decoder(reinterpret_cast<const uint8_t*>(buffer.data()), buffer.size());
 }
 
-ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage(ResourceLoadStatisticsMemoryStore& memoryStore, WorkQueue& workQueue, const String& storageDirectoryPath, IsReadOnly isReadOnly)
+ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage(ResourceLoadStatisticsMemoryStore& memoryStore, WorkQueue& workQueue, const String& storageDirectoryPath)
     : m_memoryStore(memoryStore)
     , m_workQueue(workQueue)
     , m_storageDirectoryPath(storageDirectoryPath)
-    , m_isReadOnly(isReadOnly)
 {
     ASSERT(!RunLoop::isMain());
 
@@ -247,7 +246,6 @@
 void ResourceLoadStatisticsPersistentStorage::writeMemoryStoreToDisk()
 {
     ASSERT(!RunLoop::isMain());
-    RELEASE_ASSERT(m_isReadOnly != IsReadOnly::Yes);
 
     m_hasPendingWrite = false;
     stopMonitoringDisk();
@@ -282,8 +280,6 @@
 void ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore(ForceImmediateWrite forceImmediateWrite)
 {
     ASSERT(!RunLoop::isMain());
-    if (m_isReadOnly == IsReadOnly::Yes)
-        return;
 
     auto timeSinceLastWrite = MonotonicTime::now() - m_lastStatisticsWriteTime;
     if (forceImmediateWrite != ForceImmediateWrite::Yes && timeSinceLastWrite < minimumWriteInterval) {

Modified: trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.h (233366 => 233367)


--- trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.h	2018-06-29 19:24:45 UTC (rev 233366)
+++ trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.h	2018-06-29 20:11:39 UTC (rev 233367)
@@ -44,8 +44,7 @@
 // Can only be constructed / destroyed / used from the WebResourceLoadStatisticsStore's statistic queue.
 class ResourceLoadStatisticsPersistentStorage : public CanMakeWeakPtr<ResourceLoadStatisticsPersistentStorage> {
 public:
-    enum class IsReadOnly { No, Yes };
-    ResourceLoadStatisticsPersistentStorage(ResourceLoadStatisticsMemoryStore&, WorkQueue&, const String& storageDirectoryPath, IsReadOnly);
+    ResourceLoadStatisticsPersistentStorage(ResourceLoadStatisticsMemoryStore&, WorkQueue&, const String& storageDirectoryPath);
     ~ResourceLoadStatisticsPersistentStorage();
 
     void clear();
@@ -72,7 +71,6 @@
     std::unique_ptr<WebCore::FileMonitor> m_fileMonitor;
     WallTime m_lastStatisticsFileSyncTime;
     MonotonicTime m_lastStatisticsWriteTime;
-    IsReadOnly m_isReadOnly { IsReadOnly::No };
     bool m_hasPendingWrite { false };
 };
 

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (233366 => 233367)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2018-06-29 19:24:45 UTC (rev 233366)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2018-06-29 20:11:39 UTC (rev 233367)
@@ -118,9 +118,9 @@
 {
     ASSERT(RunLoop::isMain());
 
-    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), isPersistent = websiteDataStore.isPersistent(), resourceLoadStatisticsDirectory = websiteDataStore.resolvedResourceLoadStatisticsDirectory().isolatedCopy()] {
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), resourceLoadStatisticsDirectory = websiteDataStore.resolvedResourceLoadStatisticsDirectory().isolatedCopy()] {
         m_memoryStore = std::make_unique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue);
-        m_persistentStorage = std::make_unique<ResourceLoadStatisticsPersistentStorage>(*m_memoryStore, m_statisticsQueue, resourceLoadStatisticsDirectory, isPersistent ? ResourceLoadStatisticsPersistentStorage::IsReadOnly::No : ResourceLoadStatisticsPersistentStorage::IsReadOnly::Yes);
+        m_persistentStorage = std::make_unique<ResourceLoadStatisticsPersistentStorage>(*m_memoryStore, m_statisticsQueue, resourceLoadStatisticsDirectory);
     });
 
     m_statisticsQueue->dispatchAfter(5_s, [this, protectedThis = makeRef(*this)] {

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (233366 => 233367)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2018-06-29 19:24:45 UTC (rev 233366)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2018-06-29 20:11:39 UTC (rev 233367)
@@ -1441,7 +1441,7 @@
 
 void WebsiteDataStore::setResourceLoadStatisticsEnabled(bool enabled)
 {
-    if (enabled == resourceLoadStatisticsEnabled())
+    if (m_sessionID.isEphemeral() || enabled == resourceLoadStatisticsEnabled())
         return;
 
     if (enabled) {
@@ -1471,6 +1471,8 @@
 
 void WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback)
 {
+    ASSERT(!m_sessionID.isEphemeral());
+
     if (m_resourceLoadStatistics) {
         m_resourceLoadStatistics->setStatisticsTestingCallback(WTFMove(callback));
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to