Changeset 248144 in webkit
- Timestamp:
- Aug 1, 2019 6:59:08 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r248139 r248144 1 2019-08-01 Alex Christensen <achristensen@webkit.org> 2 3 Do not send NetworkProcessProxy::LogTestingEvent message if we are not testing 4 https://bugs.webkit.org/show_bug.cgi?id=200360 5 6 Reviewed by Tim Horton. 7 8 Sending this message causes instantiation of the default WebsiteDataStore in the UIProcess, 9 which causes more memory to be used than is needed if we are browsing without the default WebsiteDataStore. 10 11 Covered by an API test. 12 13 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 14 (WebKit::WebResourceLoadStatisticsStore::logTestingEvent): 15 * NetworkProcess/NetworkSession.cpp: 16 (WebKit::NetworkSession::NetworkSession): 17 * NetworkProcess/NetworkSession.h: 18 (WebKit::NetworkSession::enableResourceLoadStatisticsLogTestingEvent const): 19 * NetworkProcess/NetworkSessionCreationParameters.cpp: 20 (WebKit::NetworkSessionCreationParameters::encode const): 21 (WebKit::NetworkSessionCreationParameters::decode): 22 * NetworkProcess/NetworkSessionCreationParameters.h: 23 * UIProcess/WebProcessPool.cpp: 24 (WebKit::WebProcessPool::ensureNetworkProcess): 25 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 26 (WebKit::WebsiteDataStore::parameters): 27 * UIProcess/WebsiteData/WebsiteDataStore.h: 28 (WebKit::WebsiteDataStore::hasStatisticsTestingCallback const): 29 1 30 2019-08-01 Alex Christensen <achristensen@webkit.org> 2 31 -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
r247918 r248144 1007 1007 ASSERT(RunLoop::isMain()); 1008 1008 1009 if (m_networkSession )1009 if (m_networkSession && m_networkSession->enableResourceLoadStatisticsLogTestingEvent()) 1010 1010 m_networkSession->networkProcess().parentProcessConnection()->send(Messages::NetworkProcessProxy::LogTestingEvent(m_networkSession->sessionID(), event), 0); 1011 1011 } -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r248047 r248144 1160 1160 } 1161 1161 1162 void NetworkProcess::setResourceLoadStatisticsLogTestingEvent(bool enabled) 1163 { 1164 forEachNetworkSession([enabled](auto& networkSession) { 1165 networkSession.setResourceLoadStatisticsLogTestingEvent(enabled); 1166 }); 1167 } 1168 1162 1169 void NetworkProcess::setResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode, CompletionHandler<void()>&& completionHandler) 1163 1170 { -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r248047 r248144 247 247 void setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID, bool value, CompletionHandler<void()>&&); 248 248 void setResourceLoadStatisticsEnabled(bool); 249 void setResourceLoadStatisticsLogTestingEvent(bool); 249 250 void setResourceLoadStatisticsDebugMode(PAL::SessionID, bool debugMode, CompletionHandler<void()>&&d); 250 251 void setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID, bool value, CompletionHandler<void()>&&); -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r248047 r248144 92 92 DumpResourceLoadStatistics(PAL::SessionID sessionID) -> (String dumpedStatistics) Async 93 93 SetResourceLoadStatisticsEnabled(bool enabled) 94 SetResourceLoadStatisticsLogTestingEvent(bool enabled) 94 95 UpdatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, Vector<WebCore::RegistrableDomain> domainsToBlock) -> () Async 95 96 IsGrandfathered(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain) -> (bool isGrandfathered) Async -
trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp
r247831 r248144 82 82 : m_sessionID(parameters.sessionID) 83 83 , m_networkProcess(networkProcess) 84 #if ENABLE(RESOURCE_LOAD_STATISTICS) 85 , m_enableResourceLoadStatisticsLogTestingEvent(parameters.enableResourceLoadStatisticsLogTestingEvent) 86 #endif 84 87 , m_adClickAttribution(makeUniqueRef<AdClickAttributionManager>(parameters.sessionID)) 85 88 , m_storageManager(StorageManager::create(String(parameters.localStorageDirectory))) -
trunk/Source/WebKit/NetworkProcess/NetworkSession.h
r247831 r248144 91 91 void logDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned significantFigures, WebCore::ShouldSample); 92 92 void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins); 93 bool enableResourceLoadStatisticsLogTestingEvent() const { return m_enableResourceLoadStatisticsLogTestingEvent; } 94 void setResourceLoadStatisticsLogTestingEvent(bool log) { m_enableResourceLoadStatisticsLogTestingEvent = log; } 93 95 #endif 94 96 void storeAdClickAttribution(WebCore::AdClickAttribution&&); … … 129 131 EnableResourceLoadStatisticsDebugMode m_enableResourceLoadStatisticsDebugMode { EnableResourceLoadStatisticsDebugMode::No }; 130 132 WebCore::RegistrableDomain m_resourceLoadStatisticsManualPrevalentResource; 133 bool m_enableResourceLoadStatisticsLogTestingEvent; 131 134 #endif 132 135 UniqueRef<AdClickAttributionManager> m_adClickAttribution; -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp
r247567 r248144 51 51 , { }, { } 52 52 #endif 53 , { }, { }, false, { }, { }, { }, { }, { }, { }, { }, { }, { }53 , { }, { }, false, false, { }, { }, { }, { }, { }, { }, { }, { }, { } 54 54 }; 55 55 } … … 81 81 encoder << resourceLoadStatisticsDirectoryExtensionHandle; 82 82 encoder << enableResourceLoadStatistics; 83 encoder << enableResourceLoadStatisticsLogTestingEvent; 83 84 encoder << shouldIncludeLocalhostInResourceLoadStatistics; 84 85 encoder << enableResourceLoadStatisticsDebugMode; … … 186 187 decoder >> enableResourceLoadStatistics; 187 188 if (!enableResourceLoadStatistics) 189 return WTF::nullopt; 190 191 Optional<bool> enableResourceLoadStatisticsLogTestingEvent; 192 decoder >> enableResourceLoadStatisticsLogTestingEvent; 193 if (!enableResourceLoadStatisticsLogTestingEvent) 188 194 return WTF::nullopt; 189 195 … … 258 264 , WTFMove(*resourceLoadStatisticsDirectoryExtensionHandle) 259 265 , WTFMove(*enableResourceLoadStatistics) 266 , WTFMove(*enableResourceLoadStatisticsLogTestingEvent) 260 267 , WTFMove(*shouldIncludeLocalhostInResourceLoadStatistics) 261 268 , WTFMove(*enableResourceLoadStatisticsDebugMode) -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h
r247567 r248144 85 85 SandboxExtension::Handle resourceLoadStatisticsDirectoryExtensionHandle; 86 86 bool enableResourceLoadStatistics { false }; 87 bool enableResourceLoadStatisticsLogTestingEvent { false }; 87 88 bool shouldIncludeLocalhostInResourceLoadStatistics { true }; 88 89 bool enableResourceLoadStatisticsDebugMode { false }; -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r247733 r248144 457 457 458 458 if (callback) { 459 _websiteDataStore->websiteDataStore(). enableResourceLoadStatisticsAndSetTestingCallback([callback = makeBlockPtr(callback), self](const String& event) {460 callback(self, (NSString *)event);459 _websiteDataStore->websiteDataStore().setStatisticsTestingCallback([callback = makeBlockPtr(callback), self](const String& event) { 460 callback(self, event); 461 461 }); 462 462 return; -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r248047 r248144 595 595 596 596 bool enableResourceLoadStatistics = m_shouldEnableITPForDefaultSessions; 597 bool enableResourceLoadStatisticsLogTestingEvent = false; 597 598 bool shouldIncludeLocalhost = true; 598 599 bool enableResourceLoadStatisticsDebugMode = false; … … 600 601 if (withWebsiteDataStore) { 601 602 enableResourceLoadStatistics = withWebsiteDataStore->resourceLoadStatisticsEnabled(); 603 #if ENABLE(RESOURCE_LOAD_STATISTICS) 604 enableResourceLoadStatisticsLogTestingEvent = withWebsiteDataStore->hasStatisticsTestingCallback(); 605 #endif 602 606 if (enableResourceLoadStatistics) { 603 607 auto networkSessionParameters = withWebsiteDataStore->parameters().networkSessionParameters; … … 611 615 } else if (m_websiteDataStore) { 612 616 enableResourceLoadStatistics = m_websiteDataStore->resourceLoadStatisticsEnabled(); 617 #if ENABLE(RESOURCE_LOAD_STATISTICS) 618 enableResourceLoadStatisticsLogTestingEvent = m_websiteDataStore->websiteDataStore().hasStatisticsTestingCallback(); 619 #endif 613 620 if (enableResourceLoadStatistics) { 614 621 auto networkSessionParameters = m_websiteDataStore->websiteDataStore().parameters().networkSessionParameters; … … 623 630 624 631 parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatistics = enableResourceLoadStatistics; 632 parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatisticsLogTestingEvent = enableResourceLoadStatisticsLogTestingEvent; 625 633 parameters.defaultDataStoreParameters.networkSessionParameters.shouldIncludeLocalhostInResourceLoadStatistics = shouldIncludeLocalhost; 626 634 parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatisticsDebugMode = enableResourceLoadStatisticsDebugMode; -
trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
r247567 r248144 135 135 WTFMove(resourceLoadStatisticsDirectoryHandle), 136 136 false, 137 false, 137 138 shouldIncludeLocalhostInResourceLoadStatistics, 138 139 enableResourceLoadStatisticsDebugMode, -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r247567 r248144 1846 1846 1847 1847 if (enabled) { 1848 enableResourceLoadStatisticsAndSetTestingCallback(nullptr); 1848 m_resourceLoadStatisticsEnabled = true; 1849 1850 resolveDirectoriesIfNecessary(); 1851 1852 for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) { 1853 processPool->setResourceLoadStatisticsEnabled(true); 1854 processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(true)); 1855 } 1849 1856 return; 1850 1857 } … … 1860 1867 #endif 1861 1868 } 1869 1870 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1871 void WebsiteDataStore::setStatisticsTestingCallback(Function<void(const String&)>&& callback) 1872 { 1873 if (callback) { 1874 for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) 1875 processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsLogTestingEvent(true)); 1876 } 1877 1878 m_statisticsTestingCallback = WTFMove(callback); 1879 } 1880 #endif 1862 1881 1863 1882 void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled) … … 1882 1901 1883 1902 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1884 void WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback)1885 {1886 ASSERT(!m_sessionID.isEphemeral());1887 1888 m_resourceLoadStatisticsEnabled = true;1889 setStatisticsTestingCallback(WTFMove(callback));1890 1891 resolveDirectoriesIfNecessary();1892 1893 for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) {1894 processPool->setResourceLoadStatisticsEnabled(true);1895 processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(true));1896 }1897 }1898 1899 1903 void WebsiteDataStore::logTestingEvent(const String& event) 1900 1904 { -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r247686 r248144 172 172 void setPrevalentResourceForDebugMode(const URL&, CompletionHandler<void()>&&); 173 173 void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool, CompletionHandler<void()>&&); 174 void setStatisticsTestingCallback(WTF::Function<void(const String&)>&& callback) { m_statisticsTestingCallback = WTFMove(callback); } 174 void setStatisticsTestingCallback(Function<void(const String&)>&&); 175 bool hasStatisticsTestingCallback() const { return !!m_statisticsTestingCallback; } 175 176 void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&); 176 177 void setSubframeUnderTopFrameDomain(const URL& subframe, const URL& topFrame); … … 208 209 void clearPendingCookies(); 209 210 210 void enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback);211 212 211 void setBoundInterfaceIdentifier(String&& identifier) { m_boundInterfaceIdentifier = WTFMove(identifier); } 213 212 const String& boundInterfaceIdentifier() { return m_boundInterfaceIdentifier; } -
trunk/Tools/ChangeLog
r248139 r248144 1 2019-08-01 Alex Christensen <achristensen@webkit.org> 2 3 Do not send NetworkProcessProxy::LogTestingEvent message if we are not testing 4 https://bugs.webkit.org/show_bug.cgi?id=200360 5 6 Reviewed by Tim Horton. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm: 9 (cleanupITPDatabase): 10 (TEST): 11 1 12 2019-08-01 Alex Christensen <achristensen@webkit.org> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm
r246500 r248144 28 28 #import "PlatformUtilities.h" 29 29 #import "TestNavigationDelegate.h" 30 #import "TestWKWebView.h" 30 31 #import <WebKit/WKFoundation.h> 31 32 #import <WebKit/WKPreferencesPrivate.h> … … 215 216 // Make sure 'evil.com' is not in our data set. 216 217 static bool doneFlag; 217 [dataStore _clearPrevalentDomain:[NSURL URLWithString:@"http://evil.com"] completionHandler: ^(void) {218 doneFlag = true;219 }];220 221 218 static bool dataSyncCompleted; 222 219 [dataStore _setResourceLoadStatisticsTestingCallback:^(WKWebsiteDataStore *, NSString *message) { … … 225 222 226 223 dataSyncCompleted = true; 224 }]; 225 [dataStore _clearPrevalentDomain:[NSURL URLWithString:@"http://evil.com"] completionHandler: ^(void) { 226 doneFlag = true; 227 227 }]; 228 228 … … 474 474 TestWebKitAPI::Util::run(&doneFlag); 475 475 } 476 477 TEST(ResourceLoadStatistics, NoMessagesWhenNotTesting) 478 { 479 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 480 WKWebsiteDataStore *dataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:[[[_WKWebsiteDataStoreConfiguration alloc] init] autorelease]] autorelease]; 481 [configuration setWebsiteDataStore:dataStore]; 482 [dataStore _setResourceLoadStatisticsEnabled:YES]; 483 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]); 484 [webView synchronouslyLoadTestPageNamed:@"simple"]; 485 EXPECT_FALSE([WKWebsiteDataStore _defaultDataStoreExists]); 486 }
Note: See TracChangeset
for help on using the changeset viewer.