Changeset 240243 in webkit
- Timestamp:
- Jan 21, 2019 2:28:04 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r240240 r240243 1 2019-01-21 Brent Fulgham <bfulgham@apple.com> 2 3 Implement message handlers for NetworkProcess-based ResourceLoadStatistics 4 https://bugs.webkit.org/show_bug.cgi?id=193556 5 <rdar://problem/47368501> 6 7 Reviewed by Alex Christensen. 8 9 This patch adds a new observer callback used to message the NetworkProcess when 10 user interaction events are received. This is needed when the ResourceLoadStatistics 11 data is not being managed by the UIProcess. 12 13 Tested by existing ResourceLoadStatistics and storageAccess tests. 14 15 * loader/ResourceLoadObserver.cpp: 16 (WebCore::ResourceLoadObserver::setLogUserInteractionNotificationCallback): 17 (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution): 18 * loader/ResourceLoadObserver.h: 19 * platform/network/cocoa/NetworkStorageSessionCocoa.mm: 20 (WebCore::NetworkStorageSession::setCookiesFromDOM): 21 1 22 2019-01-21 Zalan Bujtas <zalan@apple.com> 2 23 -
trunk/Source/WebCore/loader/ResourceLoadObserver.cpp
r239888 r240243 70 70 } 71 71 72 void ResourceLoadObserver::setLogUserInteractionNotificationCallback(Function<void(PAL::SessionID, const String&)>&& callback) 73 { 74 ASSERT(!m_logUserInteractionNotificationCallback); 75 m_logUserInteractionNotificationCallback = WTFMove(callback); 76 } 77 72 78 ResourceLoadObserver::ResourceLoadObserver() 73 79 : m_notificationTimer(*this, &ResourceLoadObserver::notifyObserver) … … 191 197 } 192 198 } 199 200 // FIXME(193297): Uncomment this line when ResourceLoadStatistics are no longer gathered in the UI Process. 201 // m_logUserInteractionNotificationCallback(document.sessionID(), domain); 193 202 #endif 194 203 -
trunk/Source/WebCore/loader/ResourceLoadObserver.h
r238771 r240243 40 40 } 41 41 42 namespace PAL { 43 class SessionID; 44 } 45 42 46 namespace WebCore { 43 47 … … 70 74 WEBCORE_EXPORT void setNotificationCallback(WTF::Function<void (Vector<ResourceLoadStatistics>&&)>&&); 71 75 WEBCORE_EXPORT void setRequestStorageAccessUnderOpenerCallback(WTF::Function<void(const String&, uint64_t, const String&)>&&); 76 WEBCORE_EXPORT void setLogUserInteractionNotificationCallback(WTF::Function<void(PAL::SessionID, const String&)>&&); 72 77 73 78 WEBCORE_EXPORT void notifyObserver(); … … 96 101 WTF::Function<void (Vector<ResourceLoadStatistics>&&)> m_notificationCallback; 97 102 WTF::Function<void(const String&, uint64_t, const String&)> m_requestStorageAccessUnderOpenerCallback; 103 WTF::Function<void(PAL::SessionID, const String&)> m_logUserInteractionNotificationCallback; 98 104 Timer m_notificationTimer; 99 105 #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED -
trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm
r240014 r240243 406 406 RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, m_ageCapForClientSideCookies); 407 407 #else 408 RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, false);408 RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, WTF::nullopt); 409 409 #endif 410 410 ASSERT([filteredCookies.get() count] <= 1); -
trunk/Source/WebKit/ChangeLog
r240237 r240243 1 2019-01-21 Brent Fulgham <bfulgham@apple.com> 2 3 Implement message handlers for NetworkProcess-based ResourceLoadStatistics 4 https://bugs.webkit.org/show_bug.cgi?id=193556 5 <rdar://problem/47368501> 6 7 Reviewed by Alex Christensen. 8 9 This patch adds a number of sibling methods for tracking ResourceLoadStatistics when the 10 observations are being handled in the NetworkProcess, rather than the UIProcess. The 11 original versions of these methods will be removed as part of Bug 193303. 12 13 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: 14 (WebKit::ResourceLoadStatisticsMemoryStore::removeDataRecords): 15 (WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords): 16 (WebKit::ResourceLoadStatisticsMemoryStore::grandfatherExistingWebsiteData): 17 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h: 18 (WebKit::ResourceLoadStatisticsMemoryStore::store const): 19 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 20 (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned): 21 (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenTelemetryWasCaptured): 22 (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore): 23 (WebKit::WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode): 24 (WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing): 25 (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess): 26 (WebKit::WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler): 27 (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess): 28 (WebKit::WebResourceLoadStatisticsStore::logUserInteraction): 29 (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction): 30 (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction): 31 (WebKit::WebResourceLoadStatisticsStore::setLastSeen): 32 (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource): 33 (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource): 34 (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource): 35 (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource): 36 (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder): 37 (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder): 38 (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo): 39 (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource): 40 (WebKit::WebResourceLoadStatisticsStore::setGrandfathered): 41 (WebKit::WebResourceLoadStatisticsStore::isGrandfathered): 42 (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin): 43 (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin): 44 (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo): 45 (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom): 46 (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo): 47 (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom): 48 (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction): 49 (WebKit::WebResourceLoadStatisticsStore::logTestingEvent): 50 (WebKit::WebResourceLoadStatisticsStore::notifyResourceLoadStatisticsProcessed): 51 (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): 52 (WebKit::WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsWithWebsiteData): 53 (WebKit::WebResourceLoadStatisticsStore::sendDiagnosticMessageWithValue const): 54 (WebKit::WebResourceLoadStatisticsStore::notifyPageStatisticsTelemetryFinished const): 55 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: 56 * NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp: 57 (WebKit::submitTopList): 58 (WebKit::submitTopLists): 59 (WebKit::notifyPages): 60 (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit): 61 (WebKit::nonEphemeralWebPageProxy): Deleted. 62 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 63 (WebKit::NetworkConnectionToWebProcess::logUserInteraction): 64 * NetworkProcess/NetworkConnectionToWebProcess.h: 65 * NetworkProcess/NetworkConnectionToWebProcess.messages.in: 66 * NetworkProcess/NetworkProcess.cpp: 67 (WebKit::NetworkProcess::dumpResourceLoadStatistics): 68 (WebKit::NetworkProcess::isGrandfathered): 69 (WebKit::NetworkProcess::isPrevalentResource): 70 (WebKit::NetworkProcess::isVeryPrevalentResource): 71 (WebKit::NetworkProcess::setGrandfathered): 72 (WebKit::NetworkProcess::setPrevalentResource): 73 (WebKit::NetworkProcess::setPrevalentResourceForDebugMode): 74 (WebKit::NetworkProcess::setVeryPrevalentResource): 75 (WebKit::NetworkProcess::clearPrevalentResource): 76 (WebKit::NetworkProcess::submitTelemetry): 77 (WebKit::NetworkProcess::scheduleCookieBlockingUpdate): 78 (WebKit::NetworkProcess::scheduleClearInMemoryAndPersistent): 79 (WebKit::NetworkProcess::resetParametersToDefaultValues): 80 (WebKit::NetworkProcess::scheduleStatisticsAndDataRecordsProcessing): 81 (WebKit::NetworkProcess::setNotifyPagesWhenDataRecordsWereScanned): 82 (WebKit::NetworkProcess::setNotifyPagesWhenTelemetryWasCaptured): 83 (WebKit::NetworkProcess::setSubframeUnderTopFrameOrigin): 84 (WebKit::NetworkProcess::isRegisteredAsRedirectingTo): 85 (WebKit::NetworkProcess::isRegisteredAsSubFrameUnder): 86 (WebKit::NetworkProcess::setSubresourceUnderTopFrameOrigin): 87 (WebKit::NetworkProcess::setSubresourceUniqueRedirectTo): 88 (WebKit::NetworkProcess::setSubresourceUniqueRedirectFrom): 89 (WebKit::NetworkProcess::isRegisteredAsSubresourceUnder): 90 (WebKit::NetworkProcess::setTopFrameUniqueRedirectTo): 91 (WebKit::NetworkProcess::setTopFrameUniqueRedirectFrom): 92 (WebKit::NetworkProcess::setLastSeen): 93 (WebKit::NetworkProcess::hasStorageAccess): 94 (WebKit::NetworkProcess::requestStorageAccess): 95 (WebKit::NetworkProcess::grantStorageAccess): 96 (WebKit::NetworkProcess::logUserInteraction): 97 (WebKit::NetworkProcess::hadUserInteraction): 98 (WebKit::NetworkProcess::clearUserInteraction): 99 (WebKit::NetworkProcess::setGrandfatheringTime): 100 (WebKit::NetworkProcess::setMaxStatisticsEntries): 101 (WebKit::NetworkProcess::setMinimumTimeBetweenDataRecordsRemoval): 102 (WebKit::NetworkProcess::setPruneEntriesDownTo): 103 (WebKit::NetworkProcess::setTimeToLiveUserInteraction): 104 (WebKit::NetworkProcess::setShouldClassifyResourcesBeforeDataRecordsRemoval): 105 (WebKit::NetworkProcess::setResourceLoadStatisticsEnabled): 106 (WebKit::NetworkProcess::setResourceLoadStatisticsDebugMode): 107 (WebKit::NetworkProcess::resetCacheMaxAgeCapForPrevalentResources): 108 (WebKit::NetworkProcess::deleteWebsiteData): 109 (WebKit::filterForTopLevelDomains): 110 (WebKit::NetworkProcess::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): 111 (WebKit::NetworkProcess::topPrivatelyControlledDomainsWithWebsiteData): 112 * NetworkProcess/NetworkProcess.h: 113 * NetworkProcess/NetworkProcess.messages.in: 114 * NetworkProcess/NetworkSession.cpp: 115 (WebKit::NetworkSession::setResourceLoadStatisticsEnabled): 116 (WebKit::NetworkSession::notifyResourceLoadStatisticsProcessed): 117 (WebKit::NetworkSession::logDiagnosticMessageWithValue): 118 (WebKit::NetworkSession::notifyPageStatisticsTelemetryFinished): 119 (WebKit::NetworkSession::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): 120 (WebKit::NetworkSession::topPrivatelyControlledDomainsWithWebsiteData): 121 (WebKit::NetworkSession::enableResourceLoadStatistics): Deleted. 122 * NetworkProcess/NetworkSession.h: 123 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 124 (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): 125 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 126 (WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler): 127 (WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode): 128 (WKWebsiteDataStoreSetStatisticsLastSeen): 129 (WKWebsiteDataStoreSetStatisticsPrevalentResource): 130 (WKWebsiteDataStoreSetStatisticsVeryPrevalentResource): 131 (WKWebsiteDataStoreDumpResourceLoadStatistics): 132 (WKWebsiteDataStoreIsStatisticsPrevalentResource): 133 (WKWebsiteDataStoreIsStatisticsVeryPrevalentResource): 134 (WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnder): 135 (WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder): 136 (WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo): 137 (WKWebsiteDataStoreSetStatisticsHasHadUserInteraction): 138 (WKWebsiteDataStoreIsStatisticsHasHadUserInteraction): 139 (WKWebsiteDataStoreSetStatisticsGrandfathered): 140 (WKWebsiteDataStoreIsStatisticsGrandfathered): 141 (WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin): 142 (WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin): 143 (WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo): 144 (WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom): 145 (WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo): 146 (WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom): 147 (WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction): 148 (WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords): 149 (WKWebsiteDataStoreStatisticsUpdateCookieBlocking): 150 (WKWebsiteDataStoreStatisticsSubmitTelemetry): 151 (WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned): 152 (WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval): 153 (WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured): 154 (WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval): 155 (WKWebsiteDataStoreSetStatisticsGrandfatheringTime): 156 (WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries): 157 (WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo): 158 (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore): 159 (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours): 160 (WKWebsiteDataStoreStatisticsResetToConsistentState): 161 * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: 162 (-[WKWebsiteDataStore _setResourceLoadStatisticsTestingCallback:]): 163 * UIProcess/Network/NetworkProcessProxy.cpp: 164 (WebKit::NetworkProcessProxy::clearCallbackStates): 165 (WebKit::NetworkProcessProxy::didClose): 166 (WebKit::nonEphemeralWebPageProxy): 167 (WebKit::NetworkProcessProxy::logGlobalDiagnosticMessageWithValue): 168 (WebKit::NetworkProcessProxy::dumpResourceLoadStatistics): 169 (WebKit::NetworkProcessProxy::didDumpResourceLoadStatistics): 170 (WebKit::NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor): 171 (WebKit::NetworkProcessProxy::didUpdateBlockCookies): 172 (WebKit::NetworkProcessProxy::isPrevalentResource): 173 (WebKit::NetworkProcessProxy::isPrevalentResourceResult): 174 (WebKit::NetworkProcessProxy::isVeryPrevalentResource): 175 (WebKit::NetworkProcessProxy::setPrevalentResource): 176 (WebKit::NetworkProcessProxy::setPrevalentResourceForDebugMode): 177 (WebKit::NetworkProcessProxy::setVeryPrevalentResource): 178 (WebKit::NetworkProcessProxy::didSetResourceLoadStatisticData): 179 (WebKit::NetworkProcessProxy::setLastSeen): 180 (WebKit::NetworkProcessProxy::clearPrevalentResource): 181 (WebKit::NetworkProcessProxy::scheduleCookieBlockingUpdate): 182 (WebKit::NetworkProcessProxy::didScheduleCookieBlockingUpdate): 183 (WebKit::NetworkProcessProxy::scheduleClearInMemoryAndPersistent): 184 (WebKit::NetworkProcessProxy::didScheduleStatisticsProcessing): 185 (WebKit::NetworkProcessProxy::scheduleStatisticsAndDataRecordsProcessing): 186 (WebKit::NetworkProcessProxy::logUserInteraction): 187 (WebKit::NetworkProcessProxy::hasHadUserInteraction): 188 (WebKit::NetworkProcessProxy::didHaveUserInteraction): 189 (WebKit::NetworkProcessProxy::clearUserInteraction): 190 (WebKit::NetworkProcessProxy::setAgeCapForClientSideCookies): 191 (WebKit::NetworkProcessProxy::didSetAgeCapForClientSideCookies): 192 (WebKit::NetworkProcessProxy::setTimeToLiveUserInteraction): 193 (WebKit::NetworkProcessProxy::didUpdateRuntimeSettings): 194 (WebKit::NetworkProcessProxy::setNotifyPagesWhenTelemetryWasCaptured): 195 (WebKit::NetworkProcessProxy::setNotifyPagesWhenDataRecordsWereScanned): 196 (WebKit::NetworkProcessProxy::setSubframeUnderTopFrameOrigin): 197 (WebKit::NetworkProcessProxy::isRegisteredAsRedirectingTo): 198 (WebKit::NetworkProcessProxy::didIsRegisteredAsRedirectingTo): 199 (WebKit::NetworkProcessProxy::isRegisteredAsSubFrameUnder): 200 (WebKit::NetworkProcessProxy::didIsRegisteredAsSubFrameUnder): 201 (WebKit::NetworkProcessProxy::setSubresourceUnderTopFrameOrigin): 202 (WebKit::NetworkProcessProxy::isRegisteredAsSubresourceUnder): 203 (WebKit::NetworkProcessProxy::didIsRegisteredAsSubresourceUnder): 204 (WebKit::NetworkProcessProxy::setSubresourceUniqueRedirectTo): 205 (WebKit::NetworkProcessProxy::setSubresourceUniqueRedirectFrom): 206 (WebKit::NetworkProcessProxy::setTopFrameUniqueRedirectTo): 207 (WebKit::NetworkProcessProxy::setTopFrameUniqueRedirectFrom): 208 (WebKit::NetworkProcessProxy::isGrandfathered): 209 (WebKit::NetworkProcessProxy::didIsGrandfathered): 210 (WebKit::NetworkProcessProxy::setGrandfathered): 211 (WebKit::NetworkProcessProxy::hasStorageAccess): 212 (WebKit::NetworkProcessProxy::requestStorageAccess): 213 (WebKit::NetworkProcessProxy::grantStorageAccess): 214 (WebKit::NetworkProcessProxy::storageAccessRequestResult): 215 (WebKit::NetworkProcessProxy::storageAccessOperationResult): 216 (WebKit::NetworkProcessProxy::didRemoveAllStorageAccess): 217 (WebKit::NetworkProcessProxy::didSetCacheMaxAgeCapForPrevalentResources): 218 (WebKit::NetworkProcessProxy::setCacheMaxAgeCap): 219 (WebKit::NetworkProcessProxy::setGrandfatheringTime): 220 (WebKit::NetworkProcessProxy::setMaxStatisticsEntries): 221 (WebKit::NetworkProcessProxy::setMinimumTimeBetweenDataRecordsRemoval): 222 (WebKit::NetworkProcessProxy::setPruneEntriesDownTo): 223 (WebKit::NetworkProcessProxy::setShouldClassifyResourcesBeforeDataRecordsRemoval): 224 (WebKit::NetworkProcessProxy::setResourceLoadStatisticsDebugMode): 225 (WebKit::NetworkProcessProxy::resetParametersToDefaultValues): 226 (WebKit::NetworkProcessProxy::submitTelemetry): 227 (WebKit::NetworkProcessProxy::notifyResourceLoadStatisticsProcessed): 228 (WebKit::NetworkProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished): 229 (WebKit::NetworkProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished): 230 (WebKit::NetworkProcessProxy::notifyResourceLoadStatisticsTelemetryFinished): 231 (WebKit::NetworkProcessProxy::didLogUserInteraction): Deleted. 232 (WebKit::NetworkProcessProxy::didResetCacheMaxAgeCapForPrevalentResources): Deleted. 233 * UIProcess/Network/NetworkProcessProxy.h: 234 * UIProcess/Network/NetworkProcessProxy.messages.in: 235 * UIProcess/WebPageProxy.cpp: 236 (WebKit::WebPageProxy::nonEphemeralWebPageProxy): 237 * UIProcess/WebPageProxy.h: 238 * UIProcess/WebProcessPool.cpp: 239 (WebKit::WebProcessPool::ensureNetworkProcess): 240 * UIProcess/WebProcessProxy.cpp: 241 (WebKit::WebProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished): 242 (WebKit::WebProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished): 243 * UIProcess/WebProcessProxy.h: 244 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 245 (WebKit::WebsiteDataStore::parameters): 246 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 247 (WebKit::WebsiteDataStore::removeData): 248 (WebKit::WebsiteDataStore::setMaxStatisticsEntries): 249 (WebKit::WebsiteDataStore::setPruneEntriesDownTo): 250 (WebKit::WebsiteDataStore::setGrandfatheringTime): 251 (WebKit::WebsiteDataStore::setCacheMaxAgeCap): 252 (WebKit::WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval): 253 (WebKit::WebsiteDataStore::dumpResourceLoadStatistics): 254 (WebKit::WebsiteDataStore::isPrevalentResource): 255 (WebKit::WebsiteDataStore::setPrevalentResource): 256 (WebKit::WebsiteDataStore::setPrevalentResourceForDebugMode): 257 (WebKit::WebsiteDataStore::isVeryPrevalentResource): 258 (WebKit::WebsiteDataStore::setVeryPrevalentResource): 259 (WebKit::WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval): 260 (WebKit::WebsiteDataStore::setSubframeUnderTopFrameOrigin): 261 (WebKit::WebsiteDataStore::isRegisteredAsSubFrameUnder): 262 (WebKit::WebsiteDataStore::setSubresourceUnderTopFrameOrigin): 263 (WebKit::WebsiteDataStore::isRegisteredAsSubresourceUnder): 264 (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectTo): 265 (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectFrom): 266 (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectTo): 267 (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectFrom): 268 (WebKit::WebsiteDataStore::isRegisteredAsRedirectingTo): 269 (WebKit::WebsiteDataStore::clearPrevalentResource): 270 (WebKit::WebsiteDataStore::resetParametersToDefaultValues): 271 (WebKit::WebsiteDataStore::submitTelemetry): 272 (WebKit::WebsiteDataStore::scheduleClearInMemoryAndPersistent): 273 (WebKit::WebsiteDataStore::scheduleCookieBlockingUpdate): 274 (WebKit::WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing): 275 (WebKit::WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor): 276 (WebKit::WebsiteDataStore::setAgeCapForClientSideCookies): 277 (WebKit::WebsiteDataStore::setLastSeen): 278 (WebKit::WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned): 279 (WebKit::WebsiteDataStore::setNotifyPagesWhenTelemetryWasCaptured): 280 (WebKit::WebsiteDataStore::hasStorageAccessForFrameHandler): 281 (WebKit::WebsiteDataStore::getAllStorageAccessEntries): 282 (WebKit::WebsiteDataStore::grantStorageAccessHandler): 283 (WebKit::WebsiteDataStore::removeAllStorageAccessHandler): 284 (WebKit::WebsiteDataStore::removePrevalentDomains): 285 (WebKit::WebsiteDataStore::hasStorageAccess): 286 (WebKit::WebsiteDataStore::requestStorageAccess): 287 (WebKit::WebsiteDataStore::grantStorageAccess): 288 (WebKit::WebsiteDataStore::setTimeToLiveUserInteraction): 289 (WebKit::WebsiteDataStore::logUserInteraction): 290 (WebKit::WebsiteDataStore::hasHadUserInteraction): 291 (WebKit::WebsiteDataStore::clearUserInteraction): 292 (WebKit::WebsiteDataStore::isGrandfathered): 293 (WebKit::WebsiteDataStore::setGrandfathered): 294 (WebKit::WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources): 295 (WebKit::WebsiteDataStore::resetCacheMaxAgeCapForPrevalentResources): 296 (WebKit::WebsiteDataStore::webPageWasAdded): 297 (WebKit::WebsiteDataStore::webPageWasInvalidated): 298 (WebKit::WebsiteDataStore::webProcessWillOpenConnection): 299 (WebKit::WebsiteDataStore::webPageWillOpenConnection): 300 (WebKit::WebsiteDataStore::webPageDidCloseConnection): 301 (WebKit::WebsiteDataStore::webProcessDidCloseConnection): 302 (WebKit::WebsiteDataStore::isAssociatedProcessPool const): 303 (WebKit::WebsiteDataStore::processPools const): 304 (WebKit::WebsiteDataStore::resourceLoadStatisticsEnabled const): 305 (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled): 306 (WebKit::WebsiteDataStore::setResourceLoadStatisticsDebugMode): 307 (WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback): 308 (WebKit::WebsiteDataStore::logTestingEvent): 309 * UIProcess/WebsiteData/WebsiteDataStore.h: 310 (WebKit::WebsiteDataStore::setStatisticsTestingCallback): 311 * WebProcess/WebProcess.cpp: 312 (WebKit::WebProcess::initializeWebProcess): 313 1 314 2019-01-15 Darin Adler <darin@apple.com> 2 315 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
r240129 r240243 27 27 #include "ResourceLoadStatisticsMemoryStore.h" 28 28 29 #if ENABLE(RESOURCE_LOAD_STATISTICS) 30 29 31 #include "Logging.h" 30 32 #include "NetworkSession.h" … … 245 247 246 248 RunLoop::main().dispatch([prevalentResourceDomains = crossThreadCopy(prevalentResourceDomains), callback = WTFMove(callback), weakThis = makeWeakPtr(*this), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef()] () mutable { 247 WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), shouldNotifyPagesWhenDataRecordsWereScanned, [callback = WTFMove(callback), weakThis = WTFMove(weakThis), workQueue = workQueue.copyRef()](const HashSet<String>& domainsWithDeletedWebsiteData) mutable { 249 if (!weakThis) { 250 callback(); 251 return; 252 } 253 254 weakThis->m_store.deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), shouldNotifyPagesWhenDataRecordsWereScanned, [callback = WTFMove(callback), weakThis = WTFMove(weakThis), workQueue = workQueue.copyRef()](const HashSet<String>& domainsWithDeletedWebsiteData) mutable { 248 255 workQueue->dispatch([topDomains = crossThreadCopy(domainsWithDeletedWebsiteData), callback = WTFMove(callback), weakThis = WTFMove(weakThis)] () mutable { 249 256 if (!weakThis) { … … 359 366 return; 360 367 361 RunLoop::main().dispatch([] { 362 WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed(); 368 RunLoop::main().dispatch([this, weakThis = makeWeakPtr(*this)] { 369 ASSERT(RunLoop::isMain()); 370 if (!weakThis) 371 return; 372 373 m_store.notifyResourceLoadStatisticsProcessed(); 363 374 }); 364 375 }); 365 376 } 366 377 367 void ResourceLoadStatisticsMemoryStore::hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, uint64_tframeID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)378 void ResourceLoadStatisticsMemoryStore::hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) 368 379 { 369 380 ASSERT(!RunLoop::isMain()); … … 381 392 382 393 RunLoop::main().dispatch([store = makeRef(m_store), subFramePrimaryDomain = subFramePrimaryDomain.isolatedCopy(), topFramePrimaryDomain = topFramePrimaryDomain.isolatedCopy(), frameID, pageID, completionHandler = WTFMove(completionHandler)]() mutable { 383 store->callHasStorageAccessForFrameHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID , pageID, [store = store.copyRef(), completionHandler = WTFMove(completionHandler)](bool result) mutable {394 store->callHasStorageAccessForFrameHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID.value(), pageID, [store = store.copyRef(), completionHandler = WTFMove(completionHandler)](bool result) mutable { 384 395 store->statisticsQueue().dispatch([completionHandler = WTFMove(completionHandler), result] () mutable { 385 396 completionHandler(result); … … 495 506 ASSERT(!RunLoop::isMain()); 496 507 497 RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef()] () mutable { 498 // FIXME: This method being a static call on WebProcessProxy is wrong. 499 // It should be on the data store that this object belongs to. 500 WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData(WebResourceLoadStatisticsStore::monitoredDataTypes(), shouldNotifyPagesWhenDataRecordsWereScanned, [weakThis = WTFMove(weakThis), callback = WTFMove(callback), workQueue = workQueue.copyRef()] (HashSet<String>&& topPrivatelyControlledDomainsWithWebsiteData) mutable { 501 workQueue->dispatch([weakThis = WTFMove(weakThis), topDomains = crossThreadCopy(topPrivatelyControlledDomainsWithWebsiteData), callback = WTFMove(callback)] () mutable { 508 RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef(), store = makeRef(m_store)] () mutable { 509 store->topPrivatelyControlledDomainsWithWebsiteData(WebResourceLoadStatisticsStore::monitoredDataTypes(), shouldNotifyPagesWhenDataRecordsWereScanned, [weakThis = WTFMove(weakThis), callback = WTFMove(callback), workQueue = workQueue.copyRef()] (HashSet<String>&& topDomainsWithWebsiteData) mutable { 510 workQueue->dispatch([weakThis = WTFMove(weakThis), topDomains = crossThreadCopy(topDomainsWithWebsiteData), callback = WTFMove(callback)] () mutable { 502 511 if (!weakThis) { 503 512 callback(); … … 1299 1308 1300 1309 } // namespace WebKit 1310 1311 #endif -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h
r239747 r240243 26 26 #pragma once 27 27 28 #if ENABLE(RESOURCE_LOAD_STATISTICS) 29 28 30 #include "ResourceLoadStatisticsClassifier.h" 29 31 #include "WebResourceLoadStatisticsStore.h" … … 117 119 void setPrevalentResourceForDebugMode(const String& domain); 118 120 119 void hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, uint64_tframeID, uint64_t pageID, CompletionHandler<void(bool)>&&);121 void hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); 120 122 void requestStorageAccess(String&& subFramePrimaryDomain, String&& topFramePrimaryDomain, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); 121 123 void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&); … … 130 132 131 133 void didCreateNetworkProcess(); 134 135 const WebResourceLoadStatisticsStore& store() const { return m_store; } 132 136 133 137 private: … … 202 206 203 207 } // namespace WebKit 208 209 #endif -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp
r239747 r240243 27 27 #include "ResourceLoadStatisticsPersistentStorage.h" 28 28 29 #if ENABLE(RESOURCE_LOAD_STATISTICS) 30 29 31 #include "Logging.h" 30 32 #include "PersistencyUtils.h" … … 271 273 272 274 } // namespace WebKit 275 276 #endif -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.h
r239747 r240243 25 25 26 26 #pragma once 27 28 #if ENABLE(RESOURCE_LOAD_STATISTICS) 27 29 28 30 #include <wtf/Forward.h> … … 76 78 77 79 } 80 81 #endif -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
r239816 r240243 27 27 #include "WebResourceLoadStatisticsStore.h" 28 28 29 #if ENABLE(RESOURCE_LOAD_STATISTICS) 30 31 #include "APIDictionary.h" 29 32 #include "Logging.h" 30 33 #include "NetworkSession.h" … … 34 37 #include "WebPageProxy.h" 35 38 #include "WebProcessMessages.h" 39 #include "WebProcessPool.h" 36 40 #include "WebProcessProxy.h" 37 41 #include "WebResourceLoadStatisticsStoreMessages.h" … … 39 43 #include "WebsiteDataFetchOption.h" 40 44 #include "WebsiteDataStore.h" 45 #include <WebCore/DiagnosticLoggingClient.h> 46 #include <WebCore/DiagnosticLoggingKeys.h> 41 47 #include <WebCore/NetworkStorageSession.h> 42 48 #include <WebCore/ResourceLoadStatistics.h> … … 89 95 } 90 96 91 void WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value) 97 void WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(bool value, CompletionHandler<void()>&& completionHandler) 98 { 99 ASSERT(RunLoop::isMain()); 100 101 postTask([this, value, completionHandler = WTFMove(completionHandler)]() mutable { 102 if (m_memoryStore) 103 m_memoryStore->setNotifyPagesWhenDataRecordsWereScanned(value); 104 105 postTaskReply(WTFMove(completionHandler)); 106 }); 107 } 108 109 void WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value, CompletionHandler<void()>&& completionHandler) 110 { 111 ASSERT(RunLoop::isMain()); 112 113 postTask([this, value, completionHandler = WTFMove(completionHandler)]() mutable { 114 if (m_memoryStore) 115 m_memoryStore->setShouldClassifyResourcesBeforeDataRecordsRemoval(value); 116 117 postTaskReply(WTFMove(completionHandler)); 118 }); 119 } 120 121 void WebResourceLoadStatisticsStore::setShouldSubmitTelemetry(bool value) 92 122 { 93 123 ASSERT(RunLoop::isMain()); … … 95 125 postTask([this, value] { 96 126 if (m_memoryStore) 97 m_memoryStore->setShouldClassifyResourcesBeforeDataRecordsRemoval(value);98 });99 }100 101 void WebResourceLoadStatisticsStore::setShouldSubmitTelemetry(bool value)102 {103 ASSERT(RunLoop::isMain());104 105 postTask([this, value] {106 if (m_memoryStore)107 127 m_memoryStore->setShouldSubmitTelemetry(value); 108 128 }); 129 } 130 131 void WebResourceLoadStatisticsStore::setNotifyPagesWhenTelemetryWasCaptured(bool value, CompletionHandler<void()>&& completionHandler) 132 { 133 ASSERT(RunLoop::isMain()); 134 135 WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value); 136 completionHandler(); 109 137 } 110 138 … … 134 162 m_memoryStore = std::make_unique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue); 135 163 m_persistentStorage = std::make_unique<ResourceLoadStatisticsPersistentStorage>(*m_memoryStore, m_statisticsQueue, resourceLoadStatisticsDirectory); 164 165 // FIXME(193297): This should be revised after the UIProcess version goes away. 166 m_memoryStore->didCreateNetworkProcess(); 136 167 }); 137 168 … … 195 226 ASSERT(RunLoop::isMain()); 196 227 197 postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { 228 setPrevalentResourceForDebugMode(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 229 } 230 231 void WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode(const String& primaryDomain, CompletionHandler<void()>&& completionHandler) 232 { 233 ASSERT(RunLoop::isMain()); 234 235 postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 198 236 if (m_memoryStore) 199 237 m_memoryStore->setPrevalentResourceForDebugMode(primaryDomain); … … 202 240 } 203 241 204 void WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing( )205 { 206 ASSERT(RunLoop::isMain()); 207 208 postTask([this ]{242 void WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&& completionHandler) 243 { 244 ASSERT(RunLoop::isMain()); 245 246 postTask([this, completionHandler = WTFMove(completionHandler)]() mutable { 209 247 if (m_memoryStore) 210 248 m_memoryStore->processStatisticsAndDataRecords(); 249 postTaskReply(WTFMove(completionHandler)); 211 250 }); 212 251 } … … 234 273 } 235 274 236 void WebResourceLoadStatisticsStore::hasStorageAccess( String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)275 void WebResourceLoadStatisticsStore::hasStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) 237 276 { 238 277 ASSERT(subFrameHost != topFrameHost); 239 278 ASSERT(RunLoop::isMain()); 240 279 241 postTask([this, subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost), frameID, pageID, completionHandler = WTFMove(completionHandler)]() mutable {280 postTask([this, subFramePrimaryDomain = subFrameHost.isolatedCopy(), topFramePrimaryDomain = topFrameHost.isolatedCopy(), frameID, pageID, completionHandler = WTFMove(completionHandler)]() mutable { 242 281 if (!m_memoryStore) { 243 postTaskReply([completionHandler = WTFMove(completionHandler)] 282 postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable { 244 283 completionHandler(false); 245 284 }); … … 247 286 } 248 287 m_memoryStore->hasStorageAccess(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, [completionHandler = WTFMove(completionHandler)](bool hasStorageAccess) mutable { 249 postTaskReply([completionHandler = WTFMove(completionHandler), hasStorageAccess] 288 postTaskReply([completionHandler = WTFMove(completionHandler), hasStorageAccess]() mutable { 250 289 completionHandler(hasStorageAccess); 251 290 }); … … 254 293 } 255 294 256 #if ENABLE(RESOURCE_LOAD_STATISTICS)257 295 bool WebResourceLoadStatisticsStore::hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID) 258 296 { 259 297 return m_networkSession ? m_networkSession->networkStorageSession().hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID) : false; 260 298 } 261 #endif262 299 263 300 void WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&& callback) … … 265 302 ASSERT(RunLoop::isMain()); 266 303 267 #if ENABLE(RESOURCE_LOAD_STATISTICS)268 304 if (m_websiteDataStore) { 269 305 m_websiteDataStore->hasStorageAccessForFrameHandler(resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(callback)); 270 306 return; 271 } else { 272 callback(hasStorageAccessForFrame(resourceDomain, firstPartyDomain, frameID, pageID)); 273 return; 274 } 275 #endif 307 } 308 309 if (m_networkSession) { 310 callback(m_networkSession->networkStorageSession().hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID)); 311 return; 312 } 313 276 314 callback(false); 277 315 } … … 282 320 ASSERT(RunLoop::isMain()); 283 321 322 requestStorageAccess(subFrameHost, topFrameHost, frameID, pageID, promptEnabled, WTFMove(completionHandler)); 323 } 324 325 void WebResourceLoadStatisticsStore::requestStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler) 326 { 284 327 auto subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost); 285 328 auto topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost); … … 289 332 } 290 333 291 postTask([this, subFramePrimaryDomain = crossThreadCopy(subFramePrimaryDomain), topFramePrimaryDomain = crossThreadCopy(topFramePrimaryDomain), frameID, pageID, promptEnabled, completionHandler = WTFMove(completionHandler)] 334 postTask([this, subFramePrimaryDomain = crossThreadCopy(subFramePrimaryDomain), topFramePrimaryDomain = crossThreadCopy(topFramePrimaryDomain), frameID, pageID, promptEnabled, completionHandler = WTFMove(completionHandler)]() mutable { 292 335 if (!m_memoryStore) { 293 postTaskReply([completionHandler = WTFMove(completionHandler)] 336 postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable { 294 337 completionHandler(StorageAccessStatus::CannotRequestAccess); 295 338 }); … … 297 340 } 298 341 299 m_memoryStore->requestStorageAccess(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID , pageID, promptEnabled, [completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable {300 postTaskReply([completionHandler = WTFMove(completionHandler), status] 342 m_memoryStore->requestStorageAccess(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID.value(), pageID, promptEnabled, [completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable { 343 postTaskReply([completionHandler = WTFMove(completionHandler), status]() mutable { 301 344 completionHandler(status); 302 345 }); … … 321 364 { 322 365 ASSERT(RunLoop::isMain()); 323 postTask([this, subFrameHost = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPromptedNow, completionHandler = WTFMove(completionHandler)] 366 postTask([this, subFrameHost = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPromptedNow, completionHandler = WTFMove(completionHandler)]() mutable { 324 367 if (!m_memoryStore) { 325 postTaskReply([completionHandler = WTFMove(completionHandler)] 368 postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable { 326 369 completionHandler(false); 327 370 }); … … 330 373 331 374 m_memoryStore->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPromptedNow, [completionHandler = WTFMove(completionHandler)](bool wasGrantedAccess) mutable { 332 postTaskReply([completionHandler = WTFMove(completionHandler), wasGrantedAccess] 375 postTaskReply([completionHandler = WTFMove(completionHandler), wasGrantedAccess]() mutable { 333 376 completionHandler(wasGrantedAccess); 334 377 }); … … 337 380 } 338 381 339 #if ENABLE(RESOURCE_LOAD_STATISTICS)340 382 bool WebResourceLoadStatisticsStore::grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID) 341 383 { … … 350 392 return isStorageGranted; 351 393 } 352 #endif353 394 354 395 void WebResourceLoadStatisticsStore::callGrantStorageAccessHandler(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback) … … 356 397 ASSERT(RunLoop::isMain()); 357 398 358 #if ENABLE(RESOURCE_LOAD_STATISTICS)359 399 if (m_websiteDataStore) { 360 400 m_websiteDataStore->grantStorageAccessHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, WTFMove(callback)); 361 401 return; 362 } else { 363 callback(grantStorageAccess(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID)); 364 return; 365 } 366 #endif 367 callback(false); 402 } 403 404 callback(grantStorageAccess(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID)); 368 405 } 369 406 … … 379 416 } 380 417 381 #if ENABLE(RESOURCE_LOAD_STATISTICS)382 418 void WebResourceLoadStatisticsStore::removeAllStorageAccess() 383 419 { … … 385 421 m_networkSession->networkStorageSession().removeAllStorageAccess(); 386 422 } 387 #endif388 423 389 424 void WebResourceLoadStatisticsStore::removeAllStorageAccess(CompletionHandler<void()>&& completionHandler) … … 391 426 ASSERT(RunLoop::isMain()); 392 427 393 #if ENABLE(RESOURCE_LOAD_STATISTICS)394 428 if (m_websiteDataStore) { 395 429 m_websiteDataStore->removeAllStorageAccessHandler(WTFMove(completionHandler)); … … 397 431 } 398 432 removeAllStorageAccess(); 399 #endif400 433 completionHandler(); 401 434 } … … 419 452 } 420 453 421 void WebResourceLoadStatisticsStore::submitTelemetry( )422 { 423 ASSERT(RunLoop::isMain()); 424 425 postTask([this ]{454 void WebResourceLoadStatisticsStore::submitTelemetry(CompletionHandler<void()>&& completionHandler) 455 { 456 ASSERT(RunLoop::isMain()); 457 458 postTask([this, completionHandler = WTFMove(completionHandler)]() mutable { 426 459 if (m_memoryStore) 427 460 WebResourceLoadStatisticsTelemetry::calculateAndSubmit(*m_memoryStore); 461 462 postTaskReply(WTFMove(completionHandler)); 428 463 }); 429 464 } … … 477 512 } 478 513 479 logUserInteraction( isolatedPrimaryDomain(url), WTFMove(completionHandler));514 logUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 480 515 } 481 516 … … 500 535 } 501 536 502 postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { 537 clearUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 538 } 539 540 void WebResourceLoadStatisticsStore::clearUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler) 541 { 542 ASSERT(RunLoop::isMain()); 543 544 postTask([this, primaryDomain = targetPrimaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 503 545 if (m_memoryStore) 504 546 m_memoryStore->clearUserInteraction(primaryDomain); … … 516 558 } 517 559 518 postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)] () mutable { 560 hasHadUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 561 } 562 563 void WebResourceLoadStatisticsStore::hasHadUserInteraction(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler) 564 { 565 postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 519 566 bool hadUserInteraction = m_memoryStore ? m_memoryStore->hasHadUserInteraction(primaryDomain) : false; 520 postTaskReply([hadUserInteraction, completionHandler = WTFMove(completionHandler)] 567 postTaskReply([hadUserInteraction, completionHandler = WTFMove(completionHandler)]() mutable { 521 568 completionHandler(hadUserInteraction); 522 569 }); … … 533 580 } 534 581 535 postTask([this, primaryDomain = isolatedPrimaryDomain(url), seconds, completionHandler = WTFMove(completionHandler)]() mutable { 536 if (m_memoryStore) 537 m_memoryStore->setLastSeen(primaryDomain, seconds); 582 setLastSeen(WebCore::ResourceLoadStatistics::primaryDomain(url), seconds, WTFMove(completionHandler)); 583 } 584 585 void WebResourceLoadStatisticsStore::setLastSeen(const String& resourceDomain, Seconds seconds, CompletionHandler<void()>&& completionHandler) 586 { 587 ASSERT(RunLoop::isMain()); 588 589 postTask([this, resourceDomain = resourceDomain.isolatedCopy(), seconds, completionHandler = WTFMove(completionHandler)]() mutable { 590 if (m_memoryStore) 591 m_memoryStore->setLastSeen(resourceDomain, seconds); 538 592 postTaskReply(WTFMove(completionHandler)); 539 593 }); … … 549 603 } 550 604 551 postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { 552 if (m_memoryStore) 553 m_memoryStore->setPrevalentResource(primaryDomain); 605 setPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 606 } 607 608 void WebResourceLoadStatisticsStore::setPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 609 { 610 ASSERT(RunLoop::isMain()); 611 612 postTask([this, resourceDomain = resourceDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 613 if (m_memoryStore) 614 m_memoryStore->setPrevalentResource(resourceDomain); 554 615 postTaskReply(WTFMove(completionHandler)); 555 616 }); … … 565 626 } 566 627 567 postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { 628 setVeryPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 629 } 630 631 void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const String& primaryDomain, CompletionHandler<void()>&& completionHandler) 632 { 633 ASSERT(RunLoop::isMain()); 634 635 postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 568 636 if (m_memoryStore) 569 637 m_memoryStore->setVeryPrevalentResource(primaryDomain); … … 576 644 ASSERT(RunLoop::isMain()); 577 645 578 postTask([this, completionHandler = WTFMove(completionHandler)] 646 postTask([this, completionHandler = WTFMove(completionHandler)]() mutable { 579 647 String result = m_memoryStore ? m_memoryStore->dumpResourceLoadStatistics() : emptyString(); 580 postTaskReply([result = result.isolatedCopy(), completionHandler = WTFMove(completionHandler)] 648 postTaskReply([result = result.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 581 649 completionHandler(result); 582 650 }); … … 593 661 } 594 662 595 postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)] () mutable { 663 isPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 664 } 665 666 void WebResourceLoadStatisticsStore::isPrevalentResource(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler) 667 { 668 ASSERT(RunLoop::isMain()); 669 670 postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 596 671 bool isPrevalentResource = m_memoryStore ? m_memoryStore->isPrevalentResource(primaryDomain) : false; 597 postTaskReply([isPrevalentResource, completionHandler = WTFMove(completionHandler)] 672 postTaskReply([isPrevalentResource, completionHandler = WTFMove(completionHandler)]() mutable { 598 673 completionHandler(isPrevalentResource); 599 674 }); 600 675 }); 601 676 } 602 677 603 678 void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const URL& url, CompletionHandler<void(bool)>&& completionHandler) 604 679 { … … 610 685 } 611 686 612 postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)] () mutable { 687 isVeryPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 688 } 689 690 void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler) 691 { 692 ASSERT(RunLoop::isMain()); 693 694 postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 613 695 bool isVeryPrevalentResource = m_memoryStore ? m_memoryStore->isVeryPrevalentResource(primaryDomain) : false; 614 postTaskReply([isVeryPrevalentResource, completionHandler = WTFMove(completionHandler)] 696 postTaskReply([isVeryPrevalentResource, completionHandler = WTFMove(completionHandler)]() mutable { 615 697 completionHandler(isVeryPrevalentResource); 616 698 }); … … 621 703 { 622 704 ASSERT(RunLoop::isMain()); 623 624 postTask([this, subresourcePrimaryDomain = isolatedPrimaryDomain(subresource), topFramePrimaryDomain = isolatedPrimaryDomain(topFrame), completionHandler = WTFMove(completionHandler)] () mutable { 705 706 isRegisteredAsSubresourceUnder(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler)); 707 } 708 709 void WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder(const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler) 710 { 711 ASSERT(RunLoop::isMain()); 712 713 postTask([this, subresourcePrimaryDomain = subresource.isolatedCopy(), topFramePrimaryDomain = topFrame.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 625 714 bool isRegisteredAsSubresourceUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubresourceUnder(subresourcePrimaryDomain, topFramePrimaryDomain) : false; 626 postTaskReply([isRegisteredAsSubresourceUnder, completionHandler = WTFMove(completionHandler)] 715 postTaskReply([isRegisteredAsSubresourceUnder, completionHandler = WTFMove(completionHandler)]() mutable { 627 716 completionHandler(isRegisteredAsSubresourceUnder); 628 717 }); … … 634 723 ASSERT(RunLoop::isMain()); 635 724 636 postTask([this, subFramePrimaryDomain = isolatedPrimaryDomain(subFrame), topFramePrimaryDomain = isolatedPrimaryDomain(topFrame), completionHandler = WTFMove(completionHandler)] () mutable { 725 isRegisteredAsSubFrameUnder(WebCore::ResourceLoadStatistics::primaryDomain(subFrame), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler)); 726 } 727 728 void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler) 729 { 730 ASSERT(RunLoop::isMain()); 731 732 postTask([this, subFramePrimaryDomain = subFrame.isolatedCopy(), topFramePrimaryDomain = topFrame.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 637 733 bool isRegisteredAsSubFrameUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubFrameUnder(subFramePrimaryDomain, topFramePrimaryDomain) : false; 638 postTaskReply([isRegisteredAsSubFrameUnder, completionHandler = WTFMove(completionHandler)] 734 postTaskReply([isRegisteredAsSubFrameUnder, completionHandler = WTFMove(completionHandler)]() mutable { 639 735 completionHandler(isRegisteredAsSubFrameUnder); 640 736 }); … … 646 742 ASSERT(RunLoop::isMain()); 647 743 648 postTask([this, hostRedirectedFromPrimaryDomain = isolatedPrimaryDomain(hostRedirectedFrom), hostRedirectedToPrimaryDomain = isolatedPrimaryDomain(hostRedirectedTo), completionHandler = WTFMove(completionHandler)] () mutable { 744 isRegisteredAsRedirectingTo(WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedFrom), WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedTo), WTFMove(completionHandler)); 745 } 746 747 void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const String& hostRedirectedFrom, const String& hostRedirectedTo, CompletionHandler<void(bool)>&& completionHandler) 748 { 749 ASSERT(RunLoop::isMain()); 750 751 postTask([this, hostRedirectedFromPrimaryDomain = hostRedirectedFrom.isolatedCopy(), hostRedirectedToPrimaryDomain = hostRedirectedTo.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 649 752 bool isRegisteredAsRedirectingTo = m_memoryStore ? m_memoryStore->isRegisteredAsRedirectingTo(hostRedirectedFromPrimaryDomain, hostRedirectedToPrimaryDomain) : false; 650 postTaskReply([isRegisteredAsRedirectingTo, completionHandler = WTFMove(completionHandler)] 753 postTaskReply([isRegisteredAsRedirectingTo, completionHandler = WTFMove(completionHandler)]() mutable { 651 754 completionHandler(isRegisteredAsRedirectingTo); 652 755 }); … … 663 766 } 664 767 665 postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { 666 if (m_memoryStore) 667 m_memoryStore->clearPrevalentResource(primaryDomain); 668 postTaskReply(WTFMove(completionHandler)); 669 }); 670 } 671 672 void WebResourceLoadStatisticsStore::setGrandfathered(const URL& url, bool value) 768 clearPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 769 } 770 771 void WebResourceLoadStatisticsStore::clearPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 772 { 773 ASSERT(RunLoop::isMain()); 774 775 postTask([this, resourceDomain = resourceDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 776 if (m_memoryStore) 777 m_memoryStore->clearPrevalentResource(resourceDomain); 778 postTaskReply(WTFMove(completionHandler)); 779 }); 780 } 781 782 void WebResourceLoadStatisticsStore::setGrandfathered(const URL& url, bool value, CompletionHandler<void()>&& completionHandler) 673 783 { 674 784 ASSERT(RunLoop::isMain()); … … 677 787 return; 678 788 679 postTask([this, primaryDomain = isolatedPrimaryDomain(url), value] { 789 setGrandfathered(WebCore::ResourceLoadStatistics::primaryDomain(url), value, WTFMove(completionHandler)); 790 } 791 792 void WebResourceLoadStatisticsStore::setGrandfathered(const String& domain, bool value, CompletionHandler<void()>&& completionHandler) 793 { 794 ASSERT(RunLoop::isMain()); 795 796 postTask([this, primaryDomain = domain.isolatedCopy(), value, completionHandler = WTFMove(completionHandler)]() mutable { 680 797 if (m_memoryStore) 681 798 m_memoryStore->setGrandfathered(primaryDomain, value); 682 }); 683 } 684 799 postTaskReply(WTFMove(completionHandler)); 800 }); 801 } 802 685 803 void WebResourceLoadStatisticsStore::isGrandfathered(const URL& url, CompletionHandler<void (bool)>&& completionHandler) 686 804 { … … 692 810 } 693 811 694 postTask([this, completionHandler = WTFMove(completionHandler), primaryDomain = isolatedPrimaryDomain(url)] () mutable { 812 isGrandfathered(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 813 } 814 815 void WebResourceLoadStatisticsStore::isGrandfathered(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler) 816 { 817 ASSERT(RunLoop::isMain()); 818 819 postTask([this, completionHandler = WTFMove(completionHandler), primaryDomain = primaryDomain.isolatedCopy()]() mutable { 695 820 bool isGrandFathered = m_memoryStore ? m_memoryStore->isGrandfathered(primaryDomain) : false; 696 postTaskReply([isGrandFathered, completionHandler = WTFMove(completionHandler)] 821 postTaskReply([isGrandFathered, completionHandler = WTFMove(completionHandler)]() mutable { 697 822 completionHandler(isGrandFathered); 698 823 }); … … 700 825 } 701 826 702 void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame) 703 { 704 ASSERT(RunLoop::isMain()); 705 706 if (subframe.protocolIsAbout() || subframe.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) 707 return; 708 709 postTask([this, primaryTopFrameDomain = isolatedPrimaryDomain(topFrame), primarySubFrameDomain = isolatedPrimaryDomain(subframe)] { 827 void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&& completionHandler) 828 { 829 ASSERT(RunLoop::isMain()); 830 831 if (subframe.protocolIsAbout() || subframe.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) { 832 completionHandler(); 833 return; 834 } 835 836 setSubframeUnderTopFrameOrigin(WebCore::ResourceLoadStatistics::primaryDomain(subframe), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler)); 837 } 838 839 void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const String& subframe, const String& topFrame, CompletionHandler<void()>&& completionHandler) 840 { 841 ASSERT(RunLoop::isMain()); 842 843 postTask([this, completionHandler = WTFMove(completionHandler), primaryTopFrameDomain = topFrame.isolatedCopy(), primarySubFrameDomain = subframe.isolatedCopy()]() mutable { 710 844 if (m_memoryStore) 711 845 m_memoryStore->setSubframeUnderTopFrameOrigin(primarySubFrameDomain, primaryTopFrameDomain); 712 }); 713 } 714 715 void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame) 716 { 717 ASSERT(RunLoop::isMain()); 718 719 if (subresource.protocolIsAbout() || subresource.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) 720 return; 721 722 postTask([this, primaryTopFrameDomain = isolatedPrimaryDomain(topFrame), primarySubresourceDomain = isolatedPrimaryDomain(subresource)] { 846 postTaskReply(WTFMove(completionHandler)); 847 }); 848 } 849 850 void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&& completionHandler) 851 { 852 ASSERT(RunLoop::isMain()); 853 854 if (subresource.protocolIsAbout() || subresource.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) { 855 completionHandler(); 856 return; 857 } 858 859 setSubresourceUnderTopFrameOrigin(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler)); 860 } 861 862 void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const String& subresource, const String& topFrame, CompletionHandler<void()>&& completionHandler) 863 { 864 ASSERT(RunLoop::isMain()); 865 866 postTask([this, completionHandler = WTFMove(completionHandler), primaryTopFrameDomain = topFrame.isolatedCopy(), primarySubresourceDomain = subresource.isolatedCopy()]() mutable { 723 867 if (m_memoryStore) 724 868 m_memoryStore->setSubresourceUnderTopFrameOrigin(primarySubresourceDomain, primaryTopFrameDomain); 725 }); 726 } 727 728 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo) 729 { 730 ASSERT(RunLoop::isMain()); 731 732 if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) 733 return; 734 735 postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedTo), primarySubresourceDomain = isolatedPrimaryDomain(subresource)] { 869 postTaskReply(WTFMove(completionHandler)); 870 }); 871 } 872 873 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) 874 { 875 ASSERT(RunLoop::isMain()); 876 877 if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) { 878 completionHandler(); 879 return; 880 } 881 882 setSubresourceUniqueRedirectTo(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), WTFMove(completionHandler)); 883 } 884 885 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) 886 { 887 ASSERT(RunLoop::isMain()); 888 889 postTask([this, completionHandler = WTFMove(completionHandler), primaryRedirectDomain = hostNameRedirectedTo.isolatedCopy(), primarySubresourceDomain = subresource.isolatedCopy()]() mutable { 736 890 if (m_memoryStore) 737 891 m_memoryStore->setSubresourceUniqueRedirectTo(primarySubresourceDomain, primaryRedirectDomain); 738 }); 739 } 740 741 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom) 742 { 743 ASSERT(RunLoop::isMain()); 744 745 if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) 746 return; 747 748 postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedFrom), primarySubresourceDomain = isolatedPrimaryDomain(subresource)] { 892 postTaskReply(WTFMove(completionHandler)); 893 }); 894 } 895 896 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) 897 { 898 ASSERT(RunLoop::isMain()); 899 900 if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) { 901 completionHandler(); 902 return; 903 } 904 905 setSubresourceUniqueRedirectFrom(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), WTFMove(completionHandler)); 906 } 907 908 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) 909 { 910 ASSERT(RunLoop::isMain()); 911 912 postTask([this, completionHandler = WTFMove(completionHandler), primaryRedirectDomain = hostNameRedirectedFrom.isolatedCopy(), primarySubresourceDomain = subresource.isolatedCopy()]() mutable { 749 913 if (m_memoryStore) 750 914 m_memoryStore->setSubresourceUniqueRedirectFrom(primarySubresourceDomain, primaryRedirectDomain); 751 }); 752 } 753 754 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo) 755 { 756 ASSERT(RunLoop::isMain()); 757 758 if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) 759 return; 760 761 postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedTo), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHostName)] { 915 postTaskReply(WTFMove(completionHandler)); 916 }); 917 } 918 919 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) 920 { 921 ASSERT(RunLoop::isMain()); 922 923 if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) { 924 completionHandler(); 925 return; 926 } 927 928 setTopFrameUniqueRedirectTo(WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), WTFMove(completionHandler)); 929 } 930 931 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) 932 { 933 ASSERT(RunLoop::isMain()); 934 935 postTask([this, completionHandler = WTFMove(completionHandler), topFramePrimaryDomain = topFrameHostName.isolatedCopy(), primaryRedirectDomain = hostNameRedirectedTo.isolatedCopy()]() mutable { 762 936 if (m_memoryStore) 763 937 m_memoryStore->setTopFrameUniqueRedirectTo(topFramePrimaryDomain, primaryRedirectDomain); 764 }); 765 } 766 767 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom) 768 { 769 ASSERT(RunLoop::isMain()); 770 771 if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) 772 return; 773 774 postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedFrom), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHostName)] { 938 postTaskReply(WTFMove(completionHandler)); 939 }); 940 } 941 942 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) 943 { 944 ASSERT(RunLoop::isMain()); 945 946 if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) { 947 completionHandler(); 948 return; 949 } 950 951 setTopFrameUniqueRedirectFrom(WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), WTFMove(completionHandler)); 952 } 953 954 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) 955 { 956 ASSERT(RunLoop::isMain()); 957 958 postTask([this, completionHandler = WTFMove(completionHandler), topFramePrimaryDomain = topFrameHostName.isolatedCopy(), primaryRedirectDomain = hostNameRedirectedFrom.isolatedCopy()]() mutable { 775 959 if (m_memoryStore) 776 960 m_memoryStore->setTopFrameUniqueRedirectFrom(topFramePrimaryDomain, primaryRedirectDomain); 961 postTaskReply(WTFMove(completionHandler)); 777 962 }); 778 963 } … … 783 968 ASSERT(RunLoop::isMain()); 784 969 785 postTask([this, completionHandler = WTFMove(completionHandler)] 970 postTask([this, completionHandler = WTFMove(completionHandler)]() mutable { 786 971 if (!m_memoryStore) { 787 972 postTaskReply(WTFMove(completionHandler)); 788 973 return; 789 974 } 790 m_memoryStore->updateCookieBlocking([completionHandler = WTFMove(completionHandler)] 975 m_memoryStore->updateCookieBlocking([completionHandler = WTFMove(completionHandler)]() mutable { 791 976 postTaskReply(WTFMove(completionHandler)); 792 977 }); … … 798 983 // Helper function used by testing system. Should only be called from the main thread. 799 984 ASSERT(RunLoop::isMain()); 800 postTask([this, domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] 985 postTask([this, domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)]() mutable { 801 986 if (!m_memoryStore) { 802 987 postTaskReply(WTFMove(completionHandler)); … … 814 999 // Helper function used by testing system. Should only be called from the main thread. 815 1000 ASSERT(RunLoop::isMain()); 816 postTask([this, domains = crossThreadCopy(domains), completionHandler = WTFMove(completionHandler)] 1001 postTask([this, domains = crossThreadCopy(domains), completionHandler = WTFMove(completionHandler)]() mutable { 817 1002 if (!m_memoryStore) { 818 1003 postTaskReply(WTFMove(completionHandler)); … … 829 1014 { 830 1015 ASSERT(RunLoop::isMain()); 831 postTask([this, protectedThis = makeRef(*this), shouldGrandfather, completionHandler = WTFMove(completionHandler)] 1016 postTask([this, protectedThis = makeRef(*this), shouldGrandfather, completionHandler = WTFMove(completionHandler)]() mutable { 832 1017 if (m_persistentStorage) 833 1018 m_persistentStorage->clear(); … … 862 1047 } 863 1048 864 void WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction(Seconds seconds )865 { 866 ASSERT(RunLoop::isMain()); 867 postTask([this, seconds ]{1049 void WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionHandler<void()>&& completionHandler) 1050 { 1051 ASSERT(RunLoop::isMain()); 1052 postTask([this, seconds, completionHandler = WTFMove(completionHandler)]() mutable { 868 1053 if (m_memoryStore) 869 1054 m_memoryStore->setTimeToLiveUserInteraction(seconds); 870 }); 871 } 872 873 void WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds) 874 { 875 ASSERT(RunLoop::isMain()); 876 postTask([this, seconds] { 1055 postTaskReply(WTFMove(completionHandler)); 1056 }); 1057 } 1058 1059 void WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds, CompletionHandler<void()>&& completionHandler) 1060 { 1061 ASSERT(RunLoop::isMain()); 1062 postTask([this, seconds, completionHandler = WTFMove(completionHandler)]() mutable { 877 1063 if (m_memoryStore) 878 1064 m_memoryStore->setMinimumTimeBetweenDataRecordsRemoval(seconds); 879 }); 880 } 881 882 void WebResourceLoadStatisticsStore::setGrandfatheringTime(Seconds seconds) 883 { 884 ASSERT(RunLoop::isMain()); 885 postTask([this, seconds] { 1065 1066 postTaskReply(WTFMove(completionHandler)); 1067 }); 1068 } 1069 1070 void WebResourceLoadStatisticsStore::setGrandfatheringTime(Seconds seconds, CompletionHandler<void()>&& completionHandler) 1071 { 1072 ASSERT(RunLoop::isMain()); 1073 postTask([this, seconds, completionHandler = WTFMove(completionHandler)]() mutable { 886 1074 if (m_memoryStore) 887 1075 m_memoryStore->setGrandfatheringTime(seconds); 888 }); 889 } 890 891 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1076 1077 postTaskReply(WTFMove(completionHandler)); 1078 }); 1079 } 1080 892 1081 void WebResourceLoadStatisticsStore::setCacheMaxAgeCapForPrevalentResources(Seconds seconds) 893 1082 { … … 895 1084 m_networkSession->networkStorageSession().setCacheMaxAgeCapForPrevalentResources(seconds); 896 1085 } 897 #endif898 1086 899 1087 void WebResourceLoadStatisticsStore::setCacheMaxAgeCap(Seconds seconds, CompletionHandler<void()>&& completionHandler) … … 902 1090 ASSERT(seconds >= 0_s); 903 1091 904 #if ENABLE(RESOURCE_LOAD_STATISTICS)905 1092 if (m_websiteDataStore) { 906 1093 m_websiteDataStore->setCacheMaxAgeCapForPrevalentResources(seconds, WTFMove(completionHandler)); … … 908 1095 } 909 1096 setCacheMaxAgeCapForPrevalentResources(seconds); 910 #endif911 1097 completionHandler(); 912 1098 } 913 1099 914 #if ENABLE(RESOURCE_LOAD_STATISTICS)915 1100 void WebResourceLoadStatisticsStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock) 916 1101 { … … 918 1103 m_networkSession->networkStorageSession().setPrevalentDomainsToBlockCookiesFor(domainsToBlock); 919 1104 } 920 #endif921 1105 922 1106 void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler) … … 924 1108 ASSERT(RunLoop::isMain()); 925 1109 926 #if ENABLE(RESOURCE_LOAD_STATISTICS)927 1110 if (m_websiteDataStore) { 928 1111 m_websiteDataStore->updatePrevalentDomainsToBlockCookiesFor(domainsToBlock, WTFMove(completionHandler)); … … 930 1113 } 931 1114 updatePrevalentDomainsToBlockCookiesFor(domainsToBlock); 932 #endif933 1115 completionHandler(); 934 1116 } 935 1117 936 #if ENABLE(RESOURCE_LOAD_STATISTICS)937 1118 void WebResourceLoadStatisticsStore::removePrevalentDomains(const Vector<String>& domains) 938 1119 { … … 940 1121 m_networkSession->networkStorageSession().removePrevalentDomains(domains); 941 1122 } 942 #endif943 1123 944 1124 void WebResourceLoadStatisticsStore::callRemoveDomainsHandler(const Vector<String>& domains) … … 946 1126 ASSERT(RunLoop::isMain()); 947 1127 948 #if ENABLE(RESOURCE_LOAD_STATISTICS)949 1128 if (m_websiteDataStore) 950 1129 m_websiteDataStore->removePrevalentDomains(domains); 951 1130 removePrevalentDomains(domains); 1131 } 1132 1133 void WebResourceLoadStatisticsStore::setMaxStatisticsEntries(size_t maximumEntryCount, CompletionHandler<void()>&& completionHandler) 1134 { 1135 ASSERT(RunLoop::isMain()); 1136 postTask([this, maximumEntryCount, completionHandler = WTFMove(completionHandler)]() mutable { 1137 if (m_memoryStore) 1138 m_memoryStore->setMaxStatisticsEntries(maximumEntryCount); 1139 1140 postTaskReply(WTFMove(completionHandler)); 1141 }); 1142 } 1143 1144 void WebResourceLoadStatisticsStore::setPruneEntriesDownTo(size_t pruneTargetCount, CompletionHandler<void()>&& completionHandler) 1145 { 1146 ASSERT(RunLoop::isMain()); 1147 1148 postTask([this, pruneTargetCount, completionHandler = WTFMove(completionHandler)]() mutable { 1149 if (m_memoryStore) 1150 m_memoryStore->setPruneEntriesDownTo(pruneTargetCount); 1151 1152 postTaskReply(WTFMove(completionHandler)); 1153 }); 1154 } 1155 1156 void WebResourceLoadStatisticsStore::resetParametersToDefaultValues(CompletionHandler<void()>&& completionHandler) 1157 { 1158 ASSERT(RunLoop::isMain()); 1159 1160 postTask([this, completionHandler = WTFMove(completionHandler)]() mutable { 1161 if (m_memoryStore) 1162 m_memoryStore->resetParametersToDefaultValues(); 1163 1164 postTaskReply(WTFMove(completionHandler)); 1165 }); 1166 } 1167 1168 void WebResourceLoadStatisticsStore::logTestingEvent(const String& event) 1169 { 1170 ASSERT(RunLoop::isMain()); 1171 1172 if (m_websiteDataStore) { 1173 m_websiteDataStore->logTestingEvent(event); 1174 return; 1175 } 1176 // FIXME(193297): Send message to UIProcess 1177 } 1178 1179 void WebResourceLoadStatisticsStore::notifyResourceLoadStatisticsProcessed() 1180 { 1181 ASSERT(RunLoop::isMain()); 1182 1183 if (m_websiteDataStore) 1184 WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed(); 1185 1186 if (m_networkSession) 1187 m_networkSession->notifyResourceLoadStatisticsProcessed(); 1188 } 1189 1190 void WebResourceLoadStatisticsStore::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler) 1191 { 1192 ASSERT(RunLoop::isMain()); 1193 1194 if (m_websiteDataStore) { 1195 WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler)); 1196 return; 1197 } 1198 1199 if (m_networkSession) { 1200 m_networkSession->deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler)); 1201 return; 1202 } 1203 1204 completionHandler({ }); 1205 } 1206 1207 void WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler) 1208 { 1209 ASSERT(RunLoop::isMain()); 1210 1211 if (m_websiteDataStore) { 1212 WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData(dataTypes, shouldNotifyPage, WTFMove(completionHandler)); 1213 return; 1214 } 1215 1216 if (m_networkSession) { 1217 m_networkSession->topPrivatelyControlledDomainsWithWebsiteData(dataTypes, shouldNotifyPage, WTFMove(completionHandler)); 1218 return; 1219 } 1220 1221 completionHandler({ }); 1222 } 1223 1224 void WebResourceLoadStatisticsStore::sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample shouldSample) const 1225 { 1226 if (m_websiteDataStore) { 1227 if (auto* webPageProxy = WebPageProxy::nonEphemeralWebPageProxy()) 1228 webPageProxy->logDiagnosticMessageWithValue(message, description, value, sigDigits, shouldSample); 1229 } 1230 1231 if (m_networkSession) 1232 const_cast<WebResourceLoadStatisticsStore*>(this)->networkSession()->logDiagnosticMessageWithValue(message, description, value, sigDigits, shouldSample); 1233 } 1234 1235 void WebResourceLoadStatisticsStore::notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) const 1236 { 1237 if (m_websiteDataStore) { 1238 API::Dictionary::MapType messageBody; 1239 messageBody.set("TotalPrevalentResources"_s, API::UInt64::create(totalPrevalentResources)); 1240 messageBody.set("TotalPrevalentResourcesWithUserInteraction"_s, API::UInt64::create(totalPrevalentResourcesWithUserInteraction)); 1241 messageBody.set("Top3SubframeUnderTopFrameOrigins"_s, API::UInt64::create(top3SubframeUnderTopFrameOrigins)); 1242 WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr()); 1243 } 1244 1245 if (m_networkSession) 1246 const_cast<WebResourceLoadStatisticsStore*>(this)->networkSession()->notifyPageStatisticsTelemetryFinished(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins); 1247 } 1248 1249 } // namespace WebKit 1250 952 1251 #endif 953 }954 955 void WebResourceLoadStatisticsStore::setMaxStatisticsEntries(size_t maximumEntryCount)956 {957 ASSERT(RunLoop::isMain());958 postTask([this, maximumEntryCount] {959 if (m_memoryStore)960 m_memoryStore->setMaxStatisticsEntries(maximumEntryCount);961 });962 }963 964 void WebResourceLoadStatisticsStore::setPruneEntriesDownTo(size_t pruneTargetCount)965 {966 ASSERT(RunLoop::isMain());967 968 postTask([this, pruneTargetCount] {969 if (m_memoryStore)970 m_memoryStore->setPruneEntriesDownTo(pruneTargetCount);971 });972 }973 974 void WebResourceLoadStatisticsStore::resetParametersToDefaultValues(CompletionHandler<void()>&& completionHandler)975 {976 ASSERT(RunLoop::isMain());977 978 postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {979 if (m_memoryStore)980 m_memoryStore->resetParametersToDefaultValues();981 982 postTaskReply(WTFMove(completionHandler));983 });984 }985 986 void WebResourceLoadStatisticsStore::logTestingEvent(const String& event)987 {988 ASSERT(RunLoop::isMain());989 990 if (m_statisticsTestingCallback)991 m_statisticsTestingCallback(event);992 }993 994 } // namespace WebKit -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
r239816 r240243 1 1 /* 2 * Copyright (C) 2016-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #if ENABLE(RESOURCE_LOAD_STATISTICS) 29 28 30 #include "Connection.h" 29 31 #include "WebsiteDataType.h" … … 43 45 class ResourceRequest; 44 46 struct ResourceLoadStatistics; 47 enum class ShouldSample : bool; 45 48 } 46 49 … … 54 57 class WebsiteDataStore; 55 58 56 enum class StorageAccessStatus {59 enum class StorageAccessStatus : unsigned { 57 60 CannotRequestAccess, 58 61 RequiresUserPrompt, 59 62 HasAccess 63 }; 64 65 enum class ShouldGrandfather { 66 No, 67 Yes, 60 68 }; 61 69 … … 79 87 80 88 void setNotifyPagesWhenDataRecordsWereScanned(bool); 81 void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool); 89 void setNotifyPagesWhenTelemetryWasCaptured(bool, CompletionHandler<void()>&&); 90 void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool, CompletionHandler<void()>&&); 82 91 void setShouldSubmitTelemetry(bool); 83 92 84 void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);85 93 void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); 86 94 void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&); … … 94 102 void logUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&); 95 103 void clearUserInteraction(const URL&, CompletionHandler<void()>&&); 104 void clearUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&); 105 void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&); 106 void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&); 96 107 bool grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID); 97 108 void hasHadUserInteraction(const URL&, CompletionHandler<void(bool)>&&); 109 void hasHadUserInteraction(const String& resourceDomain, CompletionHandler<void(bool)>&&); 110 void hasStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback); 98 111 bool hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID); 112 void requestStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); 99 113 void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&); 114 void setLastSeen(const String& resourceDomain, Seconds, CompletionHandler<void()>&&); 100 115 void setPrevalentResource(const URL&, CompletionHandler<void()>&&); 116 void setPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&&); 101 117 void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&); 118 void setVeryPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&&); 102 119 void dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&&); 103 120 void isPrevalentResource(const URL&, CompletionHandler<void(bool)>&&); 121 void isPrevalentResource(const String&, CompletionHandler<void(bool)>&&); 104 122 void isVeryPrevalentResource(const URL&, CompletionHandler<void(bool)>&&); 123 void isVeryPrevalentResource(const String&, CompletionHandler<void(bool)>&&); 105 124 void isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&&); 125 void isRegisteredAsSubresourceUnder(const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&&); 106 126 void isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&&); 127 void isRegisteredAsSubFrameUnder(const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&&); 107 128 void isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&&); 129 void isRegisteredAsRedirectingTo(const String& hostRedirectedFrom, const String& hostRedirectedTo, CompletionHandler<void(bool)>&&); 108 130 void clearPrevalentResource(const URL&, CompletionHandler<void()>&&); 109 void setGrandfathered(const URL&, bool); 131 void clearPrevalentResource(const String&, CompletionHandler<void()>&&); 132 void setGrandfathered(const URL&, bool, CompletionHandler<void()>&&); 133 void setGrandfathered(const String&, bool, CompletionHandler<void()>&&); 110 134 void isGrandfathered(const URL&, CompletionHandler<void(bool)>&&); 135 void isGrandfathered(const String&, CompletionHandler<void(bool)>&&); 111 136 void removeAllStorageAccess(); 112 137 void removePrevalentDomains(const Vector<String>& domainsToBlock); 113 138 void setCacheMaxAgeCapForPrevalentResources(Seconds); 114 void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame); 115 void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame); 116 void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo); 117 void setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom); 118 void setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo); 119 void setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom); 139 void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&); 140 void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&&); 141 void setSubframeUnderTopFrameOrigin(const String& subframe, const String& topFrame, CompletionHandler<void()>&&); 142 void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&&); 143 void setSubresourceUnderTopFrameOrigin(const String& subresource, const String& topFrame, CompletionHandler<void()>&&); 144 void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&); 145 void setSubresourceUniqueRedirectTo(const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&&); 146 void setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&); 147 void setSubresourceUniqueRedirectFrom(const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&); 148 void setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&); 149 void setTopFrameUniqueRedirectTo(const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&&); 150 void setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&); 151 void setTopFrameUniqueRedirectFrom(const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&); 120 152 void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&); 121 153 void scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&); 122 154 void scheduleClearBlockingStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&&); 123 void scheduleStatisticsAndDataRecordsProcessing( );124 void submitTelemetry( );155 void scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&&); 156 void submitTelemetry(CompletionHandler<void()>&&); 125 157 void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock); 126 127 enum class ShouldGrandfather {128 No,129 Yes,130 };131 158 void scheduleClearInMemoryAndPersistent(ShouldGrandfather, CompletionHandler<void()>&&); 132 159 void scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfather, CompletionHandler<void()>&&); 133 160 134 void setTimeToLiveUserInteraction(Seconds );135 void setMinimumTimeBetweenDataRecordsRemoval(Seconds );136 void setGrandfatheringTime(Seconds );161 void setTimeToLiveUserInteraction(Seconds, CompletionHandler<void()>&&); 162 void setMinimumTimeBetweenDataRecordsRemoval(Seconds, CompletionHandler<void()>&&); 163 void setGrandfatheringTime(Seconds, CompletionHandler<void()>&&); 137 164 void setCacheMaxAgeCap(Seconds, CompletionHandler<void()>&&); 138 void setMaxStatisticsEntries(size_t );139 void setPruneEntriesDownTo(size_t );165 void setMaxStatisticsEntries(size_t, CompletionHandler<void()>&&); 166 void setPruneEntriesDownTo(size_t, CompletionHandler<void()>&&); 140 167 141 168 void resetParametersToDefaultValues(CompletionHandler<void()>&&); … … 143 170 void setResourceLoadStatisticsDebugMode(bool, CompletionHandler<void()>&&); 144 171 void setPrevalentResourceForDebugMode(const URL&, CompletionHandler<void()>&&); 145 146 void setStatisticsTestingCallback(WTF::Function<void(const String&)>&& callback) { m_statisticsTestingCallback = WTFMove(callback); } 172 void setPrevalentResourceForDebugMode(const String& resourceDomain, CompletionHandler<void()>&&); 173 147 174 void logTestingEvent(const String&); 148 175 void callGrantStorageAccessHandler(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); … … 154 181 void didCreateNetworkProcess(); 155 182 183 void notifyResourceLoadStatisticsProcessed(); 184 156 185 WebsiteDataStore* websiteDataStore() { return m_websiteDataStore.get(); } 157 186 NetworkSession* networkSession() { return m_networkSession.get(); } 187 188 void sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample) const; 189 void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) const; 158 190 159 191 private: … … 187 219 bool m_hasScheduledProcessStats { false }; 188 220 189 WTF::Function<void(const String&)> m_statisticsTestingCallback;190 191 221 bool m_firstNetworkProcessCreated { false }; 192 222 }; 193 223 194 224 } // namespace WebKit 225 226 #endif -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp
r239747 r240243 27 27 #include "WebResourceLoadStatisticsTelemetry.h" 28 28 29 #if ENABLE(RESOURCE_LOAD_STATISTICS) 30 29 31 #include "ResourceLoadStatisticsMemoryStore.h" 32 #include "WebPageProxy.h" 30 33 #include "WebProcessPool.h" 31 34 #include "WebProcessProxy.h" … … 128 131 } 129 132 130 static WebPageProxy* nonEphemeralWebPageProxy() 131 { 132 auto processPools = WebProcessPool::allProcessPools(); 133 if (processPools.isEmpty()) 134 return nullptr; 135 136 auto processPool = processPools[0]; 137 if (!processPool) 138 return nullptr; 139 140 for (auto& webProcess : processPool->processes()) { 141 for (auto& page : webProcess->pages()) { 142 if (page->sessionID().isEphemeral()) 143 continue; 144 return page; 145 } 146 } 147 return nullptr; 148 } 149 150 static void submitTopList(unsigned numberOfResourcesFromTheTop, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, WebPageProxy& webPageProxy) 133 static void submitTopList(unsigned numberOfResourcesFromTheTop, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, const WebResourceLoadStatisticsStore& store) 151 134 { 152 135 WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subframeUnderTopFrameOriginsGetter = [] (auto& t) { … … 182 165 String descriptionPreamble = preambleBuilder.toString(); 183 166 184 webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "PrevalentResourcesWithUserInteraction",167 store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "PrevalentResourcesWithUserInteraction", 185 168 topPrevalentResourcesWithUserInteraction, significantFiguresForLoggedValues, ShouldSample::No); 186 webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubframeUnderTopFrameOrigins",169 store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubframeUnderTopFrameOrigins", 187 170 topSubframeUnderTopFrameOrigins, significantFiguresForLoggedValues, ShouldSample::No); 188 webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUnderTopFrameOrigins",171 store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUnderTopFrameOrigins", 189 172 topSubresourceUnderTopFrameOrigins, significantFiguresForLoggedValues, ShouldSample::No); 190 webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUniqueRedirectsTo",173 store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUniqueRedirectsTo", 191 174 topSubresourceUniqueRedirectsTo, significantFiguresForLoggedValues, ShouldSample::No); 192 webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesDataRecordsRemoved",175 store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesDataRecordsRemoved", 193 176 topNumberOfTimesDataRecordsRemoved, significantFiguresForLoggedValues, ShouldSample::No); 194 webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToUserInteraction",177 store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToUserInteraction", 195 178 topNumberOfTimesAccessedAsFirstPartyDueToUserInteraction, significantFiguresForLoggedValues, ShouldSample::No); 196 webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI",179 store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI", 197 180 topNumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI, significantFiguresForLoggedValues, ShouldSample::No); 198 181 } 199 182 200 static void submitTopLists(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, WebPageProxy& webPageProxy)201 { 202 submitTopList(1, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy);183 static void submitTopLists(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, const WebResourceLoadStatisticsStore& store) 184 { 185 submitTopList(1, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store); 203 186 204 187 if (sortedPrevalentResourcesWithoutUserInteraction.size() < 3) 205 188 return; 206 submitTopList(3, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy);189 submitTopList(3, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store); 207 190 208 191 if (sortedPrevalentResourcesWithoutUserInteraction.size() < 10) 209 192 return; 210 submitTopList(10, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy);193 submitTopList(10, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store); 211 194 212 195 if (sortedPrevalentResourcesWithoutUserInteraction.size() < 50) 213 196 return; 214 submitTopList(50, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy);197 submitTopList(50, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store); 215 198 216 199 if (sortedPrevalentResourcesWithoutUserInteraction.size() < 100) 217 200 return; 218 submitTopList(100, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy);201 submitTopList(100, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store); 219 202 } 220 203 221 204 // This function is for testing purposes. 222 void static notifyPages(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) 223 { 224 RunLoop::main().dispatch([totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins] { 225 API::Dictionary::MapType messageBody; 226 messageBody.set("TotalPrevalentResources"_s, API::UInt64::create(totalPrevalentResources)); 227 messageBody.set("TotalPrevalentResourcesWithUserInteraction"_s, API::UInt64::create(totalPrevalentResourcesWithUserInteraction)); 228 messageBody.set("Top3SubframeUnderTopFrameOrigins"_s, API::UInt64::create(top3SubframeUnderTopFrameOrigins)); 229 WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr()); 205 void static notifyPages(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins, const WebResourceLoadStatisticsStore& store) 206 { 207 RunLoop::main().dispatch([totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins, store = makeRef(store)] { 208 store->notifyPageStatisticsTelemetryFinished(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins); 230 209 }); 231 210 } 232 211 233 212 // This function is for testing purposes. 234 void static notifyPages(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, unsigned totalNumberOfPrevalentResourcesWithUserInteraction )213 void static notifyPages(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, unsigned totalNumberOfPrevalentResourcesWithUserInteraction, const WebResourceLoadStatisticsStore& store) 235 214 { 236 215 WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subframeUnderTopFrameOriginsGetter = [] (const PrevalentResourceTelemetry& t) { … … 238 217 }; 239 218 240 notifyPages(sortedPrevalentResources.size(), totalNumberOfPrevalentResourcesWithUserInteraction, median(sortedPrevalentResourcesWithoutUserInteraction, 0, 2, subframeUnderTopFrameOriginsGetter) );219 notifyPages(sortedPrevalentResources.size(), totalNumberOfPrevalentResourcesWithUserInteraction, median(sortedPrevalentResourcesWithoutUserInteraction, 0, 2, subframeUnderTopFrameOriginsGetter), store); 241 220 } 242 221 … … 247 226 auto sortedPrevalentResources = sortedPrevalentResourceTelemetry(resourceLoadStatisticsStore); 248 227 if (notifyPagesWhenTelemetryWasCaptured && sortedPrevalentResources.isEmpty()) { 249 notifyPages(0, 0, 0 );228 notifyPages(0, 0, 0, resourceLoadStatisticsStore.store()); 250 229 return; 251 230 } … … 263 242 264 243 // Dispatch on the main thread to make sure the WebPageProxy we're using doesn't go away. 265 RunLoop::main().dispatch([sortedPrevalentResources = WTFMove(sortedPrevalentResources), sortedPrevalentResourcesWithoutUserInteraction = WTFMove(sortedPrevalentResourcesWithoutUserInteraction), prevalentResourcesDaysSinceUserInteraction = WTFMove(prevalentResourcesDaysSinceUserInteraction) ] () {266 auto webPageProxy = nonEphemeralWebPageProxy();244 RunLoop::main().dispatch([sortedPrevalentResources = WTFMove(sortedPrevalentResources), sortedPrevalentResourcesWithoutUserInteraction = WTFMove(sortedPrevalentResourcesWithoutUserInteraction), prevalentResourcesDaysSinceUserInteraction = WTFMove(prevalentResourcesDaysSinceUserInteraction), &resourceLoadStatisticsStore] () { 245 auto webPageProxy = WebPageProxy::nonEphemeralWebPageProxy(); 267 246 if (!webPageProxy) { 268 247 if (notifyPagesWhenTelemetryWasCaptured) 269 notifyPages(0, 0, 0 );248 notifyPages(0, 0, 0, resourceLoadStatisticsStore.store()); 270 249 return; 271 250 } 272 251 273 252 if (notifyPagesWhenTelemetryWasCaptured) { 274 notifyPages(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, prevalentResourcesDaysSinceUserInteraction.size() );253 notifyPages(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, prevalentResourcesDaysSinceUserInteraction.size(), resourceLoadStatisticsStore.store()); 275 254 // The notify pages function is for testing so we don't need to do an actual submission. 276 255 return; … … 285 264 webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), "medianPrevalentResourcesWithUserInteractionDaysSinceUserInteraction"_s, median(prevalentResourcesDaysSinceUserInteraction), significantFiguresForLoggedValues, ShouldSample::No); 286 265 287 submitTopLists(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, *webPageProxy);266 submitTopLists(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, resourceLoadStatisticsStore.store()); 288 267 }); 289 268 } … … 295 274 296 275 } 276 277 #endif -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.h
r239747 r240243 26 26 #pragma once 27 27 28 #if ENABLE(RESOURCE_LOAD_STATISTICS) 29 28 30 #include <wtf/text/WTFString.h> 29 31 … … 39 41 } 40 42 } 43 44 #endif -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
r240117 r240243 1 1 /* 2 * Copyright (C) 2012-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 50 50 #include "WebIDBConnectionToClient.h" 51 51 #include "WebIDBConnectionToClientMessages.h" 52 #include "WebResourceLoadStatisticsStore.h" 52 53 #include "WebSWServerConnection.h" 53 54 #include "WebSWServerConnectionMessages.h" … … 582 583 } 583 584 585 void NetworkConnectionToWebProcess::logUserInteraction(PAL::SessionID sessionID, const String& topLevelOrigin) 586 { 587 #if ENABLE(RESOURCE_LOAD_STATISTICS) 588 if (auto networkSession = networkProcess().networkSession(sessionID)) { 589 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 590 resourceLoadStatistics->logUserInteraction(topLevelOrigin, [] { }); 591 } 592 #else 593 UNUSED_PARAM(sessionID); 594 UNUSED_PARAM(topLevelOrigin); 595 #endif 596 } 597 584 598 void NetworkConnectionToWebProcess::addOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains) 585 599 { -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
r239835 r240243 1 1 /* 2 * Copyright (C) 2012-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 195 195 void removeStorageAccessForFrame(PAL::SessionID, uint64_t frameID, uint64_t pageID); 196 196 void removeStorageAccessForAllFramesOnPage(PAL::SessionID, uint64_t pageID); 197 void logUserInteraction(PAL::SessionID, const String& topLevelOrigin); 197 198 198 199 void addOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains); -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in
r239835 r240243 59 59 RemoveStorageAccessForFrame(PAL::SessionID sessionID, uint64_t frameID, uint64_t pageID); 60 60 RemoveStorageAccessForAllFramesOnPage(PAL::SessionID sessionID, uint64_t pageID); 61 #if ENABLE(RESOURCE_LOAD_STATISTICS) 62 LogUserInteraction(PAL::SessionID sessionID, String topLevelOrigin) 63 #endif 61 64 62 65 AddOriginAccessWhitelistEntry(String sourceOrigin, String destinationProtocol, String destinationHost, bool allowDestinationSubdomains); -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r240099 r240243 1 1 /* 2 * Copyright (C) 2012-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2018 Sony Interactive Entertainment Inc. 4 4 * … … 498 498 499 499 #if ENABLE(RESOURCE_LOAD_STATISTICS) 500 void NetworkProcess::dumpResourceLoadStatistics(PAL::SessionID sessionID, uint64_t contextId) 501 { 502 if (auto* networkSession = this->networkSession(sessionID)) { 503 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { 504 resourceLoadStatistics->dumpResourceLoadStatistics([this, contextId](const String& dumpedStatistics) { 505 parentProcessConnection()->send(Messages::NetworkProcessProxy::DidDumpResourceLoadStatistics(dumpedStatistics, contextId), 0); 506 }); 507 } 508 } else 509 ASSERT_NOT_REACHED(); 510 } 511 500 512 void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, uint64_t contextId) 501 513 { … … 505 517 } 506 518 519 void NetworkProcess::isGrandfathered(PAL::SessionID sessionID, const String& targetPrimaryDomain, CompletionHandler<void(bool)>&& completionHandler) 520 { 521 if (auto* networkSession = this->networkSession(sessionID)) { 522 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 523 resourceLoadStatistics->isGrandfathered(targetPrimaryDomain, WTFMove(completionHandler)); 524 } else 525 ASSERT_NOT_REACHED(); 526 } 527 528 void NetworkProcess::isPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) 529 { 530 if (auto* networkSession = this->networkSession(sessionID)) { 531 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 532 resourceLoadStatistics->isPrevalentResource(resourceDomain, WTFMove(completionHandler)); 533 } else 534 ASSERT_NOT_REACHED(); 535 } 536 537 void NetworkProcess::isVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) 538 { 539 if (auto* networkSession = this->networkSession(sessionID)) { 540 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 541 resourceLoadStatistics->isVeryPrevalentResource(resourceDomain, WTFMove(completionHandler)); 542 } else 543 ASSERT_NOT_REACHED(); 544 } 545 507 546 void NetworkProcess::setAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds, uint64_t contextId) 508 547 { … … 512 551 } 513 552 553 void NetworkProcess::setGrandfathered(PAL::SessionID sessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&& completionHandler) 554 { 555 if (auto* networkSession = this->networkSession(sessionID)) { 556 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 557 resourceLoadStatistics->setGrandfathered(resourceDomain, isGrandfathered, WTFMove(completionHandler)); 558 } else 559 ASSERT_NOT_REACHED(); 560 } 561 562 void NetworkProcess::setPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 563 { 564 if (auto* networkSession = this->networkSession(sessionID)) { 565 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 566 resourceLoadStatistics->setPrevalentResource(resourceDomain, WTFMove(completionHandler)); 567 } else 568 ASSERT_NOT_REACHED(); 569 } 570 571 void NetworkProcess::setPrevalentResourceForDebugMode(PAL::SessionID sessionID, String resourceDomain, CompletionHandler<void()>&& completionHandler) 572 { 573 if (auto* networkSession = this->networkSession(sessionID)) { 574 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 575 resourceLoadStatistics->setPrevalentResourceForDebugMode(resourceDomain, WTFMove(completionHandler)); 576 } else 577 ASSERT_NOT_REACHED(); 578 } 579 580 void NetworkProcess::setVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 581 { 582 if (auto* networkSession = this->networkSession(sessionID)) { 583 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 584 resourceLoadStatistics->setVeryPrevalentResource(resourceDomain, WTFMove(completionHandler)); 585 } else 586 ASSERT_NOT_REACHED(); 587 } 588 589 void NetworkProcess::clearPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 590 { 591 if (auto* networkSession = this->networkSession(sessionID)) { 592 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 593 resourceLoadStatistics->clearPrevalentResource(resourceDomain, WTFMove(completionHandler)); 594 } else 595 ASSERT_NOT_REACHED(); 596 } 597 598 void NetworkProcess::submitTelemetry(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) 599 { 600 if (auto* networkSession = this->networkSession(sessionID)) { 601 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 602 resourceLoadStatistics->submitTelemetry(WTFMove(completionHandler)); 603 } else 604 ASSERT_NOT_REACHED(); 605 } 606 607 void NetworkProcess::scheduleCookieBlockingUpdate(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) 608 { 609 if (auto* networkSession = this->networkSession(sessionID)) { 610 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 611 resourceLoadStatistics->scheduleCookieBlockingUpdate(WTFMove(completionHandler)); 612 } else 613 ASSERT_NOT_REACHED(); 614 } 615 616 void NetworkProcess::scheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, bool shouldGrandfather, CompletionHandler<void()>&& completionHandler) 617 { 618 if (auto* networkSession = this->networkSession(sessionID)) { 619 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { 620 auto grandfather = shouldGrandfather ? ShouldGrandfather::Yes : ShouldGrandfather::No; 621 if (modifiedSince) 622 resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince.value(), grandfather, WTFMove(completionHandler)); 623 else 624 resourceLoadStatistics->scheduleClearInMemoryAndPersistent(grandfather, WTFMove(completionHandler)); 625 } 626 } else 627 ASSERT_NOT_REACHED(); 628 } 629 630 void NetworkProcess::resetParametersToDefaultValues(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) 631 { 632 if (auto* networkSession = this->networkSession(sessionID)) { 633 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 634 resourceLoadStatistics->resetParametersToDefaultValues(WTFMove(completionHandler)); 635 } else 636 ASSERT_NOT_REACHED(); 637 } 638 639 void NetworkProcess::scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) 640 { 641 if (auto* networkSession = this->networkSession(sessionID)) { 642 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 643 resourceLoadStatistics->scheduleStatisticsAndDataRecordsProcessing(WTFMove(completionHandler)); 644 } else 645 ASSERT_NOT_REACHED(); 646 } 647 648 void NetworkProcess::setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) 649 { 650 if (auto* networkSession = this->networkSession(sessionID)) { 651 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 652 resourceLoadStatistics->setNotifyPagesWhenDataRecordsWereScanned(value, WTFMove(completionHandler)); 653 } else 654 ASSERT_NOT_REACHED(); 655 } 656 657 void NetworkProcess::setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) 658 { 659 if (auto* networkSession = this->networkSession(sessionID)) { 660 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 661 resourceLoadStatistics->setNotifyPagesWhenTelemetryWasCaptured(value, WTFMove(completionHandler)); 662 } else 663 ASSERT_NOT_REACHED(); 664 } 665 666 void NetworkProcess::setSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, String subframe, String topFrame, CompletionHandler<void()>&& completionHandler) 667 { 668 if (auto* networkSession = this->networkSession(sessionID)) { 669 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 670 resourceLoadStatistics->setSubframeUnderTopFrameOrigin(subframe, topFrame, WTFMove(completionHandler)); 671 } else 672 ASSERT_NOT_REACHED(); 673 } 674 675 void NetworkProcess::isRegisteredAsRedirectingTo(PAL::SessionID sessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&& completionHandler) 676 { 677 if (auto* networkSession = this->networkSession(sessionID)) { 678 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 679 resourceLoadStatistics->isRegisteredAsRedirectingTo(redirectedFrom, redirectedTo, WTFMove(completionHandler)); 680 } else 681 ASSERT_NOT_REACHED(); 682 } 683 684 void NetworkProcess::isRegisteredAsSubFrameUnder(PAL::SessionID sessionID, const String& subframe, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler) 685 { 686 if (auto* networkSession = this->networkSession(sessionID)) { 687 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 688 resourceLoadStatistics->isRegisteredAsSubFrameUnder(subframe, topFrame, WTFMove(completionHandler)); 689 } else 690 ASSERT_NOT_REACHED(); 691 } 692 693 void NetworkProcess::setSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, String subresource, String topFrame, CompletionHandler<void()>&& completionHandler) 694 { 695 if (auto* networkSession = this->networkSession(sessionID)) { 696 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 697 resourceLoadStatistics->setSubresourceUnderTopFrameOrigin(subresource, topFrame, WTFMove(completionHandler)); 698 } else 699 ASSERT_NOT_REACHED(); 700 } 701 702 void NetworkProcess::setSubresourceUniqueRedirectTo(PAL::SessionID sessionID, String subresource, String hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) 703 { 704 if (auto* networkSession = this->networkSession(sessionID)) { 705 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 706 resourceLoadStatistics->setSubresourceUniqueRedirectTo(subresource, hostNameRedirectedTo, WTFMove(completionHandler)); 707 } else 708 ASSERT_NOT_REACHED(); 709 } 710 711 void NetworkProcess::setSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, String subresource, String hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) 712 { 713 if (auto* networkSession = this->networkSession(sessionID)) { 714 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 715 resourceLoadStatistics->setSubresourceUniqueRedirectFrom(subresource, hostNameRedirectedFrom, WTFMove(completionHandler)); 716 } else 717 ASSERT_NOT_REACHED(); 718 } 719 720 void NetworkProcess::isRegisteredAsSubresourceUnder(PAL::SessionID sessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler) 721 { 722 if (auto* networkSession = this->networkSession(sessionID)) { 723 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 724 resourceLoadStatistics->isRegisteredAsSubresourceUnder(subresource, topFrame, WTFMove(completionHandler)); 725 } else 726 ASSERT_NOT_REACHED(); 727 } 728 729 void NetworkProcess::setTopFrameUniqueRedirectTo(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) 730 { 731 if (auto* networkSession = this->networkSession(sessionID)) { 732 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 733 resourceLoadStatistics->setTopFrameUniqueRedirectTo(topFrameHostName, hostNameRedirectedTo, WTFMove(completionHandler)); 734 } else 735 ASSERT_NOT_REACHED(); 736 } 737 738 void NetworkProcess::setTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) 739 { 740 if (auto* networkSession = this->networkSession(sessionID)) { 741 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 742 resourceLoadStatistics->setTopFrameUniqueRedirectFrom(topFrameHostName, hostNameRedirectedFrom, WTFMove(completionHandler)); 743 } else 744 ASSERT_NOT_REACHED(); 745 } 746 747 748 void NetworkProcess::setLastSeen(PAL::SessionID sessionID, const String& resourceDomain, Seconds seconds, CompletionHandler<void()>&& completionHandler) 749 { 750 if (auto* networkSession = this->networkSession(sessionID)) { 751 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 752 resourceLoadStatistics->setLastSeen(resourceDomain, seconds, WTFMove(completionHandler)); 753 } else 754 ASSERT_NOT_REACHED(); 755 } 756 514 757 void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId) 515 758 { 516 759 if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) 517 parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccess RequestResult(networkStorageSession->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID), contextId), 0);760 parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessOperationResult(networkStorageSession->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID), contextId), 0); 518 761 else 519 762 ASSERT_NOT_REACHED(); … … 528 771 } 529 772 530 void NetworkProcess::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId) 773 void NetworkProcess::hasStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) 774 { 775 if (auto* networkSession = this->networkSession(sessionID)) { 776 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 777 resourceLoadStatistics->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(completionHandler)); 778 } else 779 ASSERT_NOT_REACHED(); 780 } 781 782 void NetworkProcess::requestStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, uint64_t contextId) 783 { 784 if (auto* networkSession = this->networkSession(sessionID)) { 785 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { 786 resourceLoadStatistics->requestStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID, promptEnabled, [this, contextId](StorageAccessStatus promptAccepted) { 787 parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessRequestResult(static_cast<unsigned>(promptAccepted), contextId), 0); 788 }); 789 } 790 } else 791 ASSERT_NOT_REACHED(); 792 } 793 794 void NetworkProcess::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, uint64_t contextId) 531 795 { 532 796 bool isStorageGranted = false; … … 538 802 ASSERT_NOT_REACHED(); 539 803 540 parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccess RequestResult(isStorageGranted, contextId), 0);804 parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessOperationResult(isStorageGranted, contextId), 0); 541 805 } 542 806 … … 550 814 } 551 815 552 void NetworkProcess::logUserInteraction(PAL::SessionID sessionID, const String& targetPrimaryDomain, uint64_t contextId) 816 void NetworkProcess::logUserInteraction(PAL::SessionID sessionID, const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler) 817 { 818 if (auto* networkSession = this->networkSession(sessionID)) { 819 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 820 resourceLoadStatistics->logUserInteraction(targetPrimaryDomain, WTFMove(completionHandler)); 821 } else 822 ASSERT_NOT_REACHED(); 823 } 824 825 void NetworkProcess::hadUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) 553 826 { 554 827 if (auto* networkSession = this->networkSession(sessionID)) { 555 828 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { 556 resourceLoadStatistics->logUserInteraction(targetPrimaryDomain, [this, contextId] { 557 parentProcessConnection()->send(Messages::NetworkProcessProxy::DidLogUserInteraction(contextId), 0); 558 }); 829 resourceLoadStatistics->hasHadUserInteraction(resourceDomain, WTFMove(completionHandler)); 559 830 } 831 } else 832 ASSERT_NOT_REACHED(); 833 } 834 835 void NetworkProcess::clearUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 836 { 837 if (auto* networkSession = this->networkSession(sessionID)) { 838 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 839 resourceLoadStatistics->clearUserInteraction(resourceDomain, WTFMove(completionHandler)); 560 840 } else 561 841 ASSERT_NOT_REACHED(); … … 586 866 } 587 867 868 void NetworkProcess::setGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) 869 { 870 if (auto* networkSession = this->networkSession(sessionID)) { 871 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 872 resourceLoadStatistics->setGrandfatheringTime(seconds, WTFMove(completionHandler)); 873 } else 874 ASSERT_NOT_REACHED(); 875 } 876 877 void NetworkProcess::setMaxStatisticsEntries(PAL::SessionID sessionID, uint64_t maximumEntryCount, CompletionHandler<void()>&& completionHandler) 878 { 879 if (auto* networkSession = this->networkSession(sessionID)) { 880 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 881 resourceLoadStatistics->setMaxStatisticsEntries(maximumEntryCount, WTFMove(completionHandler)); 882 } else 883 ASSERT_NOT_REACHED(); 884 } 885 886 void NetworkProcess::setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) 887 { 888 if (auto* networkSession = this->networkSession(sessionID)) { 889 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 890 resourceLoadStatistics->setMinimumTimeBetweenDataRecordsRemoval(seconds, WTFMove(completionHandler)); 891 } else 892 ASSERT_NOT_REACHED(); 893 } 894 895 void NetworkProcess::setPruneEntriesDownTo(PAL::SessionID sessionID, uint64_t pruneTargetCount, CompletionHandler<void()>&& completionHandler) 896 { 897 if (auto* networkSession = this->networkSession(sessionID)) { 898 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 899 resourceLoadStatistics->setPruneEntriesDownTo(pruneTargetCount, WTFMove(completionHandler)); 900 } else 901 ASSERT_NOT_REACHED(); 902 } 903 904 void NetworkProcess::setTimeToLiveUserInteraction(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) 905 { 906 if (auto* networkSession = this->networkSession(sessionID)) { 907 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 908 resourceLoadStatistics->setTimeToLiveUserInteraction(seconds, WTFMove(completionHandler)); 909 } else 910 ASSERT_NOT_REACHED(); 911 } 912 913 void NetworkProcess::setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) 914 { 915 if (auto* networkSession = this->networkSession(sessionID)) { 916 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 917 resourceLoadStatistics->setShouldClassifyResourcesBeforeDataRecordsRemoval(value, WTFMove(completionHandler)); 918 } else 919 ASSERT_NOT_REACHED(); 920 } 921 922 void NetworkProcess::setResourceLoadStatisticsEnabled(bool enabled) 923 { 924 for (auto& networkSession : m_networkSessions.values()) 925 networkSession.get().setResourceLoadStatisticsEnabled(enabled); 926 } 927 928 void NetworkProcess::setResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode, CompletionHandler<void()>&& completionHandler) 929 { 930 if (auto* networkSession = this->networkSession(sessionID)) { 931 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 932 resourceLoadStatistics->setResourceLoadStatisticsDebugMode(debugMode, WTFMove(completionHandler)); 933 } else 934 ASSERT_NOT_REACHED(); 935 } 936 588 937 void NetworkProcess::resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, uint64_t contextId) 589 938 { … … 592 941 else 593 942 ASSERT_NOT_REACHED(); 594 parentProcessConnection()->send(Messages::NetworkProcessProxy::Did ResetCacheMaxAgeCapForPrevalentResources(contextId), 0);943 parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(contextId), 0); 595 944 } 596 945 #endif // ENABLE(RESOURCE_LOAD_STATISTICS) … … 651 1000 ~CallbackAggregator() 652 1001 { 653 ASSERT(RunLoop::isMain());654 655 1002 RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler), websiteData = WTFMove(m_websiteData)] () mutable { 656 1003 completionHandler(websiteData); … … 757 1104 if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral()) 758 1105 clearDiskCache(modifiedSince, [clearTasksHandler = WTFMove(clearTasksHandler)] { }); 1106 1107 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1108 if (websiteDataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) { 1109 if (auto* networkSession = this->networkSession(sessionID)) { 1110 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { 1111 auto deletedTypesRaw = websiteDataTypes.toRaw(); 1112 auto monitoredTypesRaw = WebResourceLoadStatisticsStore::monitoredDataTypes().toRaw(); 1113 1114 // If we are deleting all of the data types that the resource load statistics store monitors 1115 // we do not need to re-grandfather old data. 1116 auto shouldGrandfather = ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) ? ShouldGrandfather::No : ShouldGrandfather::Yes; 1117 1118 resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, [clearTasksHandler = clearTasksHandler.copyRef()] { }); 1119 } 1120 } 1121 } 1122 #endif 759 1123 } 760 1124 … … 822 1186 clearDiskCacheEntries(cache(), originDatas, [clearTasksHandler = WTFMove(clearTasksHandler)] { }); 823 1187 } 1188 1189 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1190 static Vector<String> filterForTopLevelDomains(const Vector<String>& topLevelDomains, const HashSet<String>& foundValues) 1191 { 1192 Vector<String> result; 1193 for (const auto& hostname : topLevelDomains) { 1194 if (foundValues.contains(hostname)) 1195 result.append(hostname); 1196 } 1197 1198 return result; 1199 } 1200 1201 static Vector<WebsiteData::Entry> filterForTopLevelDomains(const Vector<String>& topLevelDomains, const Vector<WebsiteData::Entry>& foundValues) 1202 { 1203 Vector<WebsiteData::Entry> result; 1204 for (const auto& value : foundValues) { 1205 if (topLevelDomains.contains(value.origin.host)) 1206 result.append(value); 1207 } 1208 1209 return result; 1210 } 1211 1212 void NetworkProcess::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler) 1213 { 1214 OptionSet<WebsiteDataFetchOption> fetchOptions = WebsiteDataFetchOption::DoNotCreateProcesses; 1215 1216 struct CallbackAggregator final : public RefCounted<CallbackAggregator> { 1217 explicit CallbackAggregator(CompletionHandler<void(const HashSet<String>&)>&& completionHandler) 1218 : m_completionHandler(WTFMove(completionHandler)) 1219 { 1220 } 1221 1222 ~CallbackAggregator() 1223 { 1224 RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler), websiteData = WTFMove(m_websiteData)] () mutable { 1225 HashSet<String> origins; 1226 for (const auto& hostnameWithCookies : websiteData.hostNamesWithCookies) 1227 origins.add(hostnameWithCookies); 1228 1229 for (const auto& hostnameWithHSTS : websiteData.hostNamesWithHSTSCache) 1230 origins.add(hostnameWithHSTS); 1231 1232 for (const auto& entry : websiteData.entries) 1233 origins.add(entry.origin.host); 1234 1235 completionHandler(origins); 1236 }); 1237 } 1238 1239 CompletionHandler<void(const HashSet<String>&)> m_completionHandler; 1240 WebsiteData m_websiteData; 1241 }; 1242 1243 auto callbackAggregator = adoptRef(*new CallbackAggregator([this, completionHandler = WTFMove(completionHandler), shouldNotifyPage] (const HashSet<String>& originsWithData) mutable { 1244 if (shouldNotifyPage) 1245 parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished(), 0); 1246 1247 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originsWithData = crossThreadCopy(originsWithData)] () mutable { 1248 completionHandler(originsWithData); 1249 }); 1250 })); 1251 1252 auto& websiteDataStore = callbackAggregator->m_websiteData; 1253 1254 Vector<String> hostnamesWithCookiesToDelete; 1255 if (websiteDataTypes.contains(WebsiteDataType::Cookies)) { 1256 if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) { 1257 networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies); 1258 hostnamesWithCookiesToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, websiteDataStore.hostNamesWithCookies); 1259 networkStorageSession->deleteCookiesForHostnames(hostnamesWithCookiesToDelete); 1260 } 1261 } 1262 1263 Vector<String> hostnamesWithHSTSToDelete; 1264 #if PLATFORM(COCOA) 1265 if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) { 1266 if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) { 1267 getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache); 1268 hostnamesWithHSTSToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, websiteDataStore.hostNamesWithHSTSCache); 1269 deleteHSTSCacheForHostNames(*networkStorageSession, hostnamesWithHSTSToDelete); 1270 } 1271 } 1272 #endif 1273 1274 /* 1275 // FIXME: No API to delete credentials by origin 1276 if (websiteDataTypes.contains(WebsiteDataType::Credentials)) { 1277 if (NetworkStorageSession::storageSession(sessionID)) 1278 websiteDataStore.originsWithCredentials = NetworkStorageSession::storageSession(sessionID)->credentialStorage().originsWithCredentials(); 1279 } 1280 */ 1281 1282 if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) { 1283 CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [this, topPrivatelyControlledDomains, sessionID, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1284 1285 auto entriesToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, entries); 1286 1287 callbackAggregator->m_websiteData.entries.appendVector(entriesToDelete); 1288 1289 for (auto& entry : entriesToDelete) 1290 CacheStorage::Engine::clearCachesForOrigin(*this, sessionID, SecurityOriginData { entry.origin }, [callbackAggregator = callbackAggregator.copyRef()] { }); 1291 }); 1292 } 1293 1294 #if ENABLE(INDEXED_DATABASE) 1295 auto path = m_idbDatabasePaths.get(sessionID); 1296 if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases)) { 1297 // FIXME: Pick the right database store based on the session ID. 1298 postStorageTask(CrossThreadTask([this, sessionID, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path), topPrivatelyControlledDomains]() mutable { 1299 RunLoop::main().dispatch([this, sessionID, topPrivatelyControlledDomains = crossThreadCopy(topPrivatelyControlledDomains), callbackAggregator = callbackAggregator.copyRef(), securityOrigins = indexedDatabaseOrigins(path)] { 1300 Vector<SecurityOriginData> entriesToDelete; 1301 for (const auto& securityOrigin : securityOrigins) { 1302 if (!topPrivatelyControlledDomains.contains(securityOrigin.host)) 1303 continue; 1304 1305 entriesToDelete.append(securityOrigin); 1306 callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::IndexedDBDatabases, 0 }); 1307 } 1308 1309 idbServer(sessionID).closeAndDeleteDatabasesForOrigins(entriesToDelete, [callbackAggregator = callbackAggregator.copyRef()] { }); 1310 }); 1311 })); 1312 } 1313 #endif 1314 1315 #if ENABLE(SERVICE_WORKER) 1316 path = m_swDatabasePaths.get(sessionID); 1317 if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) { 1318 swServerForSession(sessionID).getOriginsWithRegistrations([this, sessionID, topPrivatelyControlledDomains, callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& securityOrigins) mutable { 1319 for (auto& securityOrigin : securityOrigins) { 1320 if (!topPrivatelyControlledDomains.contains(securityOrigin.host)) 1321 continue; 1322 callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::ServiceWorkerRegistrations, 0 }); 1323 swServerForSession(sessionID).clear(securityOrigin, [callbackAggregator = callbackAggregator.copyRef()] { }); 1324 } 1325 }); 1326 } 1327 #endif 1328 1329 if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { 1330 fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [this, topPrivatelyControlledDomains, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1331 1332 Vector<SecurityOriginData> entriesToDelete; 1333 for (auto& entry : entries) { 1334 if (!topPrivatelyControlledDomains.contains(entry.origin.host)) 1335 continue; 1336 entriesToDelete.append(entry.origin); 1337 callbackAggregator->m_websiteData.entries.append(entry); 1338 } 1339 clearDiskCacheEntries(cache(), entriesToDelete, [callbackAggregator = callbackAggregator.copyRef()] { }); 1340 }); 1341 } 1342 } 1343 1344 void NetworkProcess::topPrivatelyControlledDomainsWithWebsiteData(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler) 1345 { 1346 OptionSet<WebsiteDataFetchOption> fetchOptions = WebsiteDataFetchOption::DoNotCreateProcesses; 1347 1348 struct CallbackAggregator final : public RefCounted<CallbackAggregator> { 1349 explicit CallbackAggregator(CompletionHandler<void(HashSet<String>&&)>&& completionHandler) 1350 : m_completionHandler(WTFMove(completionHandler)) 1351 { 1352 } 1353 1354 ~CallbackAggregator() 1355 { 1356 RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler), websiteData = WTFMove(m_websiteData)] () mutable { 1357 HashSet<String> origins; 1358 for (const auto& hostnameWithCookies : websiteData.hostNamesWithCookies) 1359 origins.add(hostnameWithCookies); 1360 1361 for (const auto& hostnameWithHSTS : websiteData.hostNamesWithHSTSCache) 1362 origins.add(hostnameWithHSTS); 1363 1364 for (const auto& entry : websiteData.entries) 1365 origins.add(entry.origin.host); 1366 1367 completionHandler(WTFMove(origins)); 1368 }); 1369 } 1370 1371 CompletionHandler<void(HashSet<String>&&)> m_completionHandler; 1372 WebsiteData m_websiteData; 1373 }; 1374 1375 auto callbackAggregator = adoptRef(*new CallbackAggregator([this, completionHandler = WTFMove(completionHandler), shouldNotifyPage] (HashSet<String>&& originsWithData) mutable { 1376 if (shouldNotifyPage) 1377 parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished(), 0); 1378 1379 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originsWithData = crossThreadCopy(originsWithData)] () mutable { 1380 completionHandler(WTFMove(originsWithData)); 1381 }); 1382 })); 1383 1384 auto& websiteDataStore = callbackAggregator->m_websiteData; 1385 1386 Vector<String> hostnamesWithCookiesToDelete; 1387 if (websiteDataTypes.contains(WebsiteDataType::Cookies)) { 1388 if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) 1389 networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies); 1390 } 1391 1392 Vector<String> hostnamesWithHSTSToDelete; 1393 #if PLATFORM(COCOA) 1394 if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) { 1395 if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) 1396 getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache); 1397 } 1398 #endif 1399 1400 if (websiteDataTypes.contains(WebsiteDataType::Credentials)) { 1401 if (NetworkStorageSession::storageSession(sessionID)) 1402 websiteDataStore.originsWithCredentials = NetworkStorageSession::storageSession(sessionID)->credentialStorage().originsWithCredentials(); 1403 } 1404 1405 if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) { 1406 CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1407 callbackAggregator->m_websiteData.entries.appendVector(entries); 1408 }); 1409 } 1410 1411 #if ENABLE(INDEXED_DATABASE) 1412 auto path = m_idbDatabasePaths.get(sessionID); 1413 if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases)) { 1414 // FIXME: Pick the right database store based on the session ID. 1415 postStorageTask(CrossThreadTask([this, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path)]() mutable { 1416 RunLoop::main().dispatch([callbackAggregator = callbackAggregator.copyRef(), securityOrigins = indexedDatabaseOrigins(path)] { 1417 for (const auto& securityOrigin : securityOrigins) 1418 callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::IndexedDBDatabases, 0 }); 1419 }); 1420 })); 1421 } 1422 #endif 1423 1424 #if ENABLE(SERVICE_WORKER) 1425 path = m_swDatabasePaths.get(sessionID); 1426 if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) { 1427 swServerForSession(sessionID).getOriginsWithRegistrations([callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& securityOrigins) mutable { 1428 for (auto& securityOrigin : securityOrigins) 1429 callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::ServiceWorkerRegistrations, 0 }); 1430 }); 1431 } 1432 #endif 1433 1434 if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { 1435 fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1436 callbackAggregator->m_websiteData.entries.appendVector(entries); 1437 }); 1438 } 1439 } 1440 #endif // ENABLE(RESOURCE_LOAD_STATISTICS) 824 1441 825 1442 CacheStorage::Engine* NetworkProcess::findCacheEngine(const PAL::SessionID& sessionID) -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r240099 r240243 160 160 161 161 #if ENABLE(RESOURCE_LOAD_STATISTICS) 162 void clearPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); 163 void clearUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); 164 void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(PAL::SessionID, OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&); 165 void dumpResourceLoadStatistics(PAL::SessionID, uint64_t contextId); 162 166 void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, uint64_t contextId); 167 void isGrandfathered(PAL::SessionID, const String& targetPrimaryDomain, CompletionHandler<void(bool)>&&); 168 void isPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); 169 void isVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); 163 170 void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, uint64_t contextId); 171 void isRegisteredAsRedirectingTo(PAL::SessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&&); 172 void isRegisteredAsSubFrameUnder(PAL::SessionID, const String& subframe, const String& topFrame, CompletionHandler<void(bool)>&&); 173 void isRegisteredAsSubresourceUnder(PAL::SessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&&); 174 void setGrandfathered(PAL::SessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&&); 175 void setMaxStatisticsEntries(PAL::SessionID, uint64_t maximumEntryCount, CompletionHandler<void()>&&); 176 void setPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); 177 void setPrevalentResourceForDebugMode(PAL::SessionID, String resourceDomain, CompletionHandler<void()>&&); 178 void setVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); 179 void setPruneEntriesDownTo(PAL::SessionID, uint64_t pruneTargetCount, CompletionHandler<void()>&&); 180 void hadUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); 164 181 void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId); 165 182 void getAllStorageAccessEntries(PAL::SessionID, uint64_t contextId); 166 void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId); 183 void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, uint64_t contextId); 184 void hasStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); 167 185 void logFrameNavigation(PAL::SessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame); 168 void logUserInteraction(PAL::SessionID, const String& targetPrimaryDomain, uint64_t contextId);186 void logUserInteraction(PAL::SessionID, const String& targetPrimaryDomain, CompletionHandler<void()>&&); 169 187 void removeAllStorageAccess(PAL::SessionID, uint64_t contextId); 170 188 void removePrevalentDomains(PAL::SessionID, const Vector<String>& domains); 189 void requestStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, uint64_t contextId); 190 void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, uint64_t contextId); 191 void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&); 192 void scheduleClearInMemoryAndPersistent(PAL::SessionID, Optional<WallTime> modifiedSince, bool shouldGrandfather, CompletionHandler<void()>&&); 193 void scheduleCookieBlockingUpdate(PAL::SessionID, CompletionHandler<void()>&&); 194 void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, CompletionHandler<void()>&&); 195 void submitTelemetry(PAL::SessionID, CompletionHandler<void()>&&); 171 196 void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, uint64_t contextId); 172 void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, uint64_t contextId); 197 void setGrandfatheringTime(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 198 void setLastSeen(PAL::SessionID, const String& resourceDomain, Seconds, CompletionHandler<void()>&&); 199 void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 200 void setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID, bool value, CompletionHandler<void()>&&); 201 void setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID, bool value, CompletionHandler<void()>&&); 202 void setResourceLoadStatisticsEnabled(bool); 203 void setResourceLoadStatisticsDebugMode(PAL::SessionID, bool debugMode, CompletionHandler<void()>&&d); 204 void setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID, bool value, CompletionHandler<void()>&&); 205 void setSubframeUnderTopFrameOrigin(PAL::SessionID, String subframe, String topFrame, CompletionHandler<void()>&&); 206 void setSubresourceUnderTopFrameOrigin(PAL::SessionID, String subresource, String topFrame, CompletionHandler<void()>&&); 207 void setSubresourceUniqueRedirectTo(PAL::SessionID, String subresource, String hostNameRedirectedTo, CompletionHandler<void()>&&); 208 void setSubresourceUniqueRedirectFrom(PAL::SessionID, String subresource, String hostNameRedirectedFrom, CompletionHandler<void()>&&); 209 void setTimeToLiveUserInteraction(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 210 void setTopFrameUniqueRedirectTo(PAL::SessionID, String topFrameHostName, String hostNameRedirectedTo, CompletionHandler<void()>&&); 211 void setTopFrameUniqueRedirectFrom(PAL::SessionID, String topFrameHostName, String hostNameRedirectedFrom, CompletionHandler<void()>&&); 212 void topPrivatelyControlledDomainsWithWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&); 173 213 #endif 174 214 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r239816 r240243 86 86 87 87 #if ENABLE(RESOURCE_LOAD_STATISTICS) 88 ClearPrevalentResource(PAL::SessionID sessionID, String resourceDomain) -> () Async 89 ClearUserInteraction(PAL::SessionID sessionID, String resourceDomain) -> () Async 90 DumpResourceLoadStatistics(PAL::SessionID sessionID, uint64_t contextId) 91 SetResourceLoadStatisticsEnabled(bool enabled) 88 92 UpdatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, Vector<String> domainsToBlock, uint64_t contextId) 93 IsGrandfathered(PAL::SessionID sessionID, String targetPrimaryDomain) -> (bool isGrandfathered) Async 94 IsPrevalentResource(PAL::SessionID sessionID, String targetPrimaryDomain) -> (bool isPrevalent) Async 95 IsVeryPrevalentResource(PAL::SessionID sessionID, String targetPrimaryDomain) -> (bool isVeryPrevalent) Async 89 96 SetAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds, uint64_t contextId) 97 SetLastSeen(PAL::SessionID sessionID, String resourceDomain, Seconds seconds) -> () Async 98 SetPrevalentResource(PAL::SessionID sessionID, String resourceDomain) -> () Async 99 SetPrevalentResourceForDebugMode(PAL::SessionID sessionID, String resourceDomain) -> () Async 100 HadUserInteraction(PAL::SessionID sessionID, String resourceDomain) -> (bool hadUserInteraction) Async 90 101 HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId) 102 HasStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID) -> (bool hadUserInteraction) Async 91 103 GetAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId) 92 GrantStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId) 104 GrantStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, uint64_t contextId) 105 IsRegisteredAsRedirectingTo(PAL::SessionID sessionID, String redirectedFrom, String redirectedTo) -> (bool isRedirectingTo) Async 106 IsRegisteredAsSubFrameUnder(PAL::SessionID sessionID, String subframe, String topFrame) -> (bool isSubframeUnder) Async 107 IsRegisteredAsSubresourceUnder(PAL::SessionID sessionID, String subresource, String topFrame) -> (bool isSubresourceUnder) Async 93 108 LogFrameNavigation(PAL::SessionID sessionID, String targetPrimaryDomain, String mainFramePrimaryDomain, String sourcePrimaryDomain, String targetHost, String mainFrameHost, bool isRedirect, bool isMainFrame) 94 LogUserInteraction(PAL::SessionID sessionID, String targetPrimaryDomain , uint64_t contextId)109 LogUserInteraction(PAL::SessionID sessionID, String targetPrimaryDomain) -> () Async 95 110 RemoveAllStorageAccess(PAL::SessionID sessionID, uint64_t contextId) 96 111 RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction) 112 RequestStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, uint64_t contextId) 113 ResetParametersToDefaultValues(PAL::SessionID sessionID) -> () Async 114 ScheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, bool shouldGrandfather) -> () Async 115 ScheduleCookieBlockingUpdate(PAL::SessionID sessionID) -> () Async 116 ScheduleStatisticsAndDataRecordsProcessing(PAL::SessionID sessionID) -> () Async 117 SubmitTelemetry(PAL::SessionID sessionID) -> () Async 97 118 SetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId) 119 SetGrandfathered(PAL::SessionID sessionID, String resourceDomain, bool isGrandfathered) -> () Async 120 SetGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds) -> () Async 121 SetMaxStatisticsEntries(PAL::SessionID sessionID, uint64_t maximumEntryCount) -> () Async 122 SetMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID sessionID, Seconds seconds) -> () Async 123 SetPruneEntriesDownTo(PAL::SessionID sessionID, uint64_t maximumEntryCount) -> () Async 124 SetShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID sessionID, bool value) -> () Async 125 SetNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID sessionID, bool value) -> () Async 126 SetNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value) -> () Async 127 SetResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode) -> () Async 128 SetVeryPrevalentResource(PAL::SessionID sessionID, String resourceDomain) -> () Async 129 SetSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, String subframe, String topFrame) -> () Async 130 SetSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, String subresource, String topFrame) -> () Async 131 SetSubresourceUniqueRedirectTo(PAL::SessionID sessionID, String subresource, String hostNameRedirectedTo) -> () Async 132 SetSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, String subresource, String hostNameRedirectedFrom) -> () Async 133 SetTimeToLiveUserInteraction(PAL::SessionID sessionID, Seconds seconds) -> () Async 134 SetTopFrameUniqueRedirectTo(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedTo) -> () Async 135 SetTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedFrom) -> () Async 98 136 ResetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, uint64_t contextId) 99 137 #endif -
trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp
r239816 r240243 27 27 #include "NetworkSession.h" 28 28 29 #include "NetworkProcess.h" 30 #include "NetworkProcessProxyMessages.h" 31 #include "WebProcessProxy.h" 29 32 #include "WebResourceLoadStatisticsStore.h" 30 33 #include <WebCore/NetworkStorageSession.h> … … 79 82 } 80 83 81 void NetworkSession::enableResourceLoadStatistics() 84 #if ENABLE(RESOURCE_LOAD_STATISTICS) 85 void NetworkSession::setResourceLoadStatisticsEnabled(bool enable) 82 86 { 87 if (!enable) { 88 m_resourceLoadStatistics = nullptr; 89 return; 90 } 91 83 92 if (m_resourceLoadStatistics) 84 93 return; … … 87 96 } 88 97 98 void NetworkSession::notifyResourceLoadStatisticsProcessed() 99 { 100 m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyResourceLoadStatisticsProcessed(), 0); 101 } 102 103 void NetworkSession::logDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned significantFigures, WebCore::ShouldSample shouldSample) 104 { 105 m_networkProcess->parentProcessConnection()->send(Messages::WebPageProxy::LogDiagnosticMessageWithValue(message, description, value, significantFigures, shouldSample), 0); 106 } 107 108 void NetworkSession::notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) 109 { 110 m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyResourceLoadStatisticsTelemetryFinished(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins), 0); 111 } 112 113 void NetworkSession::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler) 114 { 115 m_networkProcess->deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(m_sessionID, dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler)); 116 } 117 118 void NetworkSession::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler) 119 { 120 m_networkProcess->topPrivatelyControlledDomainsWithWebsiteData(m_sessionID, dataTypes, shouldNotifyPage, WTFMove(completionHandler)); 121 } 122 #endif 123 89 124 } // namespace WebKit -
trunk/Source/WebKit/NetworkProcess/NetworkSession.h
r239816 r240243 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 namespace WebCore { 37 37 class NetworkStorageSession; 38 enum class ShouldSample : bool; 38 39 } 39 40 … … 45 46 struct NetworkSessionCreationParameters; 46 47 48 enum class WebsiteDataType; 49 47 50 class NetworkSession : public RefCounted<NetworkSession>, public CanMakeWeakPtr<NetworkSession> { 48 51 public: … … 62 65 void unregisterNetworkDataTask(NetworkDataTask& task) { m_dataTaskSet.remove(&task); } 63 66 67 #if ENABLE(RESOURCE_LOAD_STATISTICS) 64 68 WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); } 65 void enableResourceLoadStatistics(); 66 69 void setResourceLoadStatisticsEnabled(bool); 70 void notifyResourceLoadStatisticsProcessed(); 71 void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&); 72 void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&); 73 void logDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned significantFigures, WebCore::ShouldSample); 74 void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins); 75 #endif 76 67 77 protected: 68 78 NetworkSession(NetworkProcess&, PAL::SessionID); … … 72 82 HashSet<NetworkDataTask*> m_dataTaskSet; 73 83 String m_resourceLoadStatisticsDirectory; 84 #if ENABLE(RESOURCE_LOAD_STATISTICS) 74 85 RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics; 86 #endif 75 87 }; 76 88 -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
r239815 r240243 349 349 request.setFirstPartyForCookies(request.url()); 350 350 351 bool shouldBlockCookies = false;352 351 #if ENABLE(RESOURCE_LOAD_STATISTICS) 353 shouldBlockCookies = m_session->networkStorageSession().shouldBlockCookies(request, m_frameID, m_pageID);352 bool shouldBlockCookies = m_session->networkStorageSession().shouldBlockCookies(request, m_frameID, m_pageID); 354 353 #if !RELEASE_LOG_DISABLED 355 354 if (m_session->shouldLogCookieInformation()) … … 379 378 m_client->willPerformHTTPRedirection(WTFMove(redirectResponse), WTFMove(request), [completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)] (auto&& request) mutable { 380 379 if (!request.isNull()) { 380 #if ENABLE(RESOURCE_LOAD_STATISTICS) 381 381 bool shouldBlockCookies = m_session->networkStorageSession().shouldBlockCookies(request, m_frameID, m_pageID); 382 #else 383 bool shouldBlockCookies = false; 384 #endif 382 385 restrictRequestReferrerToOriginIfNeeded(request, shouldBlockCookies); 383 386 } -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r239884 r240243 378 378 } 379 379 380 #if HAVE(CFNETWORK_WITH_IGNORE_HSTS) 380 #if HAVE(CFNETWORK_WITH_IGNORE_HSTS) && ENABLE(RESOURCE_LOAD_STATISTICS) 381 381 static NSURLRequest* downgradeRequest(NSURLRequest *request) 382 382 { … … 399 399 && [request _schemeWasUpgradedDueToDynamicHSTS]; 400 400 } 401 401 #endif 402 403 #if HAVE(CFNETWORK_WITH_IGNORE_HSTS) 402 404 static void setIgnoreHSTS(NSMutableURLRequest *request, bool ignoreHSTS) 403 405 { … … 445 447 446 448 bool shouldIgnoreHSTS = false; 447 #if HAVE(CFNETWORK_WITH_IGNORE_HSTS) 449 #if HAVE(CFNETWORK_WITH_IGNORE_HSTS) && ENABLE(RESOURCE_LOAD_STATISTICS) 448 450 shouldIgnoreHSTS = schemeWasUpgradedDueToDynamicHSTS(request) && WebCore::NetworkStorageSession::storageSession(_session->sessionID())->shouldBlockCookies(request, networkDataTask->frameID(), networkDataTask->pageID()); 449 451 if (shouldIgnoreHSTS) { … … 478 480 if (auto* networkDataTask = [self existingTask:task]) { 479 481 bool shouldIgnoreHSTS = false; 480 #if HAVE(CFNETWORK_WITH_IGNORE_HSTS) 482 #if HAVE(CFNETWORK_WITH_IGNORE_HSTS) && ENABLE(RESOURCE_LOAD_STATISTICS) 481 483 shouldIgnoreHSTS = schemeWasUpgradedDueToDynamicHSTS(request) && WebCore::NetworkStorageSession::storageSession(_session->sessionID())->shouldBlockCookies(request, networkDataTask->frameID(), networkDataTask->pageID()); 482 484 if (shouldIgnoreHSTS) { … … 945 947 m_statelessSession = [NSURLSession sessionWithConfiguration:configuration delegate:static_cast<id>(m_statelessSessionDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]]; 946 948 949 #if ENABLE(RESOURCE_LOAD_STATISTICS) 947 950 m_resourceLoadStatisticsDirectory = parameters.resourceLoadStatisticsDirectory; 948 if (parameters.enableResourceLoadStatistics)949 enableResourceLoadStatistics(); 951 setResourceLoadStatisticsEnabled(parameters.enableResourceLoadStatistics); 952 #endif 950 953 } 951 954 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r239752 r240243 37 37 #include "WKString.h" 38 38 #include "WebResourceLoadStatisticsStore.h" 39 #include "WebResourceLoadStatisticsTelemetry.h"40 39 #include "WebsiteData.h" 41 40 #include "WebsiteDataFetchOption.h" … … 77 76 void WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler(WKWebsiteDataStoreRef dataStoreRef, bool enable, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler) 78 77 { 79 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 80 if (!store){78 #if ENABLE(RESOURCE_LOAD_STATISTICS) 79 WebKit::toImpl(dataStoreRef)->websiteDataStore().setResourceLoadStatisticsDebugMode(enable, [context, completionHandler] { 81 80 completionHandler(context); 82 return; 83 } 84 85 store->setResourceLoadStatisticsDebugMode(enable, [context, completionHandler] { 81 }); 82 #else 83 completionHandler(context); 84 #endif 85 } 86 87 void WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler) 88 { 89 #if ENABLE(RESOURCE_LOAD_STATISTICS) 90 WebKit::toImpl(dataStoreRef)->websiteDataStore().setPrevalentResourceForDebugMode(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { 86 91 completionHandler(context); 87 92 }); 88 } 89 90 void WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler) 91 { 92 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 93 if (!store) { 93 #else 94 completionHandler(context); 95 #endif 96 } 97 void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler) 98 { 99 #if ENABLE(RESOURCE_LOAD_STATISTICS) 100 WebKit::toImpl(dataStoreRef)->websiteDataStore().setLastSeen(URL(URL(), WebKit::toImpl(host)->string()), Seconds { seconds }, [context, completionHandler] { 94 101 completionHandler(context); 95 return; 96 } 97 98 store->setPrevalentResourceForDebugMode(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { 99 completionHandler(context); 100 }); 101 } 102 void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler) 103 { 104 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 105 if (!store) { 106 completionHandler(context); 107 return; 108 } 109 110 store->setLastSeen(URL(URL(), WebKit::toImpl(host)->string()), Seconds { seconds }, [context, completionHandler] { 111 completionHandler(context); 112 }); 102 }); 103 #else 104 completionHandler(context); 105 #endif 113 106 } 114 107 115 108 void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsPrevalentResourceFunction completionHandler) 116 109 { 117 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 118 if (!store) { 119 completionHandler(context); 120 return; 121 } 110 #if ENABLE(RESOURCE_LOAD_STATISTICS) 111 auto& websiteDataStore = WebKit::toImpl(dataStoreRef)->websiteDataStore(); 122 112 123 113 if (value) 124 store->setPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {114 websiteDataStore.setPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { 125 115 completionHandler(context); 126 116 }); 127 117 else 128 store->clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {118 websiteDataStore.clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { 129 119 completionHandler(context); 130 120 }); 121 #else 122 completionHandler(context); 123 #endif 131 124 } 132 125 133 126 void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction completionHandler) 134 127 { 135 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 136 if (!store) { 137 completionHandler(context); 138 return; 139 } 128 #if ENABLE(RESOURCE_LOAD_STATISTICS) 129 auto& websiteDataStore = WebKit::toImpl(dataStoreRef)->websiteDataStore(); 140 130 141 131 if (value) 142 store->setVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {132 websiteDataStore.setVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { 143 133 completionHandler(context); 144 134 }); 145 135 else 146 store->clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {136 websiteDataStore.clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { 147 137 completionHandler(context); 148 138 }); 139 #else 140 completionHandler(context); 141 #endif 149 142 } 150 143 151 144 void WKWebsiteDataStoreDumpResourceLoadStatistics(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreDumpResourceLoadStatisticsFunction callback) 152 145 { 153 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 154 if (!store) { 155 callback(WebKit::toAPI(emptyString().impl()), context); 156 return; 157 } 158 159 store->dumpResourceLoadStatistics([context, callback] (const String& resourceLoadStatistics) { 146 #if ENABLE(RESOURCE_LOAD_STATISTICS) 147 WebKit::toImpl(dataStoreRef)->websiteDataStore().dumpResourceLoadStatistics([context, callback] (const String& resourceLoadStatistics) { 160 148 callback(WebKit::toAPI(resourceLoadStatistics.impl()), context); 161 149 }); 150 #else 151 callback(WebKit::toAPI(emptyString().impl()), context); 152 #endif 162 153 } 163 154 164 155 void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback) 165 156 { 166 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 167 if (!store) { 168 callback(false, context); 169 return; 170 } 171 172 store->isPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isPrevalentResource) { 157 #if ENABLE(RESOURCE_LOAD_STATISTICS) 158 WebKit::toImpl(dataStoreRef)->websiteDataStore().isPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isPrevalentResource) { 173 159 callback(isPrevalentResource, context); 174 160 }); 161 #else 162 callback(false, context); 163 #endif 175 164 } 176 165 177 166 void WKWebsiteDataStoreIsStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback) 178 167 { 179 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 180 if (!store) { 181 callback(false, context); 182 return; 183 } 184 185 store->isVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isVeryPrevalentResource) { 168 #if ENABLE(RESOURCE_LOAD_STATISTICS) 169 WebKit::toImpl(dataStoreRef)->websiteDataStore().isVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isVeryPrevalentResource) { 186 170 callback(isVeryPrevalentResource, context); 187 171 }); 172 #else 173 callback(false, context); 174 #endif 188 175 } 189 176 190 177 void WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subresourceHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnderFunction callback) 191 178 { 192 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 193 if (!store) { 194 callback(false, context); 195 return; 196 } 197 198 store->isRegisteredAsSubresourceUnder(URL(URL(), WebKit::toImpl(subresourceHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubresourceUnder) { 179 #if ENABLE(RESOURCE_LOAD_STATISTICS) 180 WebKit::toImpl(dataStoreRef)->websiteDataStore().isRegisteredAsSubresourceUnder(URL(URL(), WebKit::toImpl(subresourceHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubresourceUnder) { 199 181 callback(isRegisteredAsSubresourceUnder, context); 200 182 }); 183 #else 184 callback(false, context); 185 #endif 201 186 } 202 187 203 188 void WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subFrameHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnderFunction callback) 204 189 { 205 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 206 if (!store) { 207 callback(false, context); 208 return; 209 } 210 211 store->isRegisteredAsSubFrameUnder(URL(URL(), WebKit::toImpl(subFrameHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubFrameUnder) { 190 #if ENABLE(RESOURCE_LOAD_STATISTICS) 191 WebKit::toImpl(dataStoreRef)->websiteDataStore().isRegisteredAsSubFrameUnder(URL(URL(), WebKit::toImpl(subFrameHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubFrameUnder) { 212 192 callback(isRegisteredAsSubFrameUnder, context); 213 193 }); 194 #else 195 callback(false, context); 196 #endif 214 197 } 215 198 216 199 void WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef hostRedirectedFrom, WKStringRef hostRedirectedTo, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingToFunction callback) 217 200 { 218 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 219 if (!store) { 220 callback(false, context); 221 return; 222 } 223 224 store->isRegisteredAsRedirectingTo(URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [context, callback](bool isRegisteredAsRedirectingTo) { 201 #if ENABLE(RESOURCE_LOAD_STATISTICS) 202 WebKit::toImpl(dataStoreRef)->websiteDataStore().isRegisteredAsRedirectingTo(URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [context, callback](bool isRegisteredAsRedirectingTo) { 225 203 callback(isRegisteredAsRedirectingTo, context); 226 204 }); 205 #else 206 callback(false, context); 207 #endif 227 208 } 228 209 229 210 void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction completionHandler) 230 211 { 231 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 232 if (!store) { 233 completionHandler(context); 234 return; 235 } 212 #if ENABLE(RESOURCE_LOAD_STATISTICS) 213 auto& dataStore = WebKit::toImpl(dataStoreRef)->websiteDataStore(); 236 214 237 215 if (value) 238 store->logUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {216 dataStore.logUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { 239 217 completionHandler(context); 240 218 }); 241 219 else 242 store->clearUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {220 dataStore.clearUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { 243 221 completionHandler(context); 244 222 }); 223 #else 224 completionHandler(context); 225 #endif 245 226 } 246 227 247 228 void WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction callback) 248 229 { 249 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 250 if (!store) { 251 callback(false, context); 252 return; 253 } 254 255 store->hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool hasHadUserInteraction) { 230 #if ENABLE(RESOURCE_LOAD_STATISTICS) 231 WebKit::toImpl(dataStoreRef)->websiteDataStore().hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool hasHadUserInteraction) { 256 232 callback(hasHadUserInteraction, context); 257 233 }); 234 #else 235 callback(false, context); 236 #endif 258 237 } 259 238 260 239 void WKWebsiteDataStoreSetStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value) 261 240 { 262 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 263 if (!store) 264 return; 265 266 store->setGrandfathered(URL(URL(), WebKit::toImpl(host)->string()), value); 241 #if ENABLE(RESOURCE_LOAD_STATISTICS) 242 WebKit::toImpl(dataStoreRef)->websiteDataStore().setGrandfathered(URL(URL(), WebKit::toImpl(host)->string()), value, [] { }); 243 #endif 267 244 } 268 245 269 246 void WKWebsiteDataStoreIsStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsGrandfatheredFunction callback) 270 247 { 271 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 272 if (!store) { 273 callback(false, context); 274 return; 275 } 276 277 store->hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isGrandfathered) { 248 #if ENABLE(RESOURCE_LOAD_STATISTICS) 249 WebKit::toImpl(dataStoreRef)->websiteDataStore().hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isGrandfathered) { 278 250 callback(isGrandfathered, context); 279 251 }); 252 #else 253 callback(false, context); 254 #endif 280 255 } 281 256 282 257 void WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost) 283 258 { 284 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 285 if (!store) 286 return; 287 288 store->setSubframeUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string())); 259 #if ENABLE(RESOURCE_LOAD_STATISTICS) 260 WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubframeUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [] { }); 261 #endif 289 262 } 290 263 291 264 void WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost) 292 265 { 293 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 294 if (!store) 295 return; 296 297 store->setSubresourceUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string())); 266 #if ENABLE(RESOURCE_LOAD_STATISTICS) 267 WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubresourceUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [] { }); 268 #endif 298 269 } 299 270 300 271 void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo) 301 272 { 302 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 303 if (!store) 304 return; 305 306 store->setSubresourceUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string())); 273 #if ENABLE(RESOURCE_LOAD_STATISTICS) 274 WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubresourceUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [] { }); 275 #endif 307 276 } 308 277 309 278 void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom) 310 279 { 311 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 312 if (!store) 313 return; 314 315 store->setSubresourceUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string())); 280 #if ENABLE(RESOURCE_LOAD_STATISTICS) 281 WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubresourceUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), [] { }); 282 #endif 316 283 } 317 284 318 285 void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo) 319 286 { 320 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 321 if (!store) 322 return; 323 324 store->setTopFrameUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string())); 287 #if ENABLE(RESOURCE_LOAD_STATISTICS) 288 WebKit::toImpl(dataStoreRef)->websiteDataStore().setTopFrameUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [] { }); 289 #endif 325 290 } 326 291 327 292 void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom) 328 293 { 329 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 330 if (!store) 331 return; 332 333 store->setTopFrameUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string())); 294 #if ENABLE(RESOURCE_LOAD_STATISTICS) 295 WebKit::toImpl(dataStoreRef)->websiteDataStore().setTopFrameUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), [] { }); 296 #endif 334 297 } 335 298 336 299 void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds) 337 300 { 338 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 339 if (!store) 340 return; 341 342 store->setTimeToLiveUserInteraction(Seconds { seconds }); 301 #if ENABLE(RESOURCE_LOAD_STATISTICS) 302 WebKit::toImpl(dataStoreRef)->websiteDataStore().setTimeToLiveUserInteraction(Seconds { seconds }, [] { }); 303 #endif 343 304 } 344 305 345 306 void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef) 346 307 { 347 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 348 if (!store) 349 return; 350 351 store->scheduleStatisticsAndDataRecordsProcessing(); 308 #if ENABLE(RESOURCE_LOAD_STATISTICS) 309 WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleStatisticsAndDataRecordsProcessing([] { }); 310 #endif 352 311 } 353 312 354 313 void WKWebsiteDataStoreStatisticsUpdateCookieBlocking(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsUpdateCookieBlockingFunction completionHandler) 355 314 { 356 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 357 if (!store) {315 #if ENABLE(RESOURCE_LOAD_STATISTICS) 316 WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleCookieBlockingUpdate([context, completionHandler]() { 358 317 completionHandler(context); 359 return; 360 } 361 362 store->scheduleCookieBlockingUpdate([context, completionHandler]() { 363 completionHandler(context); 364 }); 318 }); 319 #endif 365 320 } 366 321 367 322 void WKWebsiteDataStoreStatisticsSubmitTelemetry(WKWebsiteDataStoreRef dataStoreRef) 368 323 { 369 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 370 if (!store) 371 return; 372 373 store->submitTelemetry(); 324 #if ENABLE(RESOURCE_LOAD_STATISTICS) 325 WebKit::toImpl(dataStoreRef)->websiteDataStore().submitTelemetry(); 326 #endif 374 327 } 375 328 376 329 void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned(WKWebsiteDataStoreRef dataStoreRef, bool value) 377 330 { 378 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 379 if (!store) 380 return; 381 382 store->setNotifyPagesWhenDataRecordsWereScanned(value); 331 #if ENABLE(RESOURCE_LOAD_STATISTICS) 332 WebKit::toImpl(dataStoreRef)->websiteDataStore().setNotifyPagesWhenDataRecordsWereScanned(value, [] { }); 333 #endif 383 334 } 384 335 385 336 void WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, bool value) 386 337 { 387 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 388 if (!store)389 return; 390 391 store->setShouldClassifyResourcesBeforeDataRecordsRemoval(value); 392 } 393 394 void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured(WKWebsiteDataStoreRef, bool value)395 { 396 WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value); 338 #if ENABLE(RESOURCE_LOAD_STATISTICS) 339 WebKit::toImpl(dataStoreRef)->websiteDataStore().setShouldClassifyResourcesBeforeDataRecordsRemoval(value, []() { }); 340 #endif 341 } 342 343 void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured(WKWebsiteDataStoreRef dataStoreRef, bool value) 344 { 345 #if ENABLE(RESOURCE_LOAD_STATISTICS) 346 WebKit::toImpl(dataStoreRef)->websiteDataStore().setNotifyPagesWhenTelemetryWasCaptured(value, []() { }); 347 #endif 397 348 } 398 349 399 350 void WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, double seconds) 400 351 { 401 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 402 if (!store) 403 return; 404 405 store->setMinimumTimeBetweenDataRecordsRemoval(Seconds { seconds }); 352 #if ENABLE(RESOURCE_LOAD_STATISTICS) 353 WebKit::toImpl(dataStoreRef)->websiteDataStore().setMinimumTimeBetweenDataRecordsRemoval(Seconds { seconds }, []() { }); 354 #endif 406 355 } 407 356 408 357 void WKWebsiteDataStoreSetStatisticsGrandfatheringTime(WKWebsiteDataStoreRef dataStoreRef, double seconds) 409 358 { 410 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 411 if (!store) 412 return; 413 414 store->setGrandfatheringTime(Seconds {seconds }); 359 #if ENABLE(RESOURCE_LOAD_STATISTICS) 360 WebKit::toImpl(dataStoreRef)->websiteDataStore().setGrandfatheringTime(Seconds { seconds }, []() { }); 361 #endif 415 362 } 416 363 417 364 void WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries(WKWebsiteDataStoreRef dataStoreRef, unsigned entries) 418 365 { 419 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 420 if (!store) 421 return; 422 423 store->setMaxStatisticsEntries(entries); 366 #if ENABLE(RESOURCE_LOAD_STATISTICS) 367 WebKit::toImpl(dataStoreRef)->websiteDataStore().setMaxStatisticsEntries(entries, []() { }); 368 #endif 424 369 } 425 370 426 371 void WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo(WKWebsiteDataStoreRef dataStoreRef, unsigned entries) 427 372 { 428 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 429 if (!store) 430 return; 431 432 store->setPruneEntriesDownTo(entries); 373 #if ENABLE(RESOURCE_LOAD_STATISTICS) 374 WebKit::toImpl(dataStoreRef)->websiteDataStore().setPruneEntriesDownTo(entries, []() { }); 375 #endif 433 376 } 434 377 435 378 void WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreFunction callback) 436 379 { 437 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 438 if (!store) { 439 callback(context); 440 return; 441 } 442 443 store->scheduleClearInMemoryAndPersistent(WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [context, callback]() { 444 callback(context); 445 }); 380 #if ENABLE(RESOURCE_LOAD_STATISTICS) 381 WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleClearInMemoryAndPersistent(ShouldGrandfather::Yes, [context, callback]() { 382 callback(context); 383 }); 384 #else 385 callback(context); 386 #endif 446 387 } 447 388 448 389 void WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours(WKWebsiteDataStoreRef dataStoreRef, unsigned hours, void* context, WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHoursFunction callback) 449 390 { 450 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 451 if (!store) { 452 callback(context); 453 return; 454 } 455 456 store->scheduleClearInMemoryAndPersistent(WallTime::now() - Seconds::fromHours(hours), WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [context, callback]() { 457 callback(context); 458 }); 391 #if ENABLE(RESOURCE_LOAD_STATISTICS) 392 WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleClearInMemoryAndPersistent(WallTime::now() - Seconds::fromHours(hours), ShouldGrandfather::Yes, [context, callback]() { 393 callback(context); 394 }); 395 #endif 459 396 } 460 397 … … 476 413 void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsResetToConsistentStateFunction completionHandler) 477 414 { 415 #if ENABLE(RESOURCE_LOAD_STATISTICS) 478 416 auto callbackAggregator = CallbackAggregator::create([context, completionHandler]() { 479 417 completionHandler(context); … … 483 421 store.clearResourceLoadStatisticsInWebProcesses([callbackAggregator = callbackAggregator.copyRef()] { }); 484 422 store.resetCacheMaxAgeCapForPrevalentResources([callbackAggregator = callbackAggregator.copyRef()] { }); 485 486 auto* statisticsStore = store.resourceLoadStatistics(); 487 if (!statisticsStore) 488 return; 489 490 statisticsStore->resetParametersToDefaultValues([callbackAggregator = callbackAggregator.copyRef()] { }); 491 statisticsStore->scheduleClearInMemoryAndPersistent(WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::No, [callbackAggregator = callbackAggregator.copyRef()] { }); 423 store.resetParametersToDefaultValues([callbackAggregator = callbackAggregator.copyRef()] { }); 424 store.scheduleClearInMemoryAndPersistent(ShouldGrandfather::No, [callbackAggregator = callbackAggregator.copyRef()] { }); 425 #else 426 UNUSED_PARAM(dataStoreRef); 427 completionHandler(context); 428 #endif 492 429 } 493 430 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r240156 r240243 293 293 - (BOOL)_resourceLoadStatisticsDebugMode 294 294 { 295 #if ENABLE(RESOURCE_LOAD_STATISTICS) 295 296 return _websiteDataStore->websiteDataStore().resourceLoadStatisticsDebugMode(); 297 #else 298 return NO; 299 #endif 296 300 } 297 301 298 302 - (void)_setResourceLoadStatisticsDebugMode:(BOOL)enabled 299 303 { 304 #if ENABLE(RESOURCE_LOAD_STATISTICS) 300 305 _websiteDataStore->websiteDataStore().setResourceLoadStatisticsDebugMode(enabled); 306 #else 307 UNUSED_PARAM(enabled); 308 #endif 301 309 } 302 310 … … 363 371 - (void)_resourceLoadStatisticsSetShouldSubmitTelemetry:(BOOL)value 364 372 { 373 #if ENABLE(RESOURCE_LOAD_STATISTICS) 365 374 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics(); 366 375 if (!store) … … 368 377 369 378 store->setShouldSubmitTelemetry(value); 379 #endif 370 380 } 371 381 372 382 - (void)_setResourceLoadStatisticsTestingCallback:(void (^)(WKWebsiteDataStore *, NSString *))callback 373 383 { 384 #if ENABLE(RESOURCE_LOAD_STATISTICS) 374 385 if (!_websiteDataStore->isPersistent()) 375 386 return; … … 382 393 } 383 394 384 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics(); 385 if (!store) 386 return; 387 388 store->setStatisticsTestingCallback(nullptr); 395 _websiteDataStore->websiteDataStore().setStatisticsTestingCallback(nullptr); 396 #endif 389 397 } 390 398 … … 407 415 } 408 416 417 #if ENABLE(RESOURCE_LOAD_STATISTICS) 409 418 _websiteDataStore->websiteDataStore().getAllStorageAccessEntries(webPageProxy->pageID(), [completionHandler = makeBlockPtr(completionHandler)](auto domains) { 410 419 Vector<RefPtr<API::Object>> apiDomains; … … 414 423 completionHandler(wrapper(API::Array::create(WTFMove(apiDomains)))); 415 424 }); 425 #endif 416 426 } 417 427 -
trunk/Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm
r240129 r240243 26 26 #import "config.h" 27 27 #import "ResourceLoadStatisticsMemoryStore.h" 28 29 #if ENABLE(RESOURCE_LOAD_STATISTICS) 30 28 31 #import <wtf/text/WTFString.h> 29 32 … … 63 66 64 67 } 68 69 #endif -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r240156 r240243 1 1 /* 2 * Copyright (C) 2012-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 42 42 #include "WebProcessMessages.h" 43 43 #include "WebProcessPool.h" 44 #include "WebProcessProxy.h" 45 #include "WebResourceLoadStatisticsStore.h" 44 46 #include "WebUserContentControllerProxy.h" 45 47 #include "WebsiteData.h" … … 234 236 m_pendingDeleteWebsiteDataForOriginsCallbacks.take(m_pendingDeleteWebsiteDataForOriginsCallbacks.begin()->key)(); 235 237 236 while (!m_updateBlockCookiesCallbackMap.isEmpty()) 237 m_updateBlockCookiesCallbackMap.take(m_updateBlockCookiesCallbackMap.begin()->key)(); 238 238 #if ENABLE(RESOURCE_LOAD_STATISTICS) 239 while (!m_scheduleStatisticsProcessingCallbackMap.isEmpty()) 240 m_scheduleStatisticsProcessingCallbackMap.take(m_scheduleStatisticsProcessingCallbackMap.begin()->key)(); 241 239 242 while (!m_storageAccessResponseCallbackMap.isEmpty()) 240 243 m_storageAccessResponseCallbackMap.take(m_storageAccessResponseCallbackMap.begin()->key)(false); 244 245 while (!m_storageAccessRequestResponseCallbackMap.isEmpty()) 246 m_storageAccessRequestResponseCallbackMap.take(m_storageAccessRequestResponseCallbackMap.begin()->key)(StorageAccessStatus::CannotRequestAccess); 247 248 while (!m_removeAllStorageAccessCallbackMap.isEmpty()) 249 m_removeAllStorageAccessCallbackMap.take(m_removeAllStorageAccessCallbackMap.begin()->key)(); 250 251 while (!m_allStorageAccessEntriesCallbackMap.isEmpty()) 252 m_allStorageAccessEntriesCallbackMap.take(m_allStorageAccessEntriesCallbackMap.begin()->key)({ }); 253 254 while (!m_dumpStatisticsCallbackMap.isEmpty()) 255 m_dumpStatisticsCallbackMap.take(m_dumpStatisticsCallbackMap.begin()->key)({ }); 256 #endif 241 257 } 242 258 … … 275 291 m_syncAllCookiesCounter = 0; 276 292 293 #if ENABLE(RESOURCE_LOAD_STATISTICS) 277 294 for (auto& callback : m_removeAllStorageAccessCallbackMap.values()) 278 295 callback(); 279 296 m_removeAllStorageAccessCallbackMap.clear(); 280 297 281 for (auto& callback : m_ updateBlockCookiesCallbackMap.values())298 for (auto& callback : m_scheduleStatisticsProcessingCallbackMap.values()) 282 299 callback(); 283 m_updateBlockCookiesCallbackMap.clear(); 284 300 m_scheduleStatisticsProcessingCallbackMap.clear(); 301 #endif 302 285 303 // This will cause us to be deleted. 286 304 networkProcessCrashed(); … … 401 419 } 402 420 421 void NetworkProcessProxy::logGlobalDiagnosticMessageWithValue(const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample shouldSample) 422 { 423 if (auto* page = WebPageProxy::nonEphemeralWebPageProxy()) 424 page->logDiagnosticMessageWithValue(message, description, value, significantFigures, shouldSample); 425 } 426 403 427 #if ENABLE(RESOURCE_LOAD_STATISTICS) 428 void NetworkProcessProxy::dumpResourceLoadStatistics(PAL::SessionID sessionID, CompletionHandler<void(const String&)>&& completionHandler) 429 { 430 if (!canSendMessage()) { 431 completionHandler({ }); 432 return; 433 } 434 435 auto callbackId = generateCallbackID(); 436 auto addResult = m_dumpStatisticsCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)](const String& dumpedStatistics) mutable { 437 completionHandler(dumpedStatistics); 438 }); 439 ASSERT_UNUSED(addResult, addResult.isNewEntry); 440 send(Messages::NetworkProcess::DumpResourceLoadStatistics(sessionID, callbackId), 0); 441 } 442 443 void NetworkProcessProxy::didDumpResourceLoadStatistics(String dumpedStatistics, uint64_t callbackId) 444 { 445 m_dumpStatisticsCallbackMap.take(callbackId)(dumpedStatistics); 446 } 447 404 448 void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler) 405 449 { … … 410 454 411 455 auto callbackId = generateCallbackID(); 412 auto addResult = m_ updateBlockCookiesCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable {456 auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable { 413 457 completionHandler(); 414 458 }); … … 419 463 void NetworkProcessProxy::didUpdateBlockCookies(uint64_t callbackId) 420 464 { 421 m_updateBlockCookiesCallbackMap.take(callbackId)(); 422 } 423 424 void NetworkProcessProxy::didLogUserInteraction(uint64_t contextId) 425 { 426 // FIXME(193297): Implement when activating automated test cases. 427 UNUSED_PARAM(contextId); 465 m_scheduleStatisticsProcessingCallbackMap.take(callbackId)(); 466 } 467 468 void NetworkProcessProxy::isPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) 469 { 470 if (!canSendMessage()) { 471 completionHandler(false); 472 return; 473 } 474 475 sendWithAsyncReply(Messages::NetworkProcess::IsPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler)); 476 } 477 478 void NetworkProcessProxy::isVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) 479 { 480 if (!canSendMessage()) { 481 completionHandler(false); 482 return; 483 } 484 485 sendWithAsyncReply(Messages::NetworkProcess::IsVeryPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler)); 486 } 487 488 void NetworkProcessProxy::setPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 489 { 490 if (!canSendMessage()) { 491 completionHandler(); 492 return; 493 } 494 495 sendWithAsyncReply(Messages::NetworkProcess::SetPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler)); 496 } 497 498 void NetworkProcessProxy::setPrevalentResourceForDebugMode(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 499 { 500 if (!canSendMessage()) { 501 completionHandler(); 502 return; 503 } 504 505 sendWithAsyncReply(Messages::NetworkProcess::SetPrevalentResourceForDebugMode(sessionID, resourceDomain), WTFMove(completionHandler)); 506 } 507 508 void NetworkProcessProxy::setVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 509 { 510 if (!canSendMessage()) { 511 completionHandler(); 512 return; 513 } 514 515 sendWithAsyncReply(Messages::NetworkProcess::SetVeryPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler)); 516 } 517 518 void NetworkProcessProxy::setLastSeen(PAL::SessionID sessionID, const String& resourceDomain, Seconds lastSeen, CompletionHandler<void()>&& completionHandler) 519 { 520 if (!canSendMessage()) { 521 completionHandler(); 522 return; 523 } 524 525 sendWithAsyncReply(Messages::NetworkProcess::SetLastSeen(sessionID, resourceDomain, lastSeen), WTFMove(completionHandler)); 526 } 527 528 void NetworkProcessProxy::clearPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 529 { 530 if (!canSendMessage()) { 531 completionHandler(); 532 return; 533 } 534 535 sendWithAsyncReply(Messages::NetworkProcess::ClearPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler)); 536 } 537 538 void NetworkProcessProxy::scheduleCookieBlockingUpdate(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) 539 { 540 if (!canSendMessage()) { 541 completionHandler(); 542 return; 543 } 544 545 sendWithAsyncReply(Messages::NetworkProcess::ScheduleCookieBlockingUpdate(sessionID), WTFMove(completionHandler)); 546 } 547 548 void NetworkProcessProxy::scheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler) 549 { 550 if (!canSendMessage()) { 551 completionHandler(); 552 return; 553 } 554 555 bool shouldGrandfatherBool = shouldGrandfather == ShouldGrandfather::Yes; 556 sendWithAsyncReply(Messages::NetworkProcess::ScheduleClearInMemoryAndPersistent(sessionID, modifiedSince, shouldGrandfatherBool), WTFMove(completionHandler)); 557 } 558 559 void NetworkProcessProxy::scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) 560 { 561 if (!canSendMessage()) { 562 completionHandler(); 563 return; 564 } 565 566 sendWithAsyncReply(Messages::NetworkProcess::ScheduleStatisticsAndDataRecordsProcessing(sessionID), WTFMove(completionHandler)); 567 } 568 569 void NetworkProcessProxy::logUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 570 { 571 if (!canSendMessage()) { 572 completionHandler(); 573 return; 574 } 575 576 sendWithAsyncReply(Messages::NetworkProcess::LogUserInteraction(sessionID, resourceDomain), WTFMove(completionHandler)); 577 } 578 579 void NetworkProcessProxy::hasHadUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) 580 { 581 if (!canSendMessage()) { 582 completionHandler(false); 583 return; 584 } 585 586 sendWithAsyncReply(Messages::NetworkProcess::HadUserInteraction(sessionID, resourceDomain), WTFMove(completionHandler)); 587 } 588 589 void NetworkProcessProxy::clearUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) 590 { 591 if (!canSendMessage()) { 592 completionHandler(); 593 return; 594 } 595 596 sendWithAsyncReply(Messages::NetworkProcess::ClearUserInteraction(sessionID, resourceDomain), WTFMove(completionHandler)); 428 597 } 429 598 … … 436 605 437 606 auto callbackId = generateCallbackID(); 438 auto addResult = m_ updateBlockCookiesCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable {607 auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable { 439 608 completionHandler(); 440 609 }); … … 445 614 void NetworkProcessProxy::didSetAgeCapForClientSideCookies(uint64_t callbackId) 446 615 { 447 m_updateBlockCookiesCallbackMap.take(callbackId)(); 616 m_scheduleStatisticsProcessingCallbackMap.take(callbackId)(); 617 } 618 619 void NetworkProcessProxy::setTimeToLiveUserInteraction(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) 620 { 621 if (!canSendMessage()) { 622 completionHandler(); 623 return; 624 } 625 626 sendWithAsyncReply(Messages::NetworkProcess::SetTimeToLiveUserInteraction(sessionID, seconds), WTFMove(completionHandler)); 627 } 628 629 void NetworkProcessProxy::didUpdateRuntimeSettings(uint64_t callbackId) 630 { 631 m_updateRuntimeSettingsCallbackMap.take(callbackId)(); 632 } 633 634 void NetworkProcessProxy::setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) 635 { 636 if (!canSendMessage()) { 637 completionHandler(); 638 return; 639 } 640 641 sendWithAsyncReply(Messages::NetworkProcess::SetNotifyPagesWhenTelemetryWasCaptured(sessionID, value), WTFMove(completionHandler)); 642 } 643 644 void NetworkProcessProxy::setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) 645 { 646 if (!canSendMessage()) { 647 completionHandler(); 648 return; 649 } 650 651 sendWithAsyncReply(Messages::NetworkProcess::SetNotifyPagesWhenDataRecordsWereScanned(sessionID, value), WTFMove(completionHandler)); 652 } 653 654 void NetworkProcessProxy::setSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, const String& subframe, const String& topFrame, CompletionHandler<void()>&& completionHandler) 655 { 656 if (!canSendMessage()) { 657 completionHandler(); 658 return; 659 } 660 661 sendWithAsyncReply(Messages::NetworkProcess::SetSubframeUnderTopFrameOrigin(sessionID, subframe, topFrame), WTFMove(completionHandler)); 662 } 663 664 void NetworkProcessProxy::isRegisteredAsRedirectingTo(PAL::SessionID sessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&& completionHandler) 665 { 666 if (!canSendMessage()) { 667 completionHandler(false); 668 return; 669 } 670 671 sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsRedirectingTo(sessionID, redirectedFrom, redirectedTo), WTFMove(completionHandler)); 672 } 673 674 void NetworkProcessProxy::isRegisteredAsSubFrameUnder(PAL::SessionID sessionID, const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler) 675 { 676 if (!canSendMessage()) { 677 completionHandler(false); 678 return; 679 } 680 681 sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsSubFrameUnder(sessionID, subFrame, topFrame), WTFMove(completionHandler)); 682 } 683 684 void NetworkProcessProxy::setSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, const String& subresource, const String& topFrame, CompletionHandler<void()>&& completionHandler) 685 { 686 if (!canSendMessage()) { 687 completionHandler(); 688 return; 689 } 690 691 sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUnderTopFrameOrigin(sessionID, subresource, topFrame), WTFMove(completionHandler)); 692 } 693 694 void NetworkProcessProxy::isRegisteredAsSubresourceUnder(PAL::SessionID sessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler) 695 { 696 if (!canSendMessage()) { 697 completionHandler(false); 698 return; 699 } 700 701 sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsSubresourceUnder(sessionID, subresource, topFrame), WTFMove(completionHandler)); 702 } 703 704 void NetworkProcessProxy::setSubresourceUniqueRedirectTo(PAL::SessionID sessionID, const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) 705 { 706 if (!canSendMessage()) { 707 completionHandler(); 708 return; 709 } 710 711 sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUniqueRedirectTo(sessionID, subresource, hostNameRedirectedTo), WTFMove(completionHandler)); 712 } 713 714 void NetworkProcessProxy::setSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) 715 { 716 if (!canSendMessage()) { 717 completionHandler(); 718 return; 719 } 720 721 sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUniqueRedirectFrom(sessionID, subresource, hostNameRedirectedFrom), WTFMove(completionHandler)); 722 } 723 724 void NetworkProcessProxy::setTopFrameUniqueRedirectTo(PAL::SessionID sessionID, const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) 725 { 726 if (!canSendMessage()) { 727 completionHandler(); 728 return; 729 } 730 731 sendWithAsyncReply(Messages::NetworkProcess::SetTopFrameUniqueRedirectTo(sessionID, topFrameHostName, hostNameRedirectedTo), WTFMove(completionHandler)); 732 } 733 734 void NetworkProcessProxy::setTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) 735 { 736 if (!canSendMessage()) { 737 completionHandler(); 738 return; 739 } 740 741 sendWithAsyncReply(Messages::NetworkProcess::SetTopFrameUniqueRedirectFrom(sessionID, topFrameHostName, hostNameRedirectedFrom), WTFMove(completionHandler)); 742 } 743 744 void NetworkProcessProxy::isGrandfathered(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) 745 { 746 if (!canSendMessage()) { 747 completionHandler(false); 748 return; 749 } 750 751 sendWithAsyncReply(Messages::NetworkProcess::IsGrandfathered(sessionID, resourceDomain), WTFMove(completionHandler)); 752 } 753 754 void NetworkProcessProxy::setGrandfathered(PAL::SessionID sessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&& completionHandler) 755 { 756 if (!canSendMessage()) { 757 completionHandler(); 758 return; 759 } 760 761 sendWithAsyncReply(Messages::NetworkProcess::SetGrandfathered(sessionID, resourceDomain, isGrandfathered), WTFMove(completionHandler)); 448 762 } 449 763 450 764 void NetworkProcessProxy::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool)>&& callback) 451 765 { 766 if (!canSendMessage()) { 767 callback(false); 768 return; 769 } 770 452 771 auto contextId = generateCallbackID(); 453 772 auto addResult = m_storageAccessResponseCallbackMap.add(contextId, WTFMove(callback)); … … 456 775 } 457 776 458 void NetworkProcessProxy::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, WTF::CompletionHandler<void(bool)>&& callback) 459 { 777 void NetworkProcessProxy::hasStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) 778 { 779 if (!canSendMessage()) { 780 completionHandler(false); 781 return; 782 } 783 784 sendWithAsyncReply(Messages::NetworkProcess::HasStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID), WTFMove(completionHandler)); 785 } 786 787 void NetworkProcessProxy::requestStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler) 788 { 789 if (!canSendMessage()) { 790 completionHandler(StorageAccessStatus::CannotRequestAccess); 791 return; 792 } 793 460 794 auto contextId = generateCallbackID(); 461 auto addResult = m_storageAccessRe sponseCallbackMap.add(contextId, WTFMove(callback));795 auto addResult = m_storageAccessRequestResponseCallbackMap.add(contextId, WTFMove(completionHandler)); 462 796 ASSERT_UNUSED(addResult, addResult.isNewEntry); 463 send(Messages::NetworkProcess::GrantStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID, contextId), 0); 464 } 465 466 void NetworkProcessProxy::storageAccessRequestResult(bool wasGranted, uint64_t contextId) 467 { 468 auto callback = m_storageAccessResponseCallbackMap.take(contextId); 469 callback(wasGranted); 797 send(Messages::NetworkProcess::RequestStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID, promptEnabled, contextId), 0); 798 } 799 800 void NetworkProcessProxy::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, WTF::CompletionHandler<void(bool)>&& completionHandler) 801 { 802 if (!canSendMessage()) { 803 completionHandler(false); 804 return; 805 } 806 807 auto contextId = generateCallbackID(); 808 auto addResult = m_storageAccessResponseCallbackMap.add(contextId, WTFMove(completionHandler)); 809 ASSERT_UNUSED(addResult, addResult.isNewEntry); 810 send(Messages::NetworkProcess::GrantStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID.value(), pageID, userWasPrompted, contextId), 0); 811 } 812 813 void NetworkProcessProxy::storageAccessRequestResult(unsigned status, uint64_t contextId) 814 { 815 m_storageAccessRequestResponseCallbackMap.take(contextId)(static_cast<StorageAccessStatus>(status)); 816 } 817 818 void NetworkProcessProxy::storageAccessOperationResult(bool wasGranted, uint64_t contextId) 819 { 820 m_storageAccessResponseCallbackMap.take(contextId)(wasGranted); 470 821 } 471 822 … … 485 836 void NetworkProcessProxy::didRemoveAllStorageAccess(uint64_t contextId) 486 837 { 487 auto completionHandler = m_removeAllStorageAccessCallbackMap.take(contextId); 488 completionHandler(); 838 m_removeAllStorageAccessCallbackMap.take(contextId)(); 489 839 } 490 840 491 841 void NetworkProcessProxy::getAllStorageAccessEntries(PAL::SessionID sessionID, CompletionHandler<void(Vector<String>&& domains)>&& callback) 492 842 { 843 if (!canSendMessage()) { 844 callback({ }); 845 return; 846 } 847 493 848 auto contextId = generateCallbackID(); 494 849 auto addResult = m_allStorageAccessEntriesCallbackMap.add(contextId, WTFMove(callback)); … … 518 873 void NetworkProcessProxy::didSetCacheMaxAgeCapForPrevalentResources(uint64_t contextId) 519 874 { 520 auto completionHandler = m_updateRuntimeSettingsCallbackMap.take(contextId); 521 completionHandler(); 875 m_updateRuntimeSettingsCallbackMap.take(contextId)(); 876 } 877 878 void NetworkProcessProxy::setCacheMaxAgeCap(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) 879 { 880 if (!canSendMessage()) { 881 completionHandler(); 882 return; 883 } 884 885 auto contextId = generateCallbackID(); 886 auto addResult = m_updateRuntimeSettingsCallbackMap.add(contextId, WTFMove(completionHandler)); 887 ASSERT_UNUSED(addResult, addResult.isNewEntry); 888 send(Messages::NetworkProcess::SetCacheMaxAgeCapForPrevalentResources(sessionID, seconds, contextId), 0); 889 } 890 891 void NetworkProcessProxy::setGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) 892 { 893 if (!canSendMessage()) { 894 completionHandler(); 895 return; 896 } 897 898 sendWithAsyncReply(Messages::NetworkProcess::SetGrandfatheringTime(sessionID, seconds), WTFMove(completionHandler)); 899 } 900 901 void NetworkProcessProxy::setMaxStatisticsEntries(PAL::SessionID sessionID, size_t maximumEntryCount, CompletionHandler<void()>&& completionHandler) 902 { 903 if (!canSendMessage()) { 904 completionHandler(); 905 return; 906 } 907 908 sendWithAsyncReply(Messages::NetworkProcess::SetMaxStatisticsEntries(sessionID, maximumEntryCount), WTFMove(completionHandler)); 909 } 910 911 void NetworkProcessProxy::setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) 912 { 913 if (!canSendMessage()) { 914 completionHandler(); 915 return; 916 } 917 918 sendWithAsyncReply(Messages::NetworkProcess::SetMinimumTimeBetweenDataRecordsRemoval(sessionID, seconds), WTFMove(completionHandler)); 919 } 920 921 void NetworkProcessProxy::setPruneEntriesDownTo(PAL::SessionID sessionID, size_t pruneTargetCount, CompletionHandler<void()>&& completionHandler) 922 { 923 if (!canSendMessage()) { 924 completionHandler(); 925 return; 926 } 927 928 sendWithAsyncReply(Messages::NetworkProcess::SetPruneEntriesDownTo(sessionID, pruneTargetCount), WTFMove(completionHandler)); 929 } 930 931 void NetworkProcessProxy::setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) 932 { 933 if (!canSendMessage()) { 934 completionHandler(); 935 return; 936 } 937 938 sendWithAsyncReply(Messages::NetworkProcess::SetShouldClassifyResourcesBeforeDataRecordsRemoval(sessionID, value), WTFMove(completionHandler)); 939 } 940 941 void NetworkProcessProxy::setResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode, CompletionHandler<void()>&& completionHandler) 942 { 943 if (!canSendMessage()) { 944 completionHandler(); 945 return; 946 } 947 948 sendWithAsyncReply(Messages::NetworkProcess::SetResourceLoadStatisticsDebugMode(sessionID, debugMode), WTFMove(completionHandler)); 522 949 } 523 950 … … 535 962 } 536 963 537 void NetworkProcessProxy::didResetCacheMaxAgeCapForPrevalentResources(uint64_t contextId) 538 { 539 auto completionHandler = m_updateRuntimeSettingsCallbackMap.take(contextId); 540 completionHandler(); 964 void NetworkProcessProxy::resetParametersToDefaultValues(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) 965 { 966 if (!canSendMessage()) { 967 completionHandler(); 968 return; 969 } 970 971 sendWithAsyncReply(Messages::NetworkProcess::ResetParametersToDefaultValues(sessionID), WTFMove(completionHandler)); 972 } 973 974 void NetworkProcessProxy::submitTelemetry(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) 975 { 976 if (!canSendMessage()) { 977 completionHandler(); 978 return; 979 } 980 981 sendWithAsyncReply(Messages::NetworkProcess::SubmitTelemetry(sessionID), WTFMove(completionHandler)); 982 } 983 984 void NetworkProcessProxy::scheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, bool shouldGrandfather, CompletionHandler<void()>&& completionHandler) 985 { 986 if (!canSendMessage()) { 987 completionHandler(); 988 return; 989 } 990 991 992 sendWithAsyncReply(Messages::NetworkProcess::ScheduleClearInMemoryAndPersistent(sessionID, { }, shouldGrandfather), WTFMove(completionHandler)); 993 } 994 995 void NetworkProcessProxy::notifyResourceLoadStatisticsProcessed() 996 { 997 WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed(); 998 } 999 1000 void NetworkProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished() 1001 { 1002 WebProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished(); 1003 } 1004 1005 void NetworkProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished() 1006 { 1007 WebProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished(); 1008 } 1009 1010 void NetworkProcessProxy::notifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) 1011 { 1012 API::Dictionary::MapType messageBody; 1013 messageBody.set("TotalPrevalentResources"_s, API::UInt64::create(totalPrevalentResources)); 1014 messageBody.set("TotalPrevalentResourcesWithUserInteraction"_s, API::UInt64::create(totalPrevalentResourcesWithUserInteraction)); 1015 messageBody.set("Top3SubframeUnderTopFrameOrigins"_s, API::UInt64::create(top3SubframeUnderTopFrameOrigins)); 1016 1017 WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr()); 541 1018 } 542 1019 #endif // ENABLE(RESOURCE_LOAD_STATISTICS) -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r240099 r240243 58 58 class DownloadProxyMap; 59 59 class WebProcessPool; 60 enum class StorageAccessStatus : unsigned; 60 61 enum class WebsiteDataFetchOption; 61 62 enum class WebsiteDataType; … … 78 79 79 80 #if ENABLE(RESOURCE_LOAD_STATISTICS) 81 void clearPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); 82 void clearUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); 83 void dumpResourceLoadStatistics(PAL::SessionID, CompletionHandler<void(const String&)>&&); 80 84 void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, CompletionHandler<void()>&&); 85 void hasHadUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); 86 void isGrandfathered(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); 87 void isPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); 88 void isRegisteredAsRedirectingTo(PAL::SessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&&); 89 void isRegisteredAsSubFrameUnder(PAL::SessionID, const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&&); 90 void isRegisteredAsSubresourceUnder(PAL::SessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&&); 91 void isVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); 92 void logUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); 93 void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, CompletionHandler<void()>&&); 94 void setLastSeen(PAL::SessionID, const String& resourceDomain, Seconds, CompletionHandler<void()>&&); 81 95 void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, CompletionHandler<void()>&&); 96 void setCacheMaxAgeCap(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 97 void setGrandfathered(PAL::SessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&&); 98 void setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID, bool, CompletionHandler<void()>&&); 99 void setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID, bool, CompletionHandler<void()>&&); 100 void setSubframeUnderTopFrameOrigin(PAL::SessionID, const String& subframe, const String& topFrame, CompletionHandler<void()>&&); 101 void setSubresourceUnderTopFrameOrigin(PAL::SessionID, const String& subresource, const String& topFrame, CompletionHandler<void()>&&); 102 void setSubresourceUniqueRedirectTo(PAL::SessionID, const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&&); 103 void setSubresourceUniqueRedirectFrom(PAL::SessionID, const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&); 104 void setTimeToLiveUserInteraction(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 105 void setTopFrameUniqueRedirectTo(PAL::SessionID, const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&&); 106 void setTopFrameUniqueRedirectFrom(PAL::SessionID, const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&); 107 void setPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); 108 void setPrevalentResourceForDebugMode(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); 109 void setVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); 82 110 void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback); 83 111 void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String>&& domains)>&&); 84 void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback); 112 void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, WTF::CompletionHandler<void(bool)>&&); 113 void hasStorageAccess(PAL::SessionID, const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); 114 void requestStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); 115 void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&); 85 116 void removeAllStorageAccess(PAL::SessionID, CompletionHandler<void()>&&); 117 void scheduleClearInMemoryAndPersistent(PAL::SessionID, bool shouldGrandfather, CompletionHandler<void()>&&); 118 void scheduleClearInMemoryAndPersistent(PAL::SessionID, Optional<WallTime> modifiedSince, ShouldGrandfather, CompletionHandler<void()>&&); 119 void scheduleCookieBlockingUpdate(PAL::SessionID, CompletionHandler<void()>&&); 120 void submitTelemetry(PAL::SessionID, CompletionHandler<void()>&&); 86 121 void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 122 void setGrandfatheringTime(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 123 void setMaxStatisticsEntries(PAL::SessionID, size_t maximumEntryCount, CompletionHandler<void()>&&); 124 void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 125 void setPruneEntriesDownTo(PAL::SessionID, size_t pruneTargetCount, CompletionHandler<void()>&&); 126 void setResourceLoadStatisticsDebugMode(PAL::SessionID, bool debugMode, CompletionHandler<void()>&&); 127 void setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID, bool, CompletionHandler<void()>&&); 87 128 void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, CompletionHandler<void()>&&); 88 129 #endif … … 142 183 void logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample); 143 184 void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample); 185 void logGlobalDiagnosticMessageWithValue(const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample); 144 186 #if ENABLE(RESOURCE_LOAD_STATISTICS) 145 void did LogUserInteraction(uint64_t contextId);187 void didDumpResourceLoadStatistics(String dumpedStatistics, uint64_t callbackId); 146 188 void didUpdateBlockCookies(uint64_t contextId); 147 189 void didSetAgeCapForClientSideCookies(uint64_t contextId); 148 void storageAccessRequestResult(bool wasGranted, uint64_t contextId); 190 void storageAccessOperationResult(bool wasGranted, uint64_t contextId); 191 void storageAccessRequestResult(unsigned wasGranted, uint64_t contextId); 149 192 void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId); 150 193 void didRemoveAllStorageAccess(uint64_t contextId); 151 194 void didSetCacheMaxAgeCapForPrevalentResources(uint64_t contextId); 152 void didResetCacheMaxAgeCapForPrevalentResources(uint64_t contextId); 195 void didUpdateRuntimeSettings(uint64_t contextId); 196 void notifyResourceLoadStatisticsProcessed(); 197 void notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished(); 198 void notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished(); 199 void notifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins); 153 200 #endif 154 201 void retrieveCacheStorageParameters(PAL::SessionID); … … 193 240 unsigned m_syncAllCookiesCounter { 0 }; 194 241 195 HashMap<uint64_t, CompletionHandler<void()>> m_updateBlockCookiesCallbackMap; 242 #if ENABLE(RESOURCE_LOAD_STATISTICS) 243 HashMap<uint64_t, CompletionHandler<void()>> m_scheduleStatisticsProcessingCallbackMap; 196 244 HashMap<uint64_t, CompletionHandler<void(bool wasGranted)>> m_storageAccessResponseCallbackMap; 245 HashMap<uint64_t, CompletionHandler<void(StorageAccessStatus wasGranted)>> m_storageAccessRequestResponseCallbackMap; 197 246 HashMap<uint64_t, CompletionHandler<void()>> m_removeAllStorageAccessCallbackMap; 198 247 HashMap<uint64_t, CompletionHandler<void(Vector<String>&& domains)>> m_allStorageAccessEntriesCallbackMap; 248 HashMap<uint64_t, CompletionHandler<void(const String&)>> m_dumpStatisticsCallbackMap; 249 #endif 199 250 200 251 HashMap<uint64_t, CompletionHandler<void()>> m_updateRuntimeSettingsCallbackMap; -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in
r240099 r240243 39 39 LogDiagnosticMessageWithResult(uint64_t pageID, String message, String description, uint32_t result, enum:bool WebCore::ShouldSample shouldSample) 40 40 LogDiagnosticMessageWithValue(uint64_t pageID, String message, String description, double value, unsigned significantFigures, enum:bool WebCore::ShouldSample shouldSample) 41 LogGlobalDiagnosticMessageWithValue(String message, String description, double value, unsigned significantFigures, enum:bool WebCore::ShouldSample shouldSample) 41 42 42 43 #if ENABLE(RESOURCE_LOAD_STATISTICS) 43 Did LogUserInteraction(uint64_t callbackId)44 DidDumpResourceLoadStatistics(String dumpedStatistics, uint64_t callbackId) 44 45 DidUpdateBlockCookies(uint64_t callbackId) 45 46 DidSetAgeCapForClientSideCookies(uint64_t callbackId) 46 StorageAccessRequestResult(bool wasGranted, uint64_t contextId) 47 StorageAccessOperationResult(bool wasGranted, uint64_t contextId) 48 StorageAccessRequestResult(unsigned wasGranted, uint64_t contextId) 47 49 AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId) 48 50 DidRemoveAllStorageAccess(uint64_t contextId) 49 51 DidSetCacheMaxAgeCapForPrevalentResources(uint64_t contextId) 50 DidResetCacheMaxAgeCapForPrevalentResources(uint64_t contextId) 52 DidUpdateRuntimeSettings(uint64_t contextId) 53 NotifyResourceLoadStatisticsProcessed() 54 NotifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished() 55 NotifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished() 56 NotifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) 51 57 #endif 52 58 #if ENABLE(CONTENT_EXTENSIONS) -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r240055 r240243 4481 4481 } 4482 4482 4483 WebPageProxy* WebPageProxy::nonEphemeralWebPageProxy() 4484 { 4485 auto processPools = WebProcessPool::allProcessPools(); 4486 if (processPools.isEmpty()) 4487 return nullptr; 4488 4489 auto processPool = processPools[0]; 4490 if (!processPool) 4491 return nullptr; 4492 4493 for (auto& webProcess : processPool->processes()) { 4494 for (auto& page : webProcess->pages()) { 4495 if (page->sessionID().isEphemeral()) 4496 continue; 4497 return page; 4498 } 4499 } 4500 return nullptr; 4501 } 4502 4483 4503 #if ENABLE(RESOURCE_LOAD_STATISTICS) 4484 4504 void WebPageProxy::logFrameNavigation(const WebFrameProxy& frame, const URL& pageURL, const WebCore::ResourceRequest& request, const URL& redirectURL) -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r240199 r240243 1 1 /* 2 * Copyright (C) 2010-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2010-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 1384 1384 #endif 1385 1385 1386 static WebPageProxy* nonEphemeralWebPageProxy(); 1387 1386 1388 #if ENABLE(ATTACHMENT_ELEMENT) 1387 1389 RefPtr<API::Attachment> attachmentForIdentifier(const String& identifier) const; -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r239880 r240243 561 561 SandboxExtension::createHandleForReadWriteDirectory(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectory, parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectoryExtensionHandle); 562 562 563 parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatistics = false; // FIXME(193297): Turn on when the feature is on. 563 parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatistics = false; // FIXME(193297): Turn on when the feature is on. (m_configuration->resourceLoadStatisticsEnabled()?) 564 564 565 565 // Add any platform specific parameters -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r240161 r240243 285 285 } 286 286 287 #if ENABLE(RESOURCE_LOAD_STATISTICS) 287 288 void WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void (const HashSet<String>&)>&& completionHandler) 288 289 { … … 418 419 page.value->postMessageToInjectedBundle("WebsiteDataScanForTopPrivatelyControlledDomainsFinished", nullptr); 419 420 } 420 421 422 void WebProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished() 423 { 424 for (auto& page : globalPageMap()) 425 page.value->postMessageToInjectedBundle("WebsiteDataScanForTopPrivatelyControlledDomainsFinished", nullptr); 426 } 427 428 void WebProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished() 429 { 430 for (auto& page : globalPageMap()) 431 page.value->postMessageToInjectedBundle("WebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished", nullptr); 432 } 433 421 434 void WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Object* messageBody) 422 435 { … … 424 437 page.value->postMessageToInjectedBundle("ResourceLoadStatisticsTelemetryFinished", messageBody); 425 438 } 426 439 #endif 440 427 441 Ref<WebPageProxy> WebProcessProxy::createWebPage(PageClient& pageClient, Ref<API::PageConfiguration>&& pageConfiguration) 428 442 { -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r240161 r240243 172 172 void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, CompletionHandler<void()>&&); 173 173 void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>&, CompletionHandler<void()>&&); 174 175 #if ENABLE(RESOURCE_LOAD_STATISTICS) 174 176 static void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, CompletionHandler<void (const HashSet<String>&)>&&); 175 177 static void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&); 178 176 179 static void notifyPageStatisticsAndDataRecordsProcessed(); 177 180 static void notifyPageStatisticsTelemetryFinished(API::Object* messageBody); 181 182 static void notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished(); 183 static void notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished(); 184 #endif 178 185 179 186 void enableSuddenTermination(); … … 267 274 268 275 bool isJITEnabled() const final; 269 276 270 277 private: 271 278 // IPC message handlers. -
trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.messages.in
r236563 r240243 21 21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 22 23 #if ENABLE(RESOURCE_LOAD_STATISTICS) 24 23 25 messages -> WebResourceLoadStatisticsStore { 24 26 RequestStorageAccessUnderOpener(String domainReceivingUserInteraction, uint64_t openerPageID, String openerDomain) 25 27 ResourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics> origins) 26 28 } 29 30 #endif -
trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
r239816 r240243 155 155 for (auto& dataStore : dataStoresWithStorageManagers()) { 156 156 dataStore->m_storageManager->applicationWillTerminate(); 157 #if ENABLE(RESOURCE_LOAD_STATISTICS) 157 158 if (dataStore->m_resourceLoadStatistics) 158 159 dataStore->m_resourceLoadStatistics->applicationWillTerminate(); 160 #endif 159 161 } 160 162 }]; … … 167 169 void WebsiteDataStore::platformDestroy() 168 170 { 171 #if ENABLE(RESOURCE_LOAD_STATISTICS) 169 172 if (m_resourceLoadStatistics) 170 173 m_resourceLoadStatistics->applicationWillTerminate(); 174 #endif 171 175 172 176 if (!m_storageManager) -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r240156 r240243 1 1 /* 2 * Copyright (C) 2014-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2014-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 131 131 platformDestroy(); 132 132 133 #if ENABLE(RESOURCE_LOAD_STATISTICS) 133 134 unregisterWebResourceLoadStatisticsStoreAsMessageReceiver(); 135 #endif 134 136 135 137 if (m_sessionID.isValid() && m_sessionID != PAL::SessionID::defaultSessionID()) { … … 614 616 } 615 617 618 #if ENABLE(RESOURCE_LOAD_STATISTICS) 616 619 void WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, HashSet<String>&&)>&& completionHandler) 617 620 { … … 649 652 }); 650 653 } 654 #endif 651 655 652 656 static ProcessAccessType computeNetworkProcessAccessTypeForDataRemoval(OptionSet<WebsiteDataType> dataTypes, bool isNonPersistentStore) … … 926 930 #endif 927 931 928 if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics) && m_resourceLoadStatistics) { 932 #if ENABLE(RESOURCE_LOAD_STATISTICS) 933 if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) { 929 934 auto deletedTypesRaw = dataTypes.toRaw(); 930 935 auto monitoredTypesRaw = WebResourceLoadStatisticsStore::monitoredDataTypes().toRaw(); … … 932 937 // If we are deleting all of the data types that the resource load statistics store monitors 933 938 // we do not need to re-grandfather old data. 939 auto shouldGrandfather = ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) ? ShouldGrandfather::No : ShouldGrandfather::Yes; 940 934 941 callbackAggregator->addPendingCallback(); 935 if ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) 936 m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, WebResourceLoadStatisticsStore::ShouldGrandfather::No, [callbackAggregator] { 942 943 if (m_resourceLoadStatistics) { 944 m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, [callbackAggregator] { 937 945 callbackAggregator->removePendingCallback(); 938 946 }); 939 else 940 m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [callbackAggregator] { 941 callbackAggregator->removePendingCallback(); 942 }); 947 } else { 948 for (auto& processPool : processPools()) { 949 if (auto* process = processPool->networkProcess()) { 950 process->deleteWebsiteData(m_sessionID, dataTypes, modifiedSince, [callbackAggregator] { 951 callbackAggregator->removePendingCallback(); 952 }); 953 } 954 } 955 } 943 956 944 957 callbackAggregator->addPendingCallback(); … … 947 960 }); 948 961 } 962 #endif 949 963 950 964 // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away. … … 1222 1236 #endif 1223 1237 1238 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1224 1239 // FIXME <rdar://problem/33491222>; scheduleClearInMemoryAndPersistent does not have a completion handler, 1225 1240 // so the completion handler for this removeData() call can be called prematurely. … … 1232 1247 callbackAggregator->addPendingCallback(); 1233 1248 if ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) 1234 m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent( WebResourceLoadStatisticsStore::ShouldGrandfather::No, [callbackAggregator] {1249 m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(ShouldGrandfather::No, [callbackAggregator] { 1235 1250 callbackAggregator->removePendingCallback(); 1236 1251 }); 1237 1252 else 1238 m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent( WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [callbackAggregator] {1253 m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(ShouldGrandfather::Yes, [callbackAggregator] { 1239 1254 callbackAggregator->removePendingCallback(); 1240 1255 }); … … 1245 1260 }); 1246 1261 } 1262 #endif 1247 1263 1248 1264 // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away. … … 1250 1266 } 1251 1267 1268 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1252 1269 void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler) 1253 1270 { … … 1259 1276 } 1260 1277 1278 void WebsiteDataStore::setMaxStatisticsEntries(size_t maximumEntryCount, CompletionHandler<void()>&& completionHandler) 1279 { 1280 ASSERT(RunLoop::isMain()); 1281 1282 if (m_resourceLoadStatistics) { 1283 m_resourceLoadStatistics->setMaxStatisticsEntries(maximumEntryCount, WTFMove(completionHandler)); 1284 return; 1285 } 1286 1287 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1288 1289 for (auto& processPool : processPools()) { 1290 if (auto* process = processPool->networkProcess()) 1291 process->setMaxStatisticsEntries(m_sessionID, maximumEntryCount, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1292 } 1293 } 1294 1295 void WebsiteDataStore::setPruneEntriesDownTo(size_t pruneTargetCount, CompletionHandler<void()>&& completionHandler) 1296 { 1297 ASSERT(RunLoop::isMain()); 1298 1299 if (m_resourceLoadStatistics) { 1300 m_resourceLoadStatistics->setPruneEntriesDownTo(pruneTargetCount, WTFMove(completionHandler)); 1301 return; 1302 } 1303 1304 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1305 1306 for (auto& processPool : processPools()) { 1307 if (auto* process = processPool->networkProcess()) 1308 process->setPruneEntriesDownTo(m_sessionID, pruneTargetCount, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1309 } 1310 } 1311 1312 void WebsiteDataStore::setGrandfatheringTime(Seconds seconds, CompletionHandler<void()>&& completionHandler) 1313 { 1314 ASSERT(RunLoop::isMain()); 1315 1316 if (m_resourceLoadStatistics) { 1317 m_resourceLoadStatistics->setGrandfatheringTime(seconds, WTFMove(completionHandler)); 1318 return; 1319 } 1320 1321 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1322 1323 for (auto& processPool : processPools()) { 1324 if (auto* process = processPool->networkProcess()) 1325 process->setGrandfatheringTime(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1326 } 1327 } 1328 1329 void WebsiteDataStore::setCacheMaxAgeCap(Seconds seconds, CompletionHandler<void()>&& completionHandler) 1330 { 1331 ASSERT(RunLoop::isMain()); 1332 ASSERT(seconds >= 0_s); 1333 1334 if (m_resourceLoadStatistics) { 1335 setCacheMaxAgeCap(seconds, WTFMove(completionHandler)); 1336 return; 1337 } 1338 1339 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1340 1341 for (auto& processPool : processPools()) { 1342 if (auto* process = processPool->networkProcess()) 1343 process->setCacheMaxAgeCap(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1344 } 1345 } 1346 1347 void WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds, CompletionHandler<void()>&& completionHandler) 1348 { 1349 ASSERT(RunLoop::isMain()); 1350 1351 if (m_resourceLoadStatistics) { 1352 m_resourceLoadStatistics->setMinimumTimeBetweenDataRecordsRemoval(seconds, WTFMove(completionHandler)); 1353 return; 1354 } 1355 1356 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1357 1358 for (auto& processPool : processPools()) { 1359 if (auto* process = processPool->networkProcess()) 1360 process->setMinimumTimeBetweenDataRecordsRemoval(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1361 } 1362 } 1363 1364 void WebsiteDataStore::dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&& completionHandler) 1365 { 1366 ASSERT(RunLoop::isMain()); 1367 1368 if (m_resourceLoadStatistics) { 1369 m_resourceLoadStatistics->dumpResourceLoadStatistics(WTFMove(completionHandler)); 1370 return; 1371 } 1372 1373 for (auto& processPool : processPools()) { 1374 if (auto* process = processPool->networkProcess()) { 1375 process->dumpResourceLoadStatistics(m_sessionID, WTFMove(completionHandler)); 1376 RELEASE_ASSERT(processPools().size() == 1); 1377 break; 1378 } 1379 } 1380 } 1381 1382 void WebsiteDataStore::isPrevalentResource(const URL& url, CompletionHandler<void(bool isPrevalent)>&& completionHandler) 1383 { 1384 ASSERT(RunLoop::isMain()); 1385 1386 if (url.protocolIsAbout() || url.isEmpty()) { 1387 completionHandler(false); 1388 return; 1389 } 1390 1391 if (m_resourceLoadStatistics) { 1392 m_resourceLoadStatistics->isPrevalentResource(url, WTFMove(completionHandler)); 1393 return; 1394 } 1395 1396 for (auto& processPool : processPools()) { 1397 if (auto* process = processPool->networkProcess()) { 1398 process->isPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 1399 RELEASE_ASSERT(processPools().size() == 1); 1400 break; 1401 } 1402 } 1403 } 1404 1405 void WebsiteDataStore::setPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler) 1406 { 1407 ASSERT(RunLoop::isMain()); 1408 1409 if (url.protocolIsAbout() || url.isEmpty()) { 1410 completionHandler(); 1411 return; 1412 } 1413 1414 if (m_resourceLoadStatistics) { 1415 m_resourceLoadStatistics->setPrevalentResource(url, WTFMove(completionHandler)); 1416 return; 1417 } 1418 1419 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1420 1421 for (auto& processPool : processPools()) { 1422 if (auto* process = processPool->networkProcess()) 1423 process->setPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1424 } 1425 } 1426 1427 void WebsiteDataStore::setPrevalentResourceForDebugMode(const URL& url, CompletionHandler<void()>&& completionHandler) 1428 { 1429 ASSERT(RunLoop::isMain()); 1430 1431 if (url.protocolIsAbout() || url.isEmpty()) { 1432 completionHandler(); 1433 return; 1434 } 1435 1436 if (m_resourceLoadStatistics) { 1437 m_resourceLoadStatistics->setPrevalentResourceForDebugMode(url, WTFMove(completionHandler)); 1438 return; 1439 } 1440 1441 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1442 1443 for (auto& processPool : processPools()) { 1444 if (auto* process = processPool->networkProcess()) 1445 process->setPrevalentResourceForDebugMode(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1446 } 1447 } 1448 1449 void WebsiteDataStore::isVeryPrevalentResource(const URL& url, CompletionHandler<void(bool isVeryPrevalent)>&& completionHandler) 1450 { 1451 ASSERT(RunLoop::isMain()); 1452 1453 if (url.protocolIsAbout() || url.isEmpty()) { 1454 completionHandler(false); 1455 return; 1456 } 1457 1458 if (m_resourceLoadStatistics) { 1459 m_resourceLoadStatistics->isVeryPrevalentResource(url, WTFMove(completionHandler)); 1460 return; 1461 } 1462 1463 for (auto& processPool : processPools()) { 1464 if (auto* process = processPool->networkProcess()) { 1465 process->isVeryPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 1466 ASSERT(processPools().size() == 1); 1467 break; 1468 } 1469 } 1470 } 1471 1472 void WebsiteDataStore::setVeryPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler) 1473 { 1474 ASSERT(RunLoop::isMain()); 1475 1476 if (url.protocolIsAbout() || url.isEmpty()) { 1477 completionHandler(); 1478 return; 1479 } 1480 1481 if (m_resourceLoadStatistics) { 1482 m_resourceLoadStatistics->setVeryPrevalentResource(url, WTFMove(completionHandler)); 1483 return; 1484 } 1485 1486 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1487 1488 for (auto& processPool : processPools()) { 1489 if (auto* process = processPool->networkProcess()) 1490 process->setVeryPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1491 } 1492 } 1493 1494 void WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value, CompletionHandler<void()>&& completionHandler) 1495 { 1496 ASSERT(RunLoop::isMain()); 1497 1498 if (m_resourceLoadStatistics) { 1499 m_resourceLoadStatistics->setShouldClassifyResourcesBeforeDataRecordsRemoval(value, WTFMove(completionHandler)); 1500 return; 1501 } 1502 1503 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1504 1505 for (auto& processPool : processPools()) { 1506 if (auto* process = processPool->networkProcess()) 1507 process->setShouldClassifyResourcesBeforeDataRecordsRemoval(m_sessionID, value, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1508 } 1509 } 1510 1511 void WebsiteDataStore::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&& completionHandler) 1512 { 1513 ASSERT(RunLoop::isMain()); 1514 1515 if (subframe.protocolIsAbout() || subframe.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) { 1516 completionHandler(); 1517 return; 1518 } 1519 1520 if (m_resourceLoadStatistics) { 1521 m_resourceLoadStatistics->setSubframeUnderTopFrameOrigin(subframe, topFrame, WTFMove(completionHandler)); 1522 return; 1523 } 1524 1525 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1526 1527 for (auto& processPool : processPools()) { 1528 if (auto* process = processPool->networkProcess()) 1529 process->setSubframeUnderTopFrameOrigin(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subframe), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1530 } 1531 } 1532 1533 void WebsiteDataStore::isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler) 1534 { 1535 ASSERT(RunLoop::isMain()); 1536 1537 if (m_resourceLoadStatistics) { 1538 m_resourceLoadStatistics->isRegisteredAsSubFrameUnder(subFrame, topFrame, WTFMove(completionHandler)); 1539 return; 1540 } 1541 1542 for (auto& processPool : processPools()) { 1543 if (auto* process = processPool->networkProcess()) { 1544 process->isRegisteredAsSubFrameUnder(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subFrame), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler)); 1545 ASSERT(processPools().size() == 1); 1546 break; 1547 } 1548 } 1549 } 1550 1551 void WebsiteDataStore::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&& completionHandler) 1552 { 1553 ASSERT(RunLoop::isMain()); 1554 1555 if (subresource.protocolIsAbout() || subresource.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) { 1556 completionHandler(); 1557 return; 1558 } 1559 1560 if (m_resourceLoadStatistics) { 1561 m_resourceLoadStatistics->setSubresourceUnderTopFrameOrigin(subresource, topFrame, WTFMove(completionHandler)); 1562 return; 1563 } 1564 1565 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1566 1567 for (auto& processPool : processPools()) { 1568 if (auto* process = processPool->networkProcess()) 1569 process->setSubresourceUnderTopFrameOrigin(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1570 } 1571 } 1572 1573 void WebsiteDataStore::isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler) 1574 { 1575 ASSERT(RunLoop::isMain()); 1576 1577 if (m_resourceLoadStatistics) { 1578 m_resourceLoadStatistics->isRegisteredAsSubresourceUnder(subresource, topFrame, WTFMove(completionHandler)); 1579 return; 1580 } 1581 1582 for (auto& processPool : processPools()) { 1583 if (auto* process = processPool->networkProcess()) { 1584 process->isRegisteredAsSubresourceUnder(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler)); 1585 ASSERT(processPools().size() == 1); 1586 break; 1587 } 1588 } 1589 } 1590 1591 void WebsiteDataStore::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) 1592 { 1593 ASSERT(RunLoop::isMain()); 1594 1595 if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) { 1596 completionHandler(); 1597 return; 1598 } 1599 1600 if (m_resourceLoadStatistics) { 1601 m_resourceLoadStatistics->setSubresourceUniqueRedirectTo(subresource, hostNameRedirectedTo, WTFMove(completionHandler)); 1602 return; 1603 } 1604 1605 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1606 1607 for (auto& processPool : processPools()) { 1608 if (auto* process = processPool->networkProcess()) 1609 process->setSubresourceUniqueRedirectTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1610 } 1611 } 1612 1613 void WebsiteDataStore::setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) 1614 { 1615 ASSERT(RunLoop::isMain()); 1616 1617 if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) { 1618 completionHandler(); 1619 return; 1620 } 1621 1622 if (m_resourceLoadStatistics) { 1623 m_resourceLoadStatistics->setSubresourceUniqueRedirectFrom(subresource, hostNameRedirectedFrom, WTFMove(completionHandler)); 1624 return; 1625 } 1626 1627 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1628 1629 for (auto& processPool : processPools()) { 1630 if (auto* process = processPool->networkProcess()) 1631 process->setSubresourceUniqueRedirectFrom(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1632 } 1633 } 1634 1635 void WebsiteDataStore::setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) 1636 { 1637 ASSERT(RunLoop::isMain()); 1638 1639 if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) { 1640 completionHandler(); 1641 return; 1642 } 1643 1644 if (m_resourceLoadStatistics) { 1645 m_resourceLoadStatistics->setTopFrameUniqueRedirectTo(topFrameHostName, hostNameRedirectedTo, WTFMove(completionHandler)); 1646 return; 1647 } 1648 1649 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1650 1651 for (auto& processPool : processPools()) { 1652 if (auto* process = processPool->networkProcess()) 1653 process->setTopFrameUniqueRedirectTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1654 } 1655 } 1656 1657 void WebsiteDataStore::setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) 1658 { 1659 ASSERT(RunLoop::isMain()); 1660 1661 if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) { 1662 completionHandler(); 1663 return; 1664 } 1665 1666 if (m_resourceLoadStatistics) { 1667 m_resourceLoadStatistics->setTopFrameUniqueRedirectFrom(topFrameHostName, hostNameRedirectedFrom, WTFMove(completionHandler)); 1668 return; 1669 } 1670 1671 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1672 1673 for (auto& processPool : processPools()) { 1674 if (auto* process = processPool->networkProcess()) 1675 process->setTopFrameUniqueRedirectFrom(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1676 } 1677 } 1678 1679 void WebsiteDataStore::isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&& completionHandler) 1680 { 1681 ASSERT(RunLoop::isMain()); 1682 1683 if (m_resourceLoadStatistics) { 1684 m_resourceLoadStatistics->isRegisteredAsRedirectingTo(hostRedirectedFrom, hostRedirectedTo, WTFMove(completionHandler)); 1685 return; 1686 } 1687 1688 for (auto& processPool : processPools()) { 1689 if (auto* process = processPool->networkProcess()) { 1690 process->isRegisteredAsRedirectingTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedFrom), WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedTo), WTFMove(completionHandler)); 1691 ASSERT(processPools().size() == 1); 1692 break; 1693 } 1694 } 1695 } 1696 1697 void WebsiteDataStore::clearPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler) 1698 { 1699 ASSERT(RunLoop::isMain()); 1700 1701 if (url.protocolIsAbout() || url.isEmpty()) { 1702 completionHandler(); 1703 return; 1704 } 1705 1706 if (m_resourceLoadStatistics) { 1707 m_resourceLoadStatistics->clearPrevalentResource(url, WTFMove(completionHandler)); 1708 return; 1709 } 1710 1711 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1712 1713 const auto& primaryDomain = WebCore::ResourceLoadStatistics::primaryDomain(url); 1714 for (auto& processPool : processPools()) { 1715 if (auto* process = processPool->networkProcess()) 1716 process->clearPrevalentResource(m_sessionID, primaryDomain, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1717 } 1718 } 1719 1720 void WebsiteDataStore::resetParametersToDefaultValues(CompletionHandler<void()>&& completionHandler) 1721 { 1722 ASSERT(RunLoop::isMain()); 1723 1724 if (m_resourceLoadStatistics) { 1725 m_resourceLoadStatistics->resetParametersToDefaultValues(WTFMove(completionHandler)); 1726 return; 1727 } 1728 1729 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1730 1731 for (auto& processPool : processPools()) { 1732 if (auto* process = processPool->networkProcess()) 1733 process->resetParametersToDefaultValues(m_sessionID, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1734 } 1735 } 1736 1737 void WebsiteDataStore::submitTelemetry() 1738 { 1739 ASSERT(RunLoop::isMain()); 1740 1741 if (m_resourceLoadStatistics) { 1742 m_resourceLoadStatistics->submitTelemetry([] { }); 1743 return; 1744 } 1745 1746 for (auto& processPool : processPools()) { 1747 if (auto* process = processPool->networkProcess()) 1748 process->submitTelemetry(m_sessionID, [] { }); 1749 } 1750 } 1751 1752 void WebsiteDataStore::scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler) 1753 { 1754 ASSERT(RunLoop::isMain()); 1755 1756 if (m_resourceLoadStatistics) { 1757 m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, WTFMove(completionHandler)); 1758 return; 1759 } 1760 1761 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1762 1763 for (auto& processPool : processPools()) { 1764 if (auto* process = processPool->networkProcess()) 1765 process->scheduleClearInMemoryAndPersistent(m_sessionID, modifiedSince, shouldGrandfather, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1766 } 1767 } 1768 1769 void WebsiteDataStore::scheduleClearInMemoryAndPersistent(ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler) 1770 { 1771 ASSERT(RunLoop::isMain()); 1772 1773 if (m_resourceLoadStatistics) { 1774 m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(shouldGrandfather, WTFMove(completionHandler)); 1775 return; 1776 } 1777 1778 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1779 1780 for (auto& processPool : processPools()) { 1781 if (auto* process = processPool->networkProcess()) 1782 process->scheduleClearInMemoryAndPersistent(m_sessionID, { }, shouldGrandfather, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1783 } 1784 } 1785 1786 void WebsiteDataStore::scheduleCookieBlockingUpdate(CompletionHandler<void()>&& completionHandler) 1787 { 1788 if (m_resourceLoadStatistics) { 1789 m_resourceLoadStatistics->scheduleCookieBlockingUpdate(WTFMove(completionHandler)); 1790 return; 1791 } 1792 1793 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1794 1795 for (auto& processPool : processPools()) { 1796 if (auto* process = processPool->networkProcess()) 1797 process->scheduleCookieBlockingUpdate(m_sessionID, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1798 } 1799 } 1800 1801 void WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&& completionHandler) 1802 { 1803 ASSERT(RunLoop::isMain()); 1804 1805 if (m_resourceLoadStatistics) { 1806 m_resourceLoadStatistics->scheduleStatisticsAndDataRecordsProcessing(WTFMove(completionHandler)); 1807 return; 1808 } 1809 1810 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1811 1812 for (auto& processPool : processPools()) { 1813 if (auto* process = processPool->networkProcess()) 1814 process->scheduleStatisticsAndDataRecordsProcessing(m_sessionID, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1815 } 1816 } 1817 1261 1818 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1262 1819 void WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler) … … 1269 1826 } 1270 1827 } 1828 #endif 1271 1829 1272 1830 void WebsiteDataStore::setAgeCapForClientSideCookies(Optional<Seconds> seconds, CompletionHandler<void()>&& completionHandler) … … 1277 1835 if (auto* process = processPool->networkProcess()) 1278 1836 process->setAgeCapForClientSideCookies(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1837 } 1838 } 1839 1840 void WebsiteDataStore::setLastSeen(const URL& url, Seconds seconds, CompletionHandler<void()>&& completionHandler) 1841 { 1842 if (url.protocolIsAbout() || url.isEmpty()) { 1843 completionHandler(); 1844 return; 1845 } 1846 1847 if (m_resourceLoadStatistics) { 1848 m_resourceLoadStatistics->setLastSeen(url, seconds, WTFMove(completionHandler)); 1849 return; 1850 } 1851 1852 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1853 1854 const auto& primaryDomain = WebCore::ResourceLoadStatistics::primaryDomain(url); 1855 for (auto& processPool : processPools()) { 1856 if (auto* process = processPool->networkProcess()) 1857 process->setLastSeen(m_sessionID, primaryDomain, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1858 } 1859 } 1860 1861 void WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned(bool value, CompletionHandler<void()>&& completionHandler) 1862 { 1863 if (m_resourceLoadStatistics) { 1864 m_resourceLoadStatistics->setNotifyPagesWhenDataRecordsWereScanned(value, WTFMove(completionHandler)); 1865 return; 1866 } 1867 1868 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1869 1870 for (auto& processPool : processPools()) { 1871 if (auto* process = processPool->networkProcess()) 1872 process->setNotifyPagesWhenDataRecordsWereScanned(m_sessionID, value, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1873 } 1874 } 1875 1876 void WebsiteDataStore::setNotifyPagesWhenTelemetryWasCaptured(bool value, CompletionHandler<void()>&& completionHandler) 1877 { 1878 if (m_resourceLoadStatistics) { 1879 m_resourceLoadStatistics->setNotifyPagesWhenTelemetryWasCaptured(value, WTFMove(completionHandler)); 1880 return; 1881 } 1882 1883 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1884 1885 for (auto& processPool : processPools()) { 1886 if (auto* process = processPool->networkProcess()) 1887 process->setNotifyPagesWhenTelemetryWasCaptured(m_sessionID, value, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1279 1888 } 1280 1889 } … … 1313 1922 1314 1923 auto& networkProcess = webPage->process().processPool().ensureNetworkProcess(); 1315 networkProcess.grantStorageAccess(m_sessionID, resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(completionHandler));1924 networkProcess.grantStorageAccess(m_sessionID, resourceDomain, firstPartyDomain, frameID, pageID, false, WTFMove(completionHandler)); 1316 1925 } 1317 1926 … … 1338 1947 return; 1339 1948 } 1340 1341 m_resourceLoadStatistics->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler)); 1949 1950 if (m_resourceLoadStatistics) { 1951 m_resourceLoadStatistics->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler)); 1952 return; 1953 } 1954 1955 auto* webPage = WebProcessProxy::webPage(pageID); 1956 if (!webPage) { 1957 completionHandler(false); 1958 return; 1959 } 1960 1961 if (auto networkProcess = webPage->process().processPool().networkProcess()) 1962 networkProcess->hasStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler)); 1342 1963 } 1343 1964 … … 1349 1970 } 1350 1971 1351 m_resourceLoadStatistics->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler)); 1972 if (m_resourceLoadStatistics) { 1973 m_resourceLoadStatistics->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler)); 1974 return; 1975 } 1976 1977 auto* webPage = WebProcessProxy::webPage(pageID); 1978 if (!webPage) { 1979 completionHandler(StorageAccessStatus::CannotRequestAccess); 1980 return; 1981 } 1982 1983 if (auto networkProcess = webPage->process().processPool().networkProcess()) 1984 networkProcess->requestStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler)); 1352 1985 } 1353 1986 … … 1359 1992 } 1360 1993 1361 m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler)); 1994 if (m_resourceLoadStatistics) { 1995 m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler)); 1996 return; 1997 } 1998 1999 auto* webPage = WebProcessProxy::webPage(pageID); 2000 if (!webPage) { 2001 completionHandler(false); 2002 return; 2003 } 2004 2005 if (auto networkProcess = webPage->process().processPool().networkProcess()) 2006 networkProcess->grantStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler)); 2007 } 2008 2009 void WebsiteDataStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionHandler<void()>&& completionHandler) 2010 { 2011 if (m_resourceLoadStatistics) { 2012 m_resourceLoadStatistics->setTimeToLiveUserInteraction(seconds, WTFMove(completionHandler)); 2013 return; 2014 } 2015 2016 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 2017 2018 for (auto& processPool : processPools()) { 2019 if (auto* networkProcess = processPool->networkProcess()) 2020 networkProcess->setTimeToLiveUserInteraction(m_sessionID, seconds, [callbackAggregator = callbackAggregator.copyRef()] { }); 2021 } 2022 } 2023 2024 void WebsiteDataStore::logUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler) 2025 { 2026 ASSERT(RunLoop::isMain()); 2027 2028 if (url.protocolIsAbout() || url.isEmpty()) { 2029 completionHandler(); 2030 return; 2031 } 2032 2033 if (m_resourceLoadStatistics) { 2034 m_resourceLoadStatistics->logUserInteraction(url, WTFMove(completionHandler)); 2035 return; 2036 } 2037 2038 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 2039 2040 for (auto& processPool : processPools()) { 2041 if (auto* process = processPool->networkProcess()) 2042 process->logUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [callbackAggregator = callbackAggregator.copyRef()] { }); 2043 } 2044 } 2045 2046 void WebsiteDataStore::hasHadUserInteraction(const URL& url, CompletionHandler<void(bool)>&& completionHandler) 2047 { 2048 ASSERT(RunLoop::isMain()); 2049 2050 if (url.protocolIsAbout() || url.isEmpty()) { 2051 completionHandler(false); 2052 return; 2053 } 2054 2055 if (m_resourceLoadStatistics) { 2056 m_resourceLoadStatistics->hasHadUserInteraction(url, WTFMove(completionHandler)); 2057 return; 2058 } 2059 2060 for (auto& processPool : processPools()) { 2061 if (auto* process = processPool->networkProcess()) { 2062 process->hasHadUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 2063 ASSERT(processPools().size() == 1); 2064 break; 2065 } 2066 } 2067 } 2068 2069 void WebsiteDataStore::clearUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler) 2070 { 2071 ASSERT(RunLoop::isMain()); 2072 2073 if (url.protocolIsAbout() || url.isEmpty()) { 2074 completionHandler(); 2075 return; 2076 } 2077 2078 if (m_resourceLoadStatistics) { 2079 m_resourceLoadStatistics->clearUserInteraction(url, WTFMove(completionHandler)); 2080 return; 2081 } 2082 2083 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 2084 2085 for (auto& processPool : processPools()) { 2086 if (auto* process = processPool->networkProcess()) 2087 process->clearUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [callbackAggregator = callbackAggregator.copyRef()] { }); 2088 } 2089 } 2090 2091 void WebsiteDataStore::isGrandfathered(const URL& url, CompletionHandler<void(bool)>&& completionHandler) 2092 { 2093 ASSERT(RunLoop::isMain()); 2094 2095 if (url.protocolIsAbout() || url.isEmpty()) { 2096 completionHandler(false); 2097 return; 2098 } 2099 2100 if (m_resourceLoadStatistics) { 2101 m_resourceLoadStatistics->isGrandfathered(url, WTFMove(completionHandler)); 2102 return; 2103 } 2104 2105 for (auto& processPool : processPools()) { 2106 if (auto* process = processPool->networkProcess()) { 2107 process->isGrandfathered(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); 2108 ASSERT(processPools().size() == 1); 2109 break; 2110 } 2111 } 2112 } 2113 2114 void WebsiteDataStore::setGrandfathered(const URL& url, bool isGrandfathered, CompletionHandler<void()>&& completionHandler) 2115 { 2116 ASSERT(RunLoop::isMain()); 2117 2118 if (url.protocolIsAbout() || url.isEmpty()) { 2119 completionHandler(); 2120 return; 2121 } 2122 2123 if (m_resourceLoadStatistics) { 2124 m_resourceLoadStatistics->setGrandfathered(url, isGrandfathered, WTFMove(completionHandler)); 2125 return; 2126 } 2127 2128 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 2129 2130 for (auto& processPool : processPools()) { 2131 if (auto* process = processPool->networkProcess()) 2132 process->setGrandfathered(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), isGrandfathered, [callbackAggregator = callbackAggregator.copyRef()] { }); 2133 } 1362 2134 } 1363 2135 #endif // ENABLE(RESOURCE_LOAD_STATISTICS) … … 1409 2181 m_storageManager->processWillOpenConnection(webProcessProxy, connection); 1410 2182 2183 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1411 2184 if (m_resourceLoadStatistics) 1412 2185 webProcessProxy.addMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName(), *m_resourceLoadStatistics); 2186 #endif 1413 2187 } 1414 2188 … … 1427 2201 void WebsiteDataStore::webProcessDidCloseConnection(WebProcessProxy& webProcessProxy, IPC::Connection& connection) 1428 2202 { 2203 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1429 2204 if (m_resourceLoadStatistics) 1430 2205 webProcessProxy.removeMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName()); 2206 #endif 1431 2207 1432 2208 if (m_storageManager) … … 1541 2317 bool WebsiteDataStore::resourceLoadStatisticsEnabled() const 1542 2318 { 1543 return !!m_resourceLoadStatistics; 2319 #if ENABLE(RESOURCE_LOAD_STATISTICS) 2320 return m_resourceLoadStatisticsEnabled; 2321 #else 2322 return false; 2323 #endif 2324 } 2325 2326 bool WebsiteDataStore::resourceLoadStatisticsDebugMode() const 2327 { 2328 #if ENABLE(RESOURCE_LOAD_STATISTICS) 2329 return m_resourceLoadStatisticsDebugMode; 2330 #else 2331 return false; 2332 #endif 1544 2333 } 1545 2334 1546 2335 void WebsiteDataStore::setResourceLoadStatisticsEnabled(bool enabled) 1547 2336 { 2337 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1548 2338 if (m_sessionID.isEphemeral() || enabled == resourceLoadStatisticsEnabled()) 1549 2339 return; 1550 2340 1551 2341 if (enabled) { 2342 // FIXME(193297): Remove this assert 1552 2343 ASSERT(!m_resourceLoadStatistics); 1553 2344 enableResourceLoadStatisticsAndSetTestingCallback(nullptr); … … 1555 2346 } 1556 2347 1557 2348 // FIXME(193297): Remove these two lines 1558 2349 unregisterWebResourceLoadStatisticsStoreAsMessageReceiver(); 1559 2350 m_resourceLoadStatistics = nullptr; 1560 2351 1561 auto existingProcessPools = processPools(std::numeric_limits<size_t>::max(), false); 1562 for (auto& processPool : existingProcessPools) 2352 for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) { 1563 2353 processPool->setResourceLoadStatisticsEnabled(false); 1564 } 1565 2354 processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(false)); 2355 } 2356 #else 2357 UNUSED_PARAM(enabled); 2358 #endif 2359 } 2360 2361 void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled) 2362 { 2363 setResourceLoadStatisticsDebugMode(enabled, []() { }); 2364 } 2365 2366 void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled, CompletionHandler<void()>&& completionHandler) 2367 { 2368 #if ENABLE(RESOURCE_LOAD_STATISTICS) 2369 m_resourceLoadStatisticsDebugMode = enabled; 2370 if (m_resourceLoadStatistics) { 2371 m_resourceLoadStatistics->setResourceLoadStatisticsDebugMode(enabled, WTFMove(completionHandler)); 2372 return; 2373 } 2374 2375 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 2376 2377 for (auto& processPool : processPools()) { 2378 if (auto* process = processPool->networkProcess()) 2379 process->setResourceLoadStatisticsDebugMode(m_sessionID, enabled, [callbackAggregator = callbackAggregator.copyRef()] { }); 2380 } 2381 #else 2382 UNUSED_PARAM(enabled); 2383 UNUSED_PARAM(completionHandler); 2384 #endif 2385 } 2386 2387 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1566 2388 void WebsiteDataStore::unregisterWebResourceLoadStatisticsStoreAsMessageReceiver() 1567 2389 { … … 1583 2405 } 1584 2406 1585 bool WebsiteDataStore::resourceLoadStatisticsDebugMode() const 1586 { 1587 return m_resourceLoadStatisticsDebugMode; 1588 } 1589 1590 void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled) 1591 { 1592 setResourceLoadStatisticsDebugMode(enabled, []() { }); 1593 } 1594 1595 void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled, CompletionHandler<void()>&& completionHandler) 1596 { 1597 m_resourceLoadStatisticsDebugMode = enabled; 2407 void WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback) 2408 { 2409 ASSERT(!m_sessionID.isEphemeral()); 2410 2411 m_resourceLoadStatisticsEnabled = true; 2412 setStatisticsTestingCallback(WTFMove(callback)); 2413 2414 // FIXME(193297): Remove this check 1598 2415 if (m_resourceLoadStatistics) 1599 m_resourceLoadStatistics->setResourceLoadStatisticsDebugMode(enabled, WTFMove(completionHandler)); 1600 else 1601 completionHandler(); 1602 } 1603 1604 void WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback) 1605 { 1606 ASSERT(!m_sessionID.isEphemeral()); 1607 1608 if (m_resourceLoadStatistics) { 1609 m_resourceLoadStatistics->setStatisticsTestingCallback(WTFMove(callback)); 1610 return; 1611 } 2416 return; 1612 2417 1613 2418 resolveDirectoriesIfNecessary(); 2419 2420 // FIXME(193297): Remove these two lines 1614 2421 m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this); 1615 m_resourceLoadStatistics->setStatisticsTestingCallback(WTFMove(callback));1616 1617 2422 registerWebResourceLoadStatisticsStoreAsMessageReceiver(); 1618 2423 1619 for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) 2424 for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) { 1620 2425 processPool->setResourceLoadStatisticsEnabled(true); 2426 processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(true)); 2427 } 2428 } 2429 2430 void WebsiteDataStore::logTestingEvent(const String& event) 2431 { 2432 ASSERT(RunLoop::isMain()); 2433 2434 if (m_statisticsTestingCallback) 2435 m_statisticsTestingCallback(event); 1621 2436 } 1622 2437 … … 1629 2444 callback(); 1630 2445 } 2446 #endif 1631 2447 1632 2448 Vector<WebCore::Cookie> WebsiteDataStore::pendingCookies() const … … 1699 2515 void WebsiteDataStore::didCreateNetworkProcess() 1700 2516 { 2517 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1701 2518 if (m_resourceLoadStatistics) 1702 2519 m_resourceLoadStatistics->didCreateNetworkProcess(); 1703 } 1704 1705 } 2520 #endif 2521 } 2522 2523 } -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r240156 r240243 1 1 /* 2 * Copyright (C) 2014-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2014-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 73 73 74 74 #if ENABLE(RESOURCE_LOAD_STATISTICS) 75 enum class StorageAccessStatus; 75 enum class ShouldGrandfather; 76 enum class StorageAccessStatus : unsigned; 76 77 enum class StorageAccessPromptStatus; 77 78 #endif … … 105 106 void setServiceWorkerRegistrationDirectory(String&& directory) { m_resolvedConfiguration->setServiceWorkerRegistrationDirectory(WTFMove(directory)); } 106 107 108 #if ENABLE(RESOURCE_LOAD_STATISTICS) 107 109 WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); } 108 110 void clearResourceLoadStatisticsInWebProcesses(CompletionHandler<void()>&&); 111 #endif 109 112 110 113 static void cloneSessionData(WebPageProxy& sourcePage, WebPageProxy& newPage); 111 114 112 115 void fetchData(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Function<void(Vector<WebsiteDataRecord>)>&& completionHandler); 116 void removeData(OptionSet<WebsiteDataType>, WallTime modifiedSince, Function<void()>&& completionHandler); 117 void removeData(OptionSet<WebsiteDataType>, const Vector<WebsiteDataRecord>&, Function<void()>&& completionHandler); 118 119 #if ENABLE(RESOURCE_LOAD_STATISTICS) 113 120 void fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, HashSet<String>&&)>&& completionHandler); 114 121 void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Function<void(HashSet<String>&&)>&& completionHandler); 115 void removeData(OptionSet<WebsiteDataType>, WallTime modifiedSince, Function<void()>&& completionHandler);116 void removeData(OptionSet<WebsiteDataType>, const Vector<WebsiteDataRecord>&, Function<void()>&& completionHandler);117 122 void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler); 118 123 119 #if ENABLE(RESOURCE_LOAD_STATISTICS) 124 void clearPrevalentResource(const URL&, CompletionHandler<void()>&&); 125 void clearUserInteraction(const URL&, CompletionHandler<void()>&&); 126 void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, CompletionHandler<void(const HashSet<String>&)>&&); 127 void dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&&); 128 void logTestingEvent(const String&); 129 void logUserInteraction(const URL&, CompletionHandler<void()>&&); 120 130 void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&); 121 131 void setAgeCapForClientSideCookies(Optional<Seconds>, CompletionHandler<void()>&&); … … 123 133 void getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&&); 124 134 void grantStorageAccessHandler(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool wasGranted)>&&); 135 void hasHadUserInteraction(const URL&, CompletionHandler<void(bool)>&&); 136 void isGrandfathered(const URL&, CompletionHandler<void(bool)>&&); 137 void isPrevalentResource(const URL&, CompletionHandler<void(bool)>&&); 138 void isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&&); 139 void isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&&); 140 void isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&&); 141 void isVeryPrevalentResource(const URL&, CompletionHandler<void(bool)>&&); 125 142 void removeAllStorageAccessHandler(CompletionHandler<void()>&&); 126 143 void removePrevalentDomains(const Vector<String>& domains); 144 void resetParametersToDefaultValues(CompletionHandler<void()>&&); 145 void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&); 146 void scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfather, CompletionHandler<void()>&&); 147 void scheduleClearInMemoryAndPersistent(ShouldGrandfather, CompletionHandler<void()>&&); 148 void scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&&); 149 void submitTelemetry(); 150 void setCacheMaxAgeCap(Seconds, CompletionHandler<void()>&&); 151 void setGrandfathered(const URL&, bool, CompletionHandler<void()>&&); 152 void setGrandfatheringTime(Seconds, CompletionHandler<void()>&&); 153 void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&); 154 void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&); 155 void setPruneEntriesDownTo(size_t, CompletionHandler<void()>&&); 156 void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&&); 157 void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&&); 158 void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&); 159 void setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&); 160 void setTimeToLiveUserInteraction(Seconds, CompletionHandler<void()>&&); 161 void setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&); 162 void setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&); 163 void setMaxStatisticsEntries(size_t, CompletionHandler<void()>&&); 164 void setMinimumTimeBetweenDataRecordsRemoval(Seconds, CompletionHandler<void()>&&); 165 void setNotifyPagesWhenTelemetryWasCaptured(bool, CompletionHandler<void()>&&); 166 void setPrevalentResource(const URL&, CompletionHandler<void()>&&); 167 void setPrevalentResourceForDebugMode(const URL&, CompletionHandler<void()>&&); 168 void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool, CompletionHandler<void()>&&); 169 void setStatisticsTestingCallback(WTF::Function<void(const String&)>&& callback) { m_statisticsTestingCallback = WTFMove(callback); } 170 void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&); 127 171 void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); 128 172 void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); 129 173 void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&); 174 void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame); 130 175 #endif 131 176 void setCacheMaxAgeCapForPrevalentResources(Seconds, CompletionHandler<void()>&&); … … 211 256 static void platformRemoveRecentSearches(WallTime); 212 257 258 #if ENABLE(RESOURCE_LOAD_STATISTICS) 213 259 void registerWebResourceLoadStatisticsStoreAsMessageReceiver(); 214 260 void unregisterWebResourceLoadStatisticsStoreAsMessageReceiver(); 261 #endif 215 262 216 263 HashSet<RefPtr<WebProcessPool>> processPools(size_t count = std::numeric_limits<size_t>::max(), bool ensureAPoolExists = true) const; … … 234 281 const RefPtr<StorageManager> m_storageManager; 235 282 const Ref<DeviceIdHashSaltStorage> m_deviceIdHashSaltStorage; 283 284 #if ENABLE(RESOURCE_LOAD_STATISTICS) 236 285 RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics; 237 286 bool m_resourceLoadStatisticsDebugMode { false }; 287 bool m_resourceLoadStatisticsEnabled { false }; 288 WTF::Function<void(const String&)> m_statisticsTestingCallback; 289 #endif 238 290 239 291 Ref<WorkQueue> m_queue; -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r239835 r240243 205 205 m_plugInAutoStartOriginHashes.add(PAL::SessionID::defaultSessionID(), HashMap<unsigned, WallTime>()); 206 206 207 #if ENABLE(RESOURCE_LOAD_STATISTICS) 207 208 ResourceLoadObserver::shared().setNotificationCallback([this] (Vector<ResourceLoadStatistics>&& statistics) { 208 209 parentProcessConnection()->send(Messages::WebResourceLoadStatisticsStore::ResourceLoadStatisticsUpdated(WTFMove(statistics)), 0); … … 212 213 parentProcessConnection()->send(Messages::WebResourceLoadStatisticsStore::RequestStorageAccessUnderOpener(domainInNeedOfStorageAccess, openerPageID, openerDomain), 0); 213 214 }); 215 #endif 214 216 215 217 Gigacage::disableDisablingPrimitiveGigacageIfShouldBeEnabled(); … … 383 385 ensureNetworkProcessConnection(); 384 386 387 #if ENABLE(RESOURCE_LOAD_STATISTICS) 388 ResourceLoadObserver::shared().setLogUserInteractionNotificationCallback([this] (PAL::SessionID sessionID, const String& topLevelOrigin) { 389 m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogUserInteraction(sessionID, topLevelOrigin), 0); 390 }); 391 #endif 392 385 393 setTerminationTimeout(parameters.terminationTimeout); 386 394
Note: See TracChangeset
for help on using the changeset viewer.