Diff
Modified: trunk/Source/WebKit2/CMakeLists.txt (218999 => 219000)
--- trunk/Source/WebKit2/CMakeLists.txt 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/CMakeLists.txt 2017-06-30 16:22:42 UTC (rev 219000)
@@ -328,7 +328,7 @@
UIProcess/WebProcessLifetimeTracker.cpp
UIProcess/WebProcessPool.cpp
UIProcess/WebProcessProxy.cpp
- UIProcess/WebResourceLoadObserver.cpp
+ UIProcess/WebResourceLoadStatisticsManager.cpp
UIProcess/WebURLSchemeHandler.cpp
UIProcess/WebURLSchemeTask.cpp
UIProcess/WebViewportAttributes.cpp
Modified: trunk/Source/WebKit2/ChangeLog (218999 => 219000)
--- trunk/Source/WebKit2/ChangeLog 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/ChangeLog 2017-06-30 16:22:42 UTC (rev 219000)
@@ -1,3 +1,75 @@
+2017-06-30 Chris Dumez <[email protected]>
+
+ Merge WebResourceLoadStatisticsManager and WebResourceLoadObserver
+ https://bugs.webkit.org/show_bug.cgi?id=174008
+
+ Reviewed by Brent Fulgham.
+
+ Merge WebResourceLoadStatisticsManager and WebResourceLoadObserver. One was basically
+ a proxy to the other.
+
+ * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
+ (WKResourceLoadStatisticsManagerSetPrevalentResource):
+ (WKResourceLoadStatisticsManagerIsPrevalentResource):
+ (WKResourceLoadStatisticsManagerSetHasHadUserInteraction):
+ (WKResourceLoadStatisticsManagerIsHasHadUserInteraction):
+ (WKResourceLoadStatisticsManagerSetGrandfathered):
+ (WKResourceLoadStatisticsManagerIsGrandfathered):
+ (WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin):
+ (WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin):
+ (WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo):
+ (WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction):
+ (WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree):
+ (WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval):
+ (WKResourceLoadStatisticsManagerSetGrandfatheringTime):
+ (WKResourceLoadStatisticsManagerFireDataModificationHandler):
+ (WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler):
+ (WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandlerForOneDomain):
+ (WKResourceLoadStatisticsManagerFireTelemetryHandler):
+ (WKResourceLoadStatisticsManagerSetNotifyPagesWhenDataRecordsWereScanned):
+ (WKResourceLoadStatisticsManagerSetShouldClassifyResourcesBeforeDataRecordsRemoval):
+ (WKResourceLoadStatisticsManagerSetNotifyPagesWhenTelemetryWasCaptured):
+ (WKResourceLoadStatisticsManagerSetShouldSubmitTelemetry):
+ (WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStore):
+ (WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStoreModifiedSinceHours):
+ (WKResourceLoadStatisticsManagerResetToConsistentState):
+ * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
+ * UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm:
+ (WebKit::WebResourceLoadStatisticsManager::registerUserDefaultsIfNeeded):
+ * UIProcess/WebResourceLoadObserver.cpp: Removed.
+ * UIProcess/WebResourceLoadObserver.h: Removed.
+ * UIProcess/WebResourceLoadStatisticsManager.cpp:
+ (WebKit::primaryDomain):
+ (WebKit::WebResourceLoadStatisticsManager::shared):
+ (WebKit::WebResourceLoadStatisticsManager::setStatisticsStore):
+ (WebKit::WebResourceLoadStatisticsManager::setStatisticsQueue):
+ (WebKit::WebResourceLoadStatisticsManager::clearInMemoryStore):
+ (WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore):
+ (WebKit::WebResourceLoadStatisticsManager::logUserInteraction):
+ (WebKit::WebResourceLoadStatisticsManager::clearUserInteraction):
+ (WebKit::WebResourceLoadStatisticsManager::hasHadUserInteraction):
+ (WebKit::WebResourceLoadStatisticsManager::setPrevalentResource):
+ (WebKit::WebResourceLoadStatisticsManager::isPrevalentResource):
+ (WebKit::WebResourceLoadStatisticsManager::clearPrevalentResource):
+ (WebKit::WebResourceLoadStatisticsManager::setGrandfathered):
+ (WebKit::WebResourceLoadStatisticsManager::isGrandfathered):
+ (WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
+ (WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
+ (WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
+ (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction):
+ (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
+ (WebKit::WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval):
+ (WebKit::WebResourceLoadStatisticsManager::setGrandfatheringTime):
+ (WebKit::WebResourceLoadStatisticsManager::fireDataModificationHandler):
+ (WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
+ (WebKit::WebResourceLoadStatisticsManager::fireTelemetryHandler):
+ * UIProcess/WebResourceLoadStatisticsManager.h:
+ * UIProcess/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::removeData):
+ * WebKit2.xcodeproj/project.pbxproj:
+
2017-06-30 Wenson Hsieh <[email protected]>
[iOS DnD] Drag caret rect is incorrectly computed when dropping in editable content in iframes
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp (218999 => 219000)
--- trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp 2017-06-30 16:22:42 UTC (rev 219000)
@@ -28,131 +28,145 @@
#include "WKAPICast.h"
#include "WebResourceLoadStatisticsManager.h"
+#include "WebResourceLoadStatisticsStore.h"
#include <wtf/Seconds.h>
+using namespace WebCore;
using namespace WebKit;
-WKTypeID WKResourceLoadStatisticsManagerGetTypeID()
-{
- return toAPI(WebResourceLoadStatisticsManager::APIType);
-}
-
void WKResourceLoadStatisticsManagerSetPrevalentResource(WKStringRef hostName, bool value)
{
- WebResourceLoadStatisticsManager::setPrevalentResource(toWTFString(hostName), value);
+ if (value)
+ WebResourceLoadStatisticsManager::shared().setPrevalentResource(URL(URL(), toWTFString(hostName)));
+ else
+ WebResourceLoadStatisticsManager::shared().clearPrevalentResource(URL(URL(), toWTFString(hostName)));
}
bool WKResourceLoadStatisticsManagerIsPrevalentResource(WKStringRef hostName)
{
- return WebResourceLoadStatisticsManager::isPrevalentResource(toWTFString(hostName));
+ return WebResourceLoadStatisticsManager::shared().isPrevalentResource(URL(URL(), toWTFString(hostName)));
}
void WKResourceLoadStatisticsManagerSetHasHadUserInteraction(WKStringRef hostName, bool value)
{
- WebResourceLoadStatisticsManager::setHasHadUserInteraction(toWTFString(hostName), value);
+ if (value)
+ WebResourceLoadStatisticsManager::shared().logUserInteraction(URL(URL(), toWTFString(hostName)));
+ else
+ WebResourceLoadStatisticsManager::shared().clearUserInteraction(URL(URL(), toWTFString(hostName)));
}
+// FIXME: This API name is wrong.
bool WKResourceLoadStatisticsManagerIsHasHadUserInteraction(WKStringRef hostName)
{
- return WebResourceLoadStatisticsManager::hasHadUserInteraction(toWTFString(hostName));
+ return WebResourceLoadStatisticsManager::shared().hasHadUserInteraction(URL(URL(), toWTFString(hostName)));
}
void WKResourceLoadStatisticsManagerSetGrandfathered(WKStringRef hostName, bool value)
{
- WebResourceLoadStatisticsManager::setGrandfathered(toWTFString(hostName), value);
+ WebResourceLoadStatisticsManager::shared().setGrandfathered(URL(URL(), toWTFString(hostName)), value);
}
bool WKResourceLoadStatisticsManagerIsGrandfathered(WKStringRef hostName)
{
- return WebResourceLoadStatisticsManager::isGrandfathered(toWTFString(hostName));
+ return WebResourceLoadStatisticsManager::shared().isGrandfathered(URL(URL(), toWTFString(hostName)));
}
void WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
{
- WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(toWTFString(hostName), toWTFString(topFrameHostName));
+ WebResourceLoadStatisticsManager::shared().setSubframeUnderTopFrameOrigin(URL(URL(), toWTFString(hostName)), URL(URL(), toWTFString(topFrameHostName)));
}
void WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
{
- WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(toWTFString(hostName), toWTFString(topFrameHostName));
+ WebResourceLoadStatisticsManager::shared().setSubresourceUnderTopFrameOrigin(URL(URL(), toWTFString(hostName)), URL(URL(), toWTFString(topFrameHostName)));
}
void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo)
{
- WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(toWTFString(hostName), toWTFString(hostNameRedirectedTo));
+ WebResourceLoadStatisticsManager::shared().setSubresourceUniqueRedirectTo(URL(URL(), toWTFString(hostName)), URL(URL(), toWTFString(hostNameRedirectedTo)));
}
void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds)
{
- WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(Seconds { seconds });
+ WebResourceLoadStatisticsManager::shared().setTimeToLiveUserInteraction(Seconds { seconds });
}
void WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree(double seconds)
{
- WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree(Seconds { seconds });
+ WebResourceLoadStatisticsManager::shared().setTimeToLiveCookiePartitionFree(Seconds { seconds });
}
void WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval(double seconds)
{
- WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval(Seconds { seconds });
+ WebResourceLoadStatisticsManager::shared().setMinimumTimeBetweeenDataRecordsRemoval(Seconds { seconds });
}
void WKResourceLoadStatisticsManagerSetGrandfatheringTime(double seconds)
{
- WebResourceLoadStatisticsManager::setGrandfatheringTime(Seconds { seconds });
+ WebResourceLoadStatisticsManager::shared().setGrandfatheringTime(Seconds { seconds });
}
void WKResourceLoadStatisticsManagerFireDataModificationHandler()
{
- WebResourceLoadStatisticsManager::fireDataModificationHandler();
+ WebResourceLoadStatisticsManager::shared().fireDataModificationHandler();
}
void WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler()
{
- WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler();
+ WebResourceLoadStatisticsManager::shared().fireShouldPartitionCookiesHandler();
}
void WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandlerForOneDomain(WKStringRef hostName, bool value)
{
- WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandlerForOneDomain(toWTFString(hostName), value);
+ if (value)
+ WebResourceLoadStatisticsManager::shared().fireShouldPartitionCookiesHandler({ }, { toWTFString(hostName) }, false);
+ else
+ WebResourceLoadStatisticsManager::shared().fireShouldPartitionCookiesHandler({ toWTFString(hostName) }, { }, false);
}
void WKResourceLoadStatisticsManagerFireTelemetryHandler()
{
- WebResourceLoadStatisticsManager::fireTelemetryHandler();
+ WebResourceLoadStatisticsManager::shared().fireTelemetryHandler();
}
void WKResourceLoadStatisticsManagerSetNotifyPagesWhenDataRecordsWereScanned(bool value)
{
- WebResourceLoadStatisticsManager::setNotifyPagesWhenDataRecordsWereScanned(value);
+ WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(value);
}
void WKResourceLoadStatisticsManagerSetShouldClassifyResourcesBeforeDataRecordsRemoval(bool value)
{
- WebResourceLoadStatisticsManager::setShouldClassifyResourcesBeforeDataRecordsRemoval(value);
+ WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(value);
}
void WKResourceLoadStatisticsManagerSetNotifyPagesWhenTelemetryWasCaptured(bool value)
{
- WebResourceLoadStatisticsManager::setNotifyPagesWhenTelemetryWasCaptured(value);
+ WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value);
}
void WKResourceLoadStatisticsManagerSetShouldSubmitTelemetry(bool value)
{
- WebResourceLoadStatisticsManager::setShouldSubmitTelemetry(value);
+ WebResourceLoadStatisticsStore::setShouldSubmitTelemetry(value);
}
void WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStore()
{
- WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore();
+ WebResourceLoadStatisticsManager::shared().clearInMemoryAndPersistentStore();
}
void WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours)
{
- WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStoreModifiedSinceHours(hours);
+ WebResourceLoadStatisticsManager::shared().clearInMemoryAndPersistentStore(std::chrono::system_clock::now() - std::chrono::hours(hours));
}
void WKResourceLoadStatisticsManagerResetToConsistentState()
{
- WebResourceLoadStatisticsManager::resetToConsistentState();
+ WebResourceLoadStatisticsManager::shared().setTimeToLiveUserInteraction(24_h * 30.);
+ WebResourceLoadStatisticsManager::shared().setTimeToLiveCookiePartitionFree(24_h);
+ WebResourceLoadStatisticsManager::shared().setMinimumTimeBetweeenDataRecordsRemoval(1_h);
+ WebResourceLoadStatisticsManager::shared().setGrandfatheringTime(1_h);
+ WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(false);
+ WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(false);
+ WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(true);
+ WebResourceLoadStatisticsManager::shared().clearInMemoryStore();
}
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h (218999 => 219000)
--- trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h 2017-06-30 16:22:42 UTC (rev 219000)
@@ -31,8 +31,6 @@
extern "C" {
#endif
- WK_EXPORT WKTypeID WKResourceLoadStatisticsManagerGetTypeID();
-
WK_EXPORT void WKResourceLoadStatisticsManagerSetPrevalentResource(WKStringRef hostName, bool value);
WK_EXPORT bool WKResourceLoadStatisticsManagerIsPrevalentResource(WKStringRef hostName);
WK_EXPORT void WKResourceLoadStatisticsManagerSetHasHadUserInteraction(WKStringRef hostName, bool value);
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm (218999 => 219000)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm 2017-06-30 16:22:42 UTC (rev 219000)
@@ -27,7 +27,6 @@
#import "WebResourceLoadStatisticsManager.h"
#import "WebPreferencesKeys.h"
-#import "WebResourceLoadObserver.h"
using namespace WebCore;
@@ -43,16 +42,16 @@
double timeToLiveUserInteraction = [[NSUserDefaults standardUserDefaults] doubleForKey: WebPreferencesKey::resourceLoadStatisticsTimeToLiveUserInteractionKey()];
if (timeToLiveUserInteraction > 0 && timeToLiveUserInteraction <= 30 * dayInSeconds)
- WebResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(Seconds { timeToLiveUserInteraction });
+ setTimeToLiveUserInteraction(Seconds { timeToLiveUserInteraction });
double timeToLiveCookiePartitionFree = [[NSUserDefaults standardUserDefaults] doubleForKey: WebPreferencesKey::resourceLoadStatisticsTimeToLiveCookiePartitionFreeKey()];
if (timeToLiveCookiePartitionFree > 0 && timeToLiveCookiePartitionFree <= dayInSeconds)
- WebResourceLoadObserver::sharedObserver().setTimeToLiveCookiePartitionFree(Seconds { timeToLiveCookiePartitionFree });
+ setTimeToLiveCookiePartitionFree(Seconds { timeToLiveCookiePartitionFree });
double grandfatheringTime = [[NSUserDefaults standardUserDefaults] doubleForKey: WebPreferencesKey::resourceLoadStatisticsGrandfatheringTimeKey()];
if (grandfatheringTime > 0 && grandfatheringTime <= 7 * dayInSeconds)
- WebResourceLoadObserver::sharedObserver().setGrandfatheringTime(Seconds { grandfatheringTime });
+ setGrandfatheringTime(Seconds { grandfatheringTime });
});
}
-};
+}
Deleted: trunk/Source/WebKit2/UIProcess/WebResourceLoadObserver.cpp (218999 => 219000)
--- trunk/Source/WebKit2/UIProcess/WebResourceLoadObserver.cpp 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadObserver.cpp 2017-06-30 16:22:42 UTC (rev 219000)
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WebResourceLoadObserver.h"
-
-#include <WebCore/ResourceLoadStatisticsStore.h>
-#include <WebCore/URL.h>
-#include <wtf/CrossThreadCopier.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/RunLoop.h>
-#include <wtf/WorkQueue.h>
-
-namespace WebKit {
-
-using namespace WebCore;
-
-template<typename T> static inline String primaryDomain(const T& value)
-{
- return ResourceLoadStatisticsStore::primaryDomain(value);
-}
-
-WebResourceLoadObserver& WebResourceLoadObserver::sharedObserver()
-{
- static NeverDestroyed<WebResourceLoadObserver> WebResourceLoadObserver;
- return WebResourceLoadObserver;
-}
-
-void WebResourceLoadObserver::setStatisticsStore(Ref<ResourceLoadStatisticsStore>&& store)
-{
- if (m_store && m_queue)
- m_queue = nullptr;
- m_store = WTFMove(store);
-}
-
-void WebResourceLoadObserver::setStatisticsQueue(Ref<WTF::WorkQueue>&& queue)
-{
- ASSERT(!m_queue);
- m_queue = WTFMove(queue);
-}
-
-void WebResourceLoadObserver::clearInMemoryStore()
-{
- if (!m_store)
- return;
-
- ASSERT(m_queue);
- m_queue->dispatch([this] {
- m_store->clearInMemory();
- });
-}
-
-void WebResourceLoadObserver::clearInMemoryAndPersistentStore()
-{
- if (!m_store)
- return;
-
- ASSERT(m_queue);
- m_queue->dispatch([this] {
- m_store->clearInMemoryAndPersistent();
- });
-}
-
-void WebResourceLoadObserver::clearInMemoryAndPersistentStore(std::chrono::system_clock::time_point modifiedSince)
-{
- // For now, be conservative and clear everything regardless of modifiedSince
- UNUSED_PARAM(modifiedSince);
- clearInMemoryAndPersistentStore();
-}
-
-void WebResourceLoadObserver::logUserInteraction(const URL& url)
-{
- if (url.isBlankURL() || url.isEmpty())
- return;
-
- ASSERT(m_queue);
- m_queue->dispatch([this, primaryDomainString = primaryDomain(url).isolatedCopy()] {
- {
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomainString);
- statistics.hadUserInteraction = true;
- statistics.mostRecentUserInteractionTime = WallTime::now();
- }
-
- m_store->fireShouldPartitionCookiesHandler({ primaryDomainString }, { }, false);
- });
-}
-
-void WebResourceLoadObserver::clearUserInteraction(const URL& url)
-{
- if (url.isBlankURL() || url.isEmpty())
- return;
-
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
-
- statistics.hadUserInteraction = false;
- statistics.mostRecentUserInteractionTime = { };
-}
-
-bool WebResourceLoadObserver::hasHadUserInteraction(const URL& url)
-{
- if (url.isBlankURL() || url.isEmpty())
- return false;
-
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
-
- return m_store->hasHadRecentUserInteraction(statistics);
-}
-
-void WebResourceLoadObserver::setPrevalentResource(const URL& url)
-{
- if (url.isBlankURL() || url.isEmpty())
- return;
-
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
-
- statistics.isPrevalentResource = true;
-}
-
-bool WebResourceLoadObserver::isPrevalentResource(const URL& url)
-{
- if (url.isBlankURL() || url.isEmpty())
- return false;
-
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
-
- return statistics.isPrevalentResource;
-}
-
-void WebResourceLoadObserver::clearPrevalentResource(const URL& url)
-{
- if (url.isBlankURL() || url.isEmpty())
- return;
-
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
-
- statistics.isPrevalentResource = false;
-}
-
-void WebResourceLoadObserver::setGrandfathered(const URL& url, bool value)
-{
- if (url.isBlankURL() || url.isEmpty())
- return;
-
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
-
- statistics.grandfathered = value;
-}
-
-bool WebResourceLoadObserver::isGrandfathered(const URL& url)
-{
- if (url.isBlankURL() || url.isEmpty())
- return false;
-
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
-
- return statistics.grandfathered;
-}
-
-void WebResourceLoadObserver::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame)
-{
- if (subframe.isBlankURL() || subframe.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
- return;
-
- ASSERT(m_queue);
- m_queue->dispatch([this, primaryTopFrameDomainString = primaryDomain(topFrame).isolatedCopy(), primarySubFrameDomainString = primaryDomain(subframe).isolatedCopy()] {
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primarySubFrameDomainString);
- statistics.subframeUnderTopFrameOrigins.add(primaryTopFrameDomainString);
- });
-}
-
-void WebResourceLoadObserver::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame)
-{
- if (subresource.isBlankURL() || subresource.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
- return;
-
- ASSERT(m_queue);
- m_queue->dispatch([this, primaryTopFrameDomainString = primaryDomain(topFrame).isolatedCopy(), primarySubresourceDomainString = primaryDomain(subresource).isolatedCopy()] {
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomainString);
- statistics.subresourceUnderTopFrameOrigins.add(primaryTopFrameDomainString);
- });
-}
-
-void WebResourceLoadObserver::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo)
-{
- if (subresource.isBlankURL() || subresource.isEmpty() || hostNameRedirectedTo.isBlankURL() || hostNameRedirectedTo.isEmpty())
- return;
-
- ASSERT(m_queue);
- m_queue->dispatch([this, primaryRedirectDomainString = primaryDomain(hostNameRedirectedTo).isolatedCopy(), primarySubresourceDomainString = primaryDomain(subresource).isolatedCopy()] {
- auto locker = holdLock(m_store->statisticsLock());
- auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomainString);
- statistics.subresourceUniqueRedirectsTo.add(primaryRedirectDomainString);
- });
-}
-
-void WebResourceLoadObserver::setTimeToLiveUserInteraction(Seconds seconds)
-{
- m_store->setTimeToLiveUserInteraction(seconds);
-}
-
-void WebResourceLoadObserver::setTimeToLiveCookiePartitionFree(Seconds seconds)
-{
- m_store->setTimeToLiveCookiePartitionFree(seconds);
-}
-
-void WebResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval(Seconds seconds)
-{
- m_store->setMinimumTimeBetweeenDataRecordsRemoval(seconds);
-}
-
-void WebResourceLoadObserver::setGrandfatheringTime(Seconds seconds)
-{
- m_store->setMinimumTimeBetweeenDataRecordsRemoval(seconds);
-}
-
-void WebResourceLoadObserver::fireDataModificationHandler()
-{
- // Helper function used by testing system. Should only be called from the main thread.
- ASSERT(RunLoop::isMain());
- m_queue->dispatch([this] {
- m_store->fireDataModificationHandler();
- });
-}
-
-void WebResourceLoadObserver::fireShouldPartitionCookiesHandler()
-{
- // Helper function used by testing system. Should only be called from the main thread.
- ASSERT(RunLoop::isMain());
- m_queue->dispatch([this] {
- m_store->fireShouldPartitionCookiesHandler();
- });
-}
-
-void WebResourceLoadObserver::fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)
-{
- // Helper function used by testing system. Should only be called from the main thread.
- ASSERT(RunLoop::isMain());
- m_queue->dispatch([this, domainsToRemove = CrossThreadCopier<Vector<String>>::copy(domainsToRemove), domainsToAdd = CrossThreadCopier<Vector<String>>::copy(domainsToAdd), clearFirst] {
- m_store->fireShouldPartitionCookiesHandler(domainsToRemove, domainsToAdd, clearFirst);
- });
-}
-
-void WebResourceLoadObserver::fireTelemetryHandler()
-{
- // Helper function used by testing system. Should only be called from the main thread.
- ASSERT(RunLoop::isMain());
- m_store->fireTelemetryHandler();
-}
-
-} // namespace WebKit
Deleted: trunk/Source/WebKit2/UIProcess/WebResourceLoadObserver.h (218999 => 219000)
--- trunk/Source/WebKit2/UIProcess/WebResourceLoadObserver.h 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadObserver.h 2017-06-30 16:22:42 UTC (rev 219000)
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <WebCore/ResourceLoadStatisticsStore.h>
-#include <wtf/text/WTFString.h>
-
-namespace WTF {
-class WorkQueue;
-}
-
-namespace WebCore {
-class URL;
-}
-
-namespace WebKit {
-
-class WebResourceLoadObserver {
- friend class NeverDestroyed<WebResourceLoadObserver>;
-public:
- static WebResourceLoadObserver& sharedObserver();
-
- void logUserInteraction(const WebCore::URL&);
- bool hasHadUserInteraction(const WebCore::URL&);
- void clearUserInteraction(const WebCore::URL&);
-
- void setPrevalentResource(const WebCore::URL&);
- bool isPrevalentResource(const WebCore::URL&);
- void clearPrevalentResource(const WebCore::URL&);
- void setGrandfathered(const WebCore::URL&, bool value);
- bool isGrandfathered(const WebCore::URL&);
-
- 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);
-
- void setTimeToLiveUserInteraction(Seconds);
- void setTimeToLiveCookiePartitionFree(Seconds);
- void setMinimumTimeBetweeenDataRecordsRemoval(Seconds);
- void setGrandfatheringTime(Seconds);
-
- void fireDataModificationHandler();
- void fireShouldPartitionCookiesHandler();
- void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
- void fireTelemetryHandler();
-
- void setStatisticsStore(Ref<WebCore::ResourceLoadStatisticsStore>&&);
- void setStatisticsQueue(Ref<WTF::WorkQueue>&&);
- void clearInMemoryStore();
- void clearInMemoryAndPersistentStore();
- void clearInMemoryAndPersistentStore(std::chrono::system_clock::time_point modifiedSince);
-
-private:
- RefPtr<WebCore::ResourceLoadStatisticsStore> m_store;
- RefPtr<WTF::WorkQueue> m_queue;
-};
-
-} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp (218999 => 219000)
--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp 2017-06-30 16:22:42 UTC (rev 219000)
@@ -26,149 +26,257 @@
#include "config.h"
#include "WebResourceLoadStatisticsManager.h"
-#include "Logging.h"
-#include "WebResourceLoadObserver.h"
-#include "WebResourceLoadStatisticsStore.h"
+#include <WebCore/ResourceLoadStatisticsStore.h>
#include <WebCore/URL.h>
+#include <wtf/CrossThreadCopier.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/RunLoop.h>
+#include <wtf/WorkQueue.h>
+namespace WebKit {
+
using namespace WebCore;
-namespace WebKit {
+template<typename T> static inline String primaryDomain(const T& value)
+{
+ return ResourceLoadStatisticsStore::primaryDomain(value);
+}
-void WebResourceLoadStatisticsManager::setPrevalentResource(const String& hostName, bool value)
+WebResourceLoadStatisticsManager& WebResourceLoadStatisticsManager::shared()
{
- if (value)
- WebResourceLoadObserver::sharedObserver().setPrevalentResource(URL(URL(), hostName));
- else
- WebResourceLoadObserver::sharedObserver().clearPrevalentResource(URL(URL(), hostName));
+ static NeverDestroyed<WebResourceLoadStatisticsManager> webResourceLoadStatisticsManager;
+ return webResourceLoadStatisticsManager;
}
-bool WebResourceLoadStatisticsManager::isPrevalentResource(const String& hostName)
+void WebResourceLoadStatisticsManager::setStatisticsStore(Ref<ResourceLoadStatisticsStore>&& store)
{
- return WebResourceLoadObserver::sharedObserver().isPrevalentResource(URL(URL(), hostName));
+ if (m_store && m_queue)
+ m_queue = nullptr;
+ m_store = WTFMove(store);
}
-
-void WebResourceLoadStatisticsManager::setHasHadUserInteraction(const String& hostName, bool value)
+
+void WebResourceLoadStatisticsManager::setStatisticsQueue(Ref<WTF::WorkQueue>&& queue)
{
- if (value)
- WebResourceLoadObserver::sharedObserver().logUserInteraction(URL(URL(), hostName));
- else
- WebResourceLoadObserver::sharedObserver().clearUserInteraction(URL(URL(), hostName));
+ ASSERT(!m_queue);
+ m_queue = WTFMove(queue);
}
-bool WebResourceLoadStatisticsManager::hasHadUserInteraction(const String& hostName)
+void WebResourceLoadStatisticsManager::clearInMemoryStore()
{
- return WebResourceLoadObserver::sharedObserver().hasHadUserInteraction(URL(URL(), hostName));
+ if (!m_store)
+ return;
+
+ ASSERT(m_queue);
+ m_queue->dispatch([this] {
+ m_store->clearInMemory();
+ });
}
-void WebResourceLoadStatisticsManager::setGrandfathered(const String& hostName, bool value)
+void WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore()
{
- WebResourceLoadObserver::sharedObserver().setGrandfathered(URL(URL(), hostName), value);
+ if (!m_store)
+ return;
+
+ ASSERT(m_queue);
+ m_queue->dispatch([this] {
+ m_store->clearInMemoryAndPersistent();
+ });
}
-bool WebResourceLoadStatisticsManager::isGrandfathered(const String& hostName)
+void WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore(std::chrono::system_clock::time_point modifiedSince)
{
- return WebResourceLoadObserver::sharedObserver().isGrandfathered(URL(URL(), hostName));
+ // For now, be conservative and clear everything regardless of modifiedSince
+ UNUSED_PARAM(modifiedSince);
+ clearInMemoryAndPersistentStore();
}
-void WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName)
+void WebResourceLoadStatisticsManager::logUserInteraction(const URL& url)
{
- WebResourceLoadObserver::sharedObserver().setSubframeUnderTopFrameOrigin(URL(URL(), hostName), URL(URL(), topFrameHostName));
+ if (url.isBlankURL() || url.isEmpty())
+ return;
+
+ ASSERT(m_queue);
+ m_queue->dispatch([this, primaryDomainString = primaryDomain(url).isolatedCopy()] {
+ {
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomainString);
+ statistics.hadUserInteraction = true;
+ statistics.mostRecentUserInteractionTime = WallTime::now();
+ }
+
+ m_store->fireShouldPartitionCookiesHandler({ primaryDomainString }, { }, false);
+ });
}
-void WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName)
+void WebResourceLoadStatisticsManager::clearUserInteraction(const URL& url)
{
- WebResourceLoadObserver::sharedObserver().setSubresourceUnderTopFrameOrigin(URL(URL(), hostName), URL(URL(), topFrameHostName));
+ if (url.isBlankURL() || url.isEmpty())
+ return;
+
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+
+ statistics.hadUserInteraction = false;
+ statistics.mostRecentUserInteractionTime = { };
}
-void WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo)
+bool WebResourceLoadStatisticsManager::hasHadUserInteraction(const URL& url)
{
- WebResourceLoadObserver::sharedObserver().setSubresourceUniqueRedirectTo(URL(URL(), hostName), URL(URL(), hostNameRedirectedTo));
+ if (url.isBlankURL() || url.isEmpty())
+ return false;
+
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+
+ return m_store->hasHadRecentUserInteraction(statistics);
}
-void WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(Seconds seconds)
+void WebResourceLoadStatisticsManager::setPrevalentResource(const URL& url)
{
- WebResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(seconds);
+ if (url.isBlankURL() || url.isEmpty())
+ return;
+
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+
+ statistics.isPrevalentResource = true;
}
-void WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree(Seconds seconds)
+bool WebResourceLoadStatisticsManager::isPrevalentResource(const URL& url)
{
- WebResourceLoadObserver::sharedObserver().setTimeToLiveCookiePartitionFree(seconds);
+ if (url.isBlankURL() || url.isEmpty())
+ return false;
+
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+
+ return statistics.isPrevalentResource;
}
-void WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval(Seconds seconds)
+void WebResourceLoadStatisticsManager::clearPrevalentResource(const URL& url)
{
- WebResourceLoadObserver::sharedObserver().setMinimumTimeBetweeenDataRecordsRemoval(seconds);
+ if (url.isBlankURL() || url.isEmpty())
+ return;
+
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+
+ statistics.isPrevalentResource = false;
}
-void WebResourceLoadStatisticsManager::setGrandfatheringTime(Seconds seconds)
+void WebResourceLoadStatisticsManager::setGrandfathered(const URL& url, bool value)
{
- WebResourceLoadObserver::sharedObserver().setGrandfatheringTime(seconds);
+ if (url.isBlankURL() || url.isEmpty())
+ return;
+
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+
+ statistics.grandfathered = value;
}
-void WebResourceLoadStatisticsManager::fireDataModificationHandler()
+bool WebResourceLoadStatisticsManager::isGrandfathered(const URL& url)
{
- WebResourceLoadObserver::sharedObserver().fireDataModificationHandler();
+ if (url.isBlankURL() || url.isEmpty())
+ return false;
+
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+
+ return statistics.grandfathered;
}
-void WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler()
+void WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame)
{
- WebResourceLoadObserver::sharedObserver().fireShouldPartitionCookiesHandler();
+ if (subframe.isBlankURL() || subframe.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
+ return;
+
+ ASSERT(m_queue);
+ m_queue->dispatch([this, primaryTopFrameDomainString = primaryDomain(topFrame).isolatedCopy(), primarySubFrameDomainString = primaryDomain(subframe).isolatedCopy()] {
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primarySubFrameDomainString);
+ statistics.subframeUnderTopFrameOrigins.add(primaryTopFrameDomainString);
+ });
}
-void WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandlerForOneDomain(const String& hostName, bool value)
+void WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame)
{
- if (value)
- WebResourceLoadObserver::sharedObserver().fireShouldPartitionCookiesHandler({ }, {hostName}, false);
- else
- WebResourceLoadObserver::sharedObserver().fireShouldPartitionCookiesHandler({hostName}, { }, false);
+ if (subresource.isBlankURL() || subresource.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
+ return;
+
+ ASSERT(m_queue);
+ m_queue->dispatch([this, primaryTopFrameDomainString = primaryDomain(topFrame).isolatedCopy(), primarySubresourceDomainString = primaryDomain(subresource).isolatedCopy()] {
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomainString);
+ statistics.subresourceUnderTopFrameOrigins.add(primaryTopFrameDomainString);
+ });
}
-void WebResourceLoadStatisticsManager::fireTelemetryHandler()
+void WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo)
{
- WebResourceLoadObserver::sharedObserver().fireTelemetryHandler();
+ if (subresource.isBlankURL() || subresource.isEmpty() || hostNameRedirectedTo.isBlankURL() || hostNameRedirectedTo.isEmpty())
+ return;
+
+ ASSERT(m_queue);
+ m_queue->dispatch([this, primaryRedirectDomainString = primaryDomain(hostNameRedirectedTo).isolatedCopy(), primarySubresourceDomainString = primaryDomain(subresource).isolatedCopy()] {
+ auto locker = holdLock(m_store->statisticsLock());
+ auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomainString);
+ statistics.subresourceUniqueRedirectsTo.add(primaryRedirectDomainString);
+ });
}
-
-void WebResourceLoadStatisticsManager::setNotifyPagesWhenDataRecordsWereScanned(bool value)
+
+void WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(Seconds seconds)
{
- WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(value);
+ m_store->setTimeToLiveUserInteraction(seconds);
}
-void WebResourceLoadStatisticsManager::setNotifyPagesWhenTelemetryWasCaptured(bool value)
+void WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree(Seconds seconds)
{
- WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value);
+ m_store->setTimeToLiveCookiePartitionFree(seconds);
}
-
-void WebResourceLoadStatisticsManager::setShouldSubmitTelemetry(bool value)
+
+void WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval(Seconds seconds)
{
- WebResourceLoadStatisticsStore::setShouldSubmitTelemetry(value);
+ m_store->setMinimumTimeBetweeenDataRecordsRemoval(seconds);
}
-
-void WebResourceLoadStatisticsManager::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value)
+
+void WebResourceLoadStatisticsManager::setGrandfatheringTime(Seconds seconds)
{
- WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(value);
+ m_store->setMinimumTimeBetweeenDataRecordsRemoval(seconds);
}
-void WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore()
+void WebResourceLoadStatisticsManager::fireDataModificationHandler()
{
- WebResourceLoadObserver::sharedObserver().clearInMemoryAndPersistentStore();
+ // Helper function used by testing system. Should only be called from the main thread.
+ ASSERT(RunLoop::isMain());
+ m_queue->dispatch([this] {
+ m_store->fireDataModificationHandler();
+ });
}
-void WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours)
+void WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler()
{
- WebResourceLoadObserver::sharedObserver().clearInMemoryAndPersistentStore(std::chrono::system_clock::now() - std::chrono::hours(hours));
+ // Helper function used by testing system. Should only be called from the main thread.
+ ASSERT(RunLoop::isMain());
+ m_queue->dispatch([this] {
+ m_store->fireShouldPartitionCookiesHandler();
+ });
}
-
-void WebResourceLoadStatisticsManager::resetToConsistentState()
+
+void WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)
{
- WebResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(24_h * 30.);
- WebResourceLoadObserver::sharedObserver().setTimeToLiveCookiePartitionFree(24_h);
- WebResourceLoadObserver::sharedObserver().setMinimumTimeBetweeenDataRecordsRemoval(1_h);
- WebResourceLoadObserver::sharedObserver().setGrandfatheringTime(1_h);
- WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(false);
- WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(false);
- WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(true);
- WebResourceLoadObserver::sharedObserver().clearInMemoryStore();
+ // Helper function used by testing system. Should only be called from the main thread.
+ ASSERT(RunLoop::isMain());
+ m_queue->dispatch([this, domainsToRemove = CrossThreadCopier<Vector<String>>::copy(domainsToRemove), domainsToAdd = CrossThreadCopier<Vector<String>>::copy(domainsToAdd), clearFirst] {
+ m_store->fireShouldPartitionCookiesHandler(domainsToRemove, domainsToAdd, clearFirst);
+ });
}
-
+
+void WebResourceLoadStatisticsManager::fireTelemetryHandler()
+{
+ // Helper function used by testing system. Should only be called from the main thread.
+ ASSERT(RunLoop::isMain());
+ m_store->fireTelemetryHandler();
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h (218999 => 219000)
--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h 2017-06-30 16:22:42 UTC (rev 219000)
@@ -25,50 +25,61 @@
#pragma once
-#include "APIObject.h"
-
-#include <wtf/RefPtr.h>
-#include <wtf/Seconds.h>
+#include <WebCore/ResourceLoadStatisticsStore.h>
#include <wtf/text/WTFString.h>
+namespace WTF {
+class WorkQueue;
+}
+
+namespace WebCore {
+class URL;
+}
+
namespace WebKit {
-class WebResourceLoadStatisticsManager : public API::ObjectImpl<API::Object::Type::WebResourceLoadStatisticsManager> {
+class WebResourceLoadStatisticsManager {
+ friend class NeverDestroyed<WebResourceLoadStatisticsManager>;
public:
- static Ref<WebResourceLoadStatisticsManager> create()
- {
- return adoptRef(*new WebResourceLoadStatisticsManager());
- }
- static void setPrevalentResource(const String& hostName, bool value);
- static bool isPrevalentResource(const String& hostName);
- static void setHasHadUserInteraction(const String& hostName, bool value);
- static bool hasHadUserInteraction(const String& hostName);
- static void setGrandfathered(const String& hostName, bool value);
- static bool isGrandfathered(const String& hostName);
- static void setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
- static void setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
- static void setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo);
- static void setTimeToLiveUserInteraction(Seconds);
- static void setTimeToLiveCookiePartitionFree(Seconds);
- static void setMinimumTimeBetweeenDataRecordsRemoval(Seconds);
- static void setGrandfatheringTime(Seconds);
- static void setReducedTimestampResolution(Seconds);
- static void fireDataModificationHandler();
- static void fireShouldPartitionCookiesHandler();
- static void fireShouldPartitionCookiesHandlerForOneDomain(const String& hostName, bool value);
- static void fireTelemetryHandler();
- static void setNotifyPagesWhenDataRecordsWereScanned(bool);
- static void setNotifyPagesWhenTelemetryWasCaptured(bool value);
- static void setShouldSubmitTelemetry(bool value);
- static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value);
- static void clearInMemoryAndPersistentStore();
- static void clearInMemoryAndPersistentStoreModifiedSinceHours(unsigned);
- static void resetToConsistentState();
+ static WebResourceLoadStatisticsManager& shared();
+
+ void logUserInteraction(const WebCore::URL&);
+ bool hasHadUserInteraction(const WebCore::URL&);
+ void clearUserInteraction(const WebCore::URL&);
+
+ void setPrevalentResource(const WebCore::URL&);
+ bool isPrevalentResource(const WebCore::URL&);
+ void clearPrevalentResource(const WebCore::URL&);
+ void setGrandfathered(const WebCore::URL&, bool value);
+ bool isGrandfathered(const WebCore::URL&);
+
+ 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);
+
+ void setTimeToLiveUserInteraction(Seconds);
+ void setTimeToLiveCookiePartitionFree(Seconds);
+ void setMinimumTimeBetweeenDataRecordsRemoval(Seconds);
+ void setGrandfatheringTime(Seconds);
+
+ void fireDataModificationHandler();
+ void fireShouldPartitionCookiesHandler();
+ void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
+ void fireTelemetryHandler();
+
+ void setStatisticsStore(Ref<WebCore::ResourceLoadStatisticsStore>&&);
+ void setStatisticsQueue(Ref<WTF::WorkQueue>&&);
+ void clearInMemoryStore();
+ void clearInMemoryAndPersistentStore();
+ void clearInMemoryAndPersistentStore(std::chrono::system_clock::time_point modifiedSince);
+
#if PLATFORM(COCOA)
- static void registerUserDefaultsIfNeeded();
+ void registerUserDefaultsIfNeeded();
#endif
private:
+ RefPtr<WebCore::ResourceLoadStatisticsStore> m_store;
+ RefPtr<WTF::WorkQueue> m_queue;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp (218999 => 219000)
--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp 2017-06-30 16:22:42 UTC (rev 219000)
@@ -30,7 +30,6 @@
#include "WebProcessMessages.h"
#include "WebProcessPool.h"
#include "WebProcessProxy.h"
-#include "WebResourceLoadObserver.h"
#include "WebResourceLoadStatisticsManager.h"
#include "WebResourceLoadStatisticsStoreMessages.h"
#include "WebsiteDataFetchOption.h"
@@ -210,8 +209,8 @@
{
ASSERT(RunLoop::isMain());
- WebResourceLoadObserver::sharedObserver().setStatisticsStore(m_resourceLoadStatisticsStore.copyRef());
- WebResourceLoadObserver::sharedObserver().setStatisticsQueue(m_statisticsQueue.copyRef());
+ WebResourceLoadStatisticsManager::shared().setStatisticsStore(m_resourceLoadStatisticsStore.copyRef());
+ WebResourceLoadStatisticsManager::shared().setStatisticsQueue(m_statisticsQueue.copyRef());
m_resourceLoadStatisticsStore->setNotificationCallback([this, protectedThis = makeRef(*this)] {
if (m_resourceLoadStatisticsStore->isEmpty())
return;
@@ -234,7 +233,7 @@
submitTelemetry();
});
#if PLATFORM(COCOA)
- WebResourceLoadStatisticsManager::registerUserDefaultsIfNeeded();
+ WebResourceLoadStatisticsManager::shared().registerUserDefaultsIfNeeded();
#endif
}
Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (218999 => 219000)
--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp 2017-06-30 16:22:42 UTC (rev 219000)
@@ -34,7 +34,7 @@
#include "WebCookieManagerProxy.h"
#include "WebProcessMessages.h"
#include "WebProcessPool.h"
-#include "WebResourceLoadObserver.h"
+#include "WebResourceLoadStatisticsManager.h"
#include "WebResourceLoadStatisticsStore.h"
#include "WebResourceLoadStatisticsStoreMessages.h"
#include "WebsiteData.h"
@@ -816,7 +816,7 @@
#endif
if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics))
- WebResourceLoadObserver::sharedObserver().clearInMemoryAndPersistentStore(modifiedSince);
+ WebResourceLoadStatisticsManager::shared().clearInMemoryAndPersistentStore(modifiedSince);
// There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
callbackAggregator->callIfNeeded();
@@ -1085,7 +1085,7 @@
#endif
if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics))
- WebResourceLoadObserver::sharedObserver().clearInMemoryAndPersistentStore();
+ WebResourceLoadStatisticsManager::shared().clearInMemoryAndPersistentStore();
// There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
callbackAggregator->callIfNeeded();
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (218999 => 219000)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2017-06-30 16:12:17 UTC (rev 218999)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2017-06-30 16:22:42 UTC (rev 219000)
@@ -902,8 +902,6 @@
41FAF5F81E3C1021001AE678 /* LibWebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F61E3C0B47001AE678 /* LibWebRTCResolver.h */; };
41FAF5F91E3C1025001AE678 /* LibWebRTCResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FAF5F71E3C0B47001AE678 /* LibWebRTCResolver.cpp */; };
4450AEC01DC3FAE5009943F2 /* SharedMemoryCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */; };
- 46343B3A1F0599230003F309 /* WebResourceLoadObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4646AB321F0598D4009D07FC /* WebResourceLoadObserver.cpp */; };
- 46343B3B1F0599260003F309 /* WebResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 4646AB331F0598D4009D07FC /* WebResourceLoadObserver.h */; };
463FD4801EB9459600A2982C /* WKProcessTerminationReason.h in Headers */ = {isa = PBXBuildFile; fileRef = 463FD47F1EB9458400A2982C /* WKProcessTerminationReason.h */; settings = {ATTRIBUTES = (Private, ); }; };
463FD4821EB94EC000A2982C /* ProcessTerminationReason.h in Headers */ = {isa = PBXBuildFile; fileRef = 463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */; };
465250E61ECF52DC002025CB /* WebKit2InitializeCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 465250E51ECF52CD002025CB /* WebKit2InitializeCocoa.mm */; };
@@ -3145,8 +3143,6 @@
4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SharedMemoryCocoa.cpp; path = cocoa/SharedMemoryCocoa.cpp; sourceTree = "<group>"; };
463FD47F1EB9458400A2982C /* WKProcessTerminationReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKProcessTerminationReason.h; sourceTree = "<group>"; };
463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessTerminationReason.h; sourceTree = "<group>"; };
- 4646AB321F0598D4009D07FC /* WebResourceLoadObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebResourceLoadObserver.cpp; sourceTree = "<group>"; };
- 4646AB331F0598D4009D07FC /* WebResourceLoadObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebResourceLoadObserver.h; sourceTree = "<group>"; };
465250E51ECF52CD002025CB /* WebKit2InitializeCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKit2InitializeCocoa.mm; sourceTree = "<group>"; };
46A2B6061E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackgroundProcessResponsivenessTimer.cpp; sourceTree = "<group>"; };
46A2B6071E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackgroundProcessResponsivenessTimer.h; sourceTree = "<group>"; };
@@ -6867,8 +6863,6 @@
BC111B0D112F5E4F00337BAB /* WebProcessProxy.cpp */,
BC032DCF10F4389F0058C15A /* WebProcessProxy.h */,
BCEE7AB312817095009827DA /* WebProcessProxy.messages.in */,
- 4646AB321F0598D4009D07FC /* WebResourceLoadObserver.cpp */,
- 4646AB331F0598D4009D07FC /* WebResourceLoadObserver.h */,
6BE969A11E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp */,
6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */,
7A9CD8C01C77984900D9F6C7 /* WebResourceLoadStatisticsStore.cpp */,
@@ -8578,7 +8572,6 @@
0F5947A8187B517600437857 /* RemoteScrollingCoordinatorMessages.h in Headers */,
0F59479B187B3B6000437857 /* RemoteScrollingCoordinatorProxy.h in Headers */,
0F5947A4187B3B7D00437857 /* RemoteScrollingCoordinatorTransaction.h in Headers */,
- 46343B3B1F0599260003F309 /* WebResourceLoadObserver.h in Headers */,
0F59479D187B3B6000437857 /* RemoteScrollingTree.h in Headers */,
A55BA81F1BA25B27007CD33D /* RemoteWebInspectorProxy.h in Headers */,
A55BA8251BA25CFB007CD33D /* RemoteWebInspectorProxyMessages.h in Headers */,
@@ -10295,7 +10288,6 @@
C0337DAE127A24FE008FF4F4 /* WebEvent.cpp in Sources */,
BC032DBA10F4380F0058C15A /* WebEventConversion.cpp in Sources */,
BC111B5E112F629800337BAB /* WebEventFactory.mm in Sources */,
- 46343B3A1F0599230003F309 /* WebResourceLoadObserver.cpp in Sources */,
BCE469531214E6CB000B98EB /* WebFormClient.cpp in Sources */,
BCE469551214E6CB000B98EB /* WebFormSubmissionListenerProxy.cpp in Sources */,
BC111ADD112F5B9300337BAB /* WebFrame.cpp in Sources */,