Move DownloadMonitor test speed multiplier from WebProcessPool to WebsiteDataStoreCon...
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Sep 2019 18:49:19 +0000 (18:49 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Sep 2019 18:49:19 +0000 (18:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202339

Reviewed by Youenn Fablet.

Source/WebKit:

This was only used for some unit tests, which still are accelerated so they pass in the same amount of time as before.
I need this value to not be process-global in the NetworkProcess.

* NetworkProcess/Downloads/Download.cpp:
(WebKit::Download::Download):
* NetworkProcess/Downloads/Download.h:
(WebKit::Download::Download):
(WebKit::Download::testSpeedMultiplier const):
* NetworkProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::resumeDownload):
* NetworkProcess/Downloads/DownloadManager.h:
* NetworkProcess/Downloads/DownloadMonitor.cpp:
(WebKit::DownloadMonitor::applicationDidEnterBackground):
(WebKit::DownloadMonitor::testSpeedMultiplier const):
(WebKit::DownloadMonitor::timerFired):
(WebKit::DownloadMonitor::speedMultiplier const): Deleted.
* NetworkProcess/Downloads/DownloadMonitor.h:
* NetworkProcess/NetworkDataTaskBlob.cpp:
(WebKit::NetworkDataTaskBlob::download):
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::initializeNetworkProcess):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode const):
(WebKit::NetworkProcessCreationParameters::decode):
* NetworkProcess/NetworkProcessCreationParameters.h:
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::NetworkSession):
* NetworkProcess/NetworkSession.h:
(WebKit::NetworkSession::testSpeedMultiplier const):
* NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::encode const):
(WebKit::NetworkSessionCreationParameters::decode):
* NetworkProcess/NetworkSessionCreationParameters.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:dataTask:didBecomeDownloadTask:]):
* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration downloadMonitorSpeedMultiplierForTesting]): Deleted.
(-[_WKProcessPoolConfiguration setDownloadMonitorSpeedMultiplierForTesting:]): Deleted.
* UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
* UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
(-[_WKWebsiteDataStoreConfiguration testSpeedMultiplier]):
(-[_WKWebsiteDataStoreConfiguration setTestSpeedMultiplier:]):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeNetworkProcess):
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::parameters):
* UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
(WebKit::WebsiteDataStoreConfiguration::copy):
* UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
(WebKit::WebsiteDataStoreConfiguration::testSpeedMultiplier const):
(WebKit::WebsiteDataStoreConfiguration::setTestSpeedMultiplier):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
(TestWebKitAPI::webViewWithDownloadMonitorSpeedMultiplier):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250521 268f45cc-cd09-0410-ab3c-d52691b4dbfc

30 files changed:
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Downloads/Download.cpp
Source/WebKit/NetworkProcess/Downloads/Download.h
Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp
Source/WebKit/NetworkProcess/Downloads/DownloadManager.h
Source/WebKit/NetworkProcess/Downloads/DownloadMonitor.cpp
Source/WebKit/NetworkProcess/Downloads/DownloadMonitor.h
Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp
Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h
Source/WebKit/NetworkProcess/NetworkSession.cpp
Source/WebKit/NetworkProcess/NetworkSession.h
Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp
Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp
Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h
Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h
Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h
Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm
Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm

index e2e2de4..3c4373a 100644 (file)
@@ -1,3 +1,67 @@
+2019-09-30  Alex Christensen  <achristensen@webkit.org>
+
+        Move DownloadMonitor test speed multiplier from WebProcessPool to WebsiteDataStoreConfiguration
+        https://bugs.webkit.org/show_bug.cgi?id=202339
+
+        Reviewed by Youenn Fablet.
+
+        This was only used for some unit tests, which still are accelerated so they pass in the same amount of time as before.
+        I need this value to not be process-global in the NetworkProcess.
+
+        * NetworkProcess/Downloads/Download.cpp:
+        (WebKit::Download::Download):
+        * NetworkProcess/Downloads/Download.h:
+        (WebKit::Download::Download):
+        (WebKit::Download::testSpeedMultiplier const):
+        * NetworkProcess/Downloads/DownloadManager.cpp:
+        (WebKit::DownloadManager::resumeDownload):
+        * NetworkProcess/Downloads/DownloadManager.h:
+        * NetworkProcess/Downloads/DownloadMonitor.cpp:
+        (WebKit::DownloadMonitor::applicationDidEnterBackground):
+        (WebKit::DownloadMonitor::testSpeedMultiplier const):
+        (WebKit::DownloadMonitor::timerFired):
+        (WebKit::DownloadMonitor::speedMultiplier const): Deleted.
+        * NetworkProcess/Downloads/DownloadMonitor.h:
+        * NetworkProcess/NetworkDataTaskBlob.cpp:
+        (WebKit::NetworkDataTaskBlob::download):
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::initializeNetworkProcess):
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcessCreationParameters.cpp:
+        (WebKit::NetworkProcessCreationParameters::encode const):
+        (WebKit::NetworkProcessCreationParameters::decode):
+        * NetworkProcess/NetworkProcessCreationParameters.h:
+        * NetworkProcess/NetworkSession.cpp:
+        (WebKit::NetworkSession::NetworkSession):
+        * NetworkProcess/NetworkSession.h:
+        (WebKit::NetworkSession::testSpeedMultiplier const):
+        * NetworkProcess/NetworkSessionCreationParameters.cpp:
+        (WebKit::NetworkSessionCreationParameters::encode const):
+        (WebKit::NetworkSessionCreationParameters::decode):
+        * NetworkProcess/NetworkSessionCreationParameters.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (-[WKNetworkSessionDelegate URLSession:dataTask:didBecomeDownloadTask:]):
+        * UIProcess/API/APIProcessPoolConfiguration.cpp:
+        (API::ProcessPoolConfiguration::copy):
+        * UIProcess/API/APIProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+        (-[_WKProcessPoolConfiguration downloadMonitorSpeedMultiplierForTesting]): Deleted.
+        (-[_WKProcessPoolConfiguration setDownloadMonitorSpeedMultiplierForTesting:]): Deleted.
+        * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
+        * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
+        (-[_WKWebsiteDataStoreConfiguration testSpeedMultiplier]):
+        (-[_WKWebsiteDataStoreConfiguration setTestSpeedMultiplier:]):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+        (WebKit::WebsiteDataStore::parameters):
+        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
+        (WebKit::WebsiteDataStoreConfiguration::copy):
+        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
+        (WebKit::WebsiteDataStoreConfiguration::testSpeedMultiplier const):
+        (WebKit::WebsiteDataStoreConfiguration::setTestSpeedMultiplier):
+
 2019-09-30  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] IconDatabase is not thread-safe
index bf051bf..abc461e 100644 (file)
 namespace WebKit {
 using namespace WebCore;
 
-Download::Download(DownloadManager& downloadManager, DownloadID downloadID, NetworkDataTask& download, const PAL::SessionID& sessionID, const String& suggestedName)
+Download::Download(DownloadManager& downloadManager, DownloadID downloadID, NetworkDataTask& download, NetworkSession& session, const String& suggestedName)
     : m_downloadManager(downloadManager)
     , m_downloadID(downloadID)
     , m_client(downloadManager.client())
     , m_download(&download)
-    , m_sessionID(sessionID)
+    , m_sessionID(session.sessionID())
     , m_suggestedName(suggestedName)
+    , m_testSpeedMultiplier(session.testSpeedMultiplier())
 {
     ASSERT(m_downloadID.downloadID());
 
@@ -64,13 +65,14 @@ Download::Download(DownloadManager& downloadManager, DownloadID downloadID, Netw
 }
 
 #if PLATFORM(COCOA)
-Download::Download(DownloadManager& downloadManager, DownloadID downloadID, NSURLSessionDownloadTask* download, const PAL::SessionID& sessionID, const String& suggestedName)
+Download::Download(DownloadManager& downloadManager, DownloadID downloadID, NSURLSessionDownloadTask* download, NetworkSession& session, const String& suggestedName)
     : m_downloadManager(downloadManager)
     , m_downloadID(downloadID)
     , m_client(downloadManager.client())
     , m_downloadTask(download)
-    , m_sessionID(sessionID)
+    , m_sessionID(session.sessionID())
     , m_suggestedName(suggestedName)
+    , m_testSpeedMultiplier(session.testSpeedMultiplier())
 {
     ASSERT(m_downloadID.downloadID());
 
index 8265a7e..4061024 100644 (file)
@@ -68,9 +68,9 @@ class WebPage;
 class Download : public IPC::MessageSender, public CanMakeWeakPtr<Download> {
     WTF_MAKE_NONCOPYABLE(Download); WTF_MAKE_FAST_ALLOCATED;
 public:
-    Download(DownloadManager&, DownloadID, NetworkDataTask&, const PAL::SessionID& sessionID, const String& suggestedFilename = { });
+    Download(DownloadManager&, DownloadID, NetworkDataTask&, NetworkSession&, const String& suggestedFilename = { });
 #if PLATFORM(COCOA)
-    Download(DownloadManager&, DownloadID, NSURLSessionDownloadTask*, const PAL::SessionID& sessionID, const String& suggestedFilename = { });
+    Download(DownloadManager&, DownloadID, NSURLSessionDownloadTask*, NetworkSession&, const String& suggestedFilename = { });
 #endif
 
     ~Download();
@@ -99,6 +99,8 @@ public:
     void applicationWillEnterForeground() { m_monitor.applicationWillEnterForeground(); }
     DownloadManager& manager() const { return m_downloadManager; }
 
+    unsigned testSpeedMultiplier() const { return m_testSpeedMultiplier; }
+
 private:
     // IPC::MessageSender
     IPC::Connection* messageSenderConnection() const override;
@@ -124,6 +126,7 @@ private:
     bool m_wasCanceled { false };
     bool m_hasReceivedData { false };
     DownloadMonitor m_monitor { *this };
+    unsigned m_testSpeedMultiplier { 1 };
 };
 
 } // namespace WebKit
index 0427f19..6251e98 100644 (file)
@@ -123,7 +123,10 @@ void DownloadManager::resumeDownload(PAL::SessionID sessionID, DownloadID downlo
 #if !PLATFORM(COCOA)
     notImplemented();
 #else
-    auto download = makeUnique<Download>(*this, downloadID, nullptr, sessionID);
+    auto* networkSession = m_client.networkSession(sessionID);
+    if (!networkSession)
+        return;
+    auto download = makeUnique<Download>(*this, downloadID, nullptr, *networkSession);
 
     download->resume(resumeData, path, WTFMove(sandboxExtensionHandle));
     ASSERT(!m_downloads.contains(downloadID));
index 37db5e4..8c823cc 100644 (file)
@@ -76,7 +76,6 @@ public:
         virtual NetworkSession* networkSession(PAL::SessionID) const = 0;
         virtual void ref() const = 0;
         virtual void deref() const = 0;
-        virtual uint32_t downloadMonitorSpeedMultiplier() const = 0;
     };
 
     explicit DownloadManager(Client&);
index 36da145..4958b86 100644 (file)
@@ -103,12 +103,12 @@ void DownloadMonitor::applicationDidEnterBackground()
     RELEASE_LOG_IF_ALLOWED("applicationDidEnterBackground (id = %" PRIu64 ")", m_download.downloadID().downloadID());
     ASSERT(!m_timer.isActive());
     ASSERT(!m_interval);
-    m_timer.startOneShot(throughputIntervals[0].time / speedMultiplier());
+    m_timer.startOneShot(throughputIntervals[0].time / testSpeedMultiplier());
 }
 
-uint32_t DownloadMonitor::speedMultiplier() const
+uint32_t DownloadMonitor::testSpeedMultiplier() const
 {
-    return m_download.manager().client().downloadMonitorSpeedMultiplier();
+    return m_download.testSpeedMultiplier();
 }
 
 void DownloadMonitor::timerFired()
@@ -121,7 +121,7 @@ void DownloadMonitor::timerFired()
         m_download.cancel();
     } else if (m_interval + 1 < WTF_ARRAY_LENGTH(throughputIntervals)) {
         RELEASE_LOG_IF_ALLOWED("timerFired: sufficient throughput rate (id = %" PRIu64 ")", m_download.downloadID().downloadID());
-        m_timer.startOneShot(timeUntilNextInterval(m_interval++) / speedMultiplier());
+        m_timer.startOneShot(timeUntilNextInterval(m_interval++) / testSpeedMultiplier());
     } else
         RELEASE_LOG_IF_ALLOWED("timerFired: Download reached threshold to not be terminated (id = %" PRIu64 ")", m_download.downloadID().downloadID());
 }
index bb753a3..39eabe5 100644 (file)
@@ -46,7 +46,7 @@ private:
     Download& m_download;
 
     double measuredThroughputRate() const;
-    uint32_t speedMultiplier() const;
+    uint32_t testSpeedMultiplier() const;
     
     struct Timestamp {
         MonotonicTime time;
index 8a6c5a1..b756b8d 100644 (file)
@@ -467,7 +467,7 @@ void NetworkDataTaskBlob::download()
     }
 
     auto& downloadManager = m_networkProcess->downloadManager();
-    auto download = makeUnique<Download>(downloadManager, m_pendingDownloadID, *this, m_session->sessionID(), suggestedFilename());
+    auto download = makeUnique<Download>(downloadManager, m_pendingDownloadID, *this, *m_session, suggestedFilename());
     auto* downloadPtr = download.get();
     downloadManager.dataTaskBecameDownloadTask(m_pendingDownloadID, WTFMove(download));
     downloadPtr->didCreateDestination(m_pendingDownloadLocation);
index 106d81c..f52f40f 100644 (file)
@@ -362,8 +362,6 @@ void NetworkProcess::initializeNetworkProcess(NetworkProcessCreationParameters&&
     for (auto& scheme : parameters.urlSchemesRegisteredAsCanDisplayOnlyIfCanRequest)
         registerURLSchemeAsCanDisplayOnlyIfCanRequest(scheme);
     
-    m_downloadMonitorSpeedMultiplier = parameters.downloadMonitorSpeedMultiplier;
-
     RELEASE_LOG(Process, "%p - NetworkProcess::initializeNetworkProcess: Presenting process = %d", this, WebCore::presentingApplicationPID());
 }
 
index 9749595..90cf732 100644 (file)
@@ -380,7 +380,6 @@ private:
     IPC::Connection* parentProcessConnectionForDownloads() override { return parentProcessConnection(); }
     AuthenticationManager& downloadsAuthenticationManager() override;
     void pendingDownloadCanceled(DownloadID) override;
-    uint32_t downloadMonitorSpeedMultiplier() const override { return m_downloadMonitorSpeedMultiplier; }
 
     // Message Handlers
     void didReceiveSyncNetworkProcessMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);
@@ -557,7 +556,6 @@ private:
         HashMap<WebCore::ClientOrigin, std::unique_ptr<WebCore::StorageQuotaManager>> m_managersPerOrigin;
     };
     HashMap<PAL::SessionID, StorageQuotaManagers> m_storageQuotaManagers;
-    uint32_t m_downloadMonitorSpeedMultiplier { 1 };
 
     OptionSet<NetworkCache::CacheOption> m_cacheOptions;
     WebCore::MessagePortChannelRegistry m_messagePortChannelRegistry;
index 827a7a3..9d298a3 100644 (file)
@@ -80,7 +80,6 @@ void NetworkProcessCreationParameters::encode(IPC::Encoder& encoder) const
     encoder << serviceWorkerRegistrationDirectory << serviceWorkerRegistrationDirectoryExtensionHandle << urlSchemesServiceWorkersCanHandle << shouldDisableServiceWorkerProcessTerminationDelay;
 #endif
     encoder << shouldEnableITPDatabase;
-    encoder << downloadMonitorSpeedMultiplier;
     encoder << enableAdClickAttributionDebugMode;
     encoder << hstsStorageDirectory;
     encoder << hstsStorageDirectoryExtensionHandle;
@@ -188,12 +187,6 @@ bool NetworkProcessCreationParameters::decode(IPC::Decoder& decoder, NetworkProc
     if (!decoder.decode(result.shouldEnableITPDatabase))
         return false;
 
-    Optional<uint32_t> downloadMonitorSpeedMultiplier;
-    decoder >> downloadMonitorSpeedMultiplier;
-    if (!downloadMonitorSpeedMultiplier)
-        return false;
-    result.downloadMonitorSpeedMultiplier = *downloadMonitorSpeedMultiplier;
-
     if (!decoder.decode(result.enableAdClickAttributionDebugMode))
         return false;
 
index bf794fc..358cfce 100644 (file)
@@ -100,7 +100,6 @@ struct NetworkProcessCreationParameters {
     bool shouldDisableServiceWorkerProcessTerminationDelay { false };
 #endif
     bool shouldEnableITPDatabase { false };
-    uint32_t downloadMonitorSpeedMultiplier { 1 };
     bool enableAdClickAttributionDebugMode { false };
     String hstsStorageDirectory;
     SandboxExtension::Handle hstsStorageDirectoryExtensionHandle;
index c660586..0c9baaf 100644 (file)
@@ -84,6 +84,7 @@ NetworkSession::NetworkSession(NetworkProcess& networkProcess, const NetworkSess
     , m_enableResourceLoadStatisticsLogTestingEvent(parameters.enableResourceLoadStatisticsLogTestingEvent)
 #endif
     , m_adClickAttribution(makeUniqueRef<AdClickAttributionManager>(parameters.sessionID))
+    , m_testSpeedMultiplier(parameters.testSpeedMultiplier)
 {
     if (!m_sessionID.isEphemeral()) {
         String networkCacheDirectory = parameters.networkCacheDirectory;
index b182c69..7ce2dbb 100644 (file)
@@ -122,6 +122,8 @@ public:
 
     WebCore::BlobRegistryImpl& blobRegistry() { return m_blobRegistry; }
 
+    unsigned testSpeedMultiplier() const { return m_testSpeedMultiplier; }
+
 protected:
     NetworkSession(NetworkProcess&, const NetworkSessionCreationParameters&);
 
@@ -153,6 +155,7 @@ protected:
 #endif
     RefPtr<NetworkCache::Cache> m_cache;
     WebCore::BlobRegistryImpl m_blobRegistry;
+    unsigned m_testSpeedMultiplier { 1 };
 };
 
 } // namespace WebKit
index d6ab8ed..2bdbf21 100644 (file)
@@ -78,6 +78,7 @@ void NetworkSessionCreationParameters::encode(IPC::Encoder& encoder) const
     encoder << fastServerTrustEvaluationEnabled;
     encoder << networkCacheSpeculativeValidationEnabled;
     encoder << shouldUseTestingNetworkSession;
+    encoder << testSpeedMultiplier;
 }
 
 Optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters::decode(IPC::Decoder& decoder)
@@ -242,6 +243,11 @@ Optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters::dec
     if (!shouldUseTestingNetworkSession)
         return WTF::nullopt;
     
+    Optional<unsigned> testSpeedMultiplier;
+    decoder >> testSpeedMultiplier;
+    if (!testSpeedMultiplier)
+        return WTF::nullopt;
+    
     return {{
         *sessionID
         , WTFMove(*boundInterfaceIdentifier)
@@ -280,6 +286,7 @@ Optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters::dec
         , WTFMove(*fastServerTrustEvaluationEnabled)
         , WTFMove(*networkCacheSpeculativeValidationEnabled)
         , WTFMove(*shouldUseTestingNetworkSession)
+        , WTFMove(*testSpeedMultiplier)
     }};
 }
 
index b0b583f..2eb8ce8 100644 (file)
@@ -96,6 +96,7 @@ struct NetworkSessionCreationParameters {
     bool fastServerTrustEvaluationEnabled { false };
     bool networkCacheSpeculativeValidationEnabled { false };
     bool shouldUseTestingNetworkSession { false };
+    unsigned testSpeedMultiplier { 1 };
 };
 
 } // namespace WebKit
index b4b1eb9..6d140e6 100644 (file)
@@ -787,7 +787,7 @@ static inline void processServerTrustEvaluation(NetworkSessionCocoa *session, NS
         Ref<NetworkDataTaskCocoa> protectedNetworkDataTask(*networkDataTask);
         auto downloadID = networkDataTask->pendingDownloadID();
         auto& downloadManager = _session->networkProcess().downloadManager();
-        auto download = makeUnique<WebKit::Download>(downloadManager, downloadID, downloadTask, _session->sessionID(), networkDataTask->suggestedFilename());
+        auto download = makeUnique<WebKit::Download>(downloadManager, downloadID, downloadTask, *_session, networkDataTask->suggestedFilename());
         networkDataTask->transferSandboxExtensionToDownload(*download);
         ASSERT(FileSystem::fileExists(networkDataTask->pendingDownloadLocation()));
         download->didCreateDestination(networkDataTask->pendingDownloadLocation());
index df90dff..fcb2605 100644 (file)
@@ -909,7 +909,7 @@ void NetworkDataTaskSoup::download()
     m_downloadOutputStream = adoptGRef(G_OUTPUT_STREAM(outputStream.leakRef()));
 
     auto& downloadManager = m_session->networkProcess().downloadManager();
-    auto download = makeUnique<Download>(downloadManager, m_pendingDownloadID, *this, m_session->sessionID(), suggestedFilename());
+    auto download = makeUnique<Download>(downloadManager, m_pendingDownloadID, *this, *m_session, suggestedFilename());
     auto* downloadPtr = download.get();
     downloadManager.dataTaskBecameDownloadTask(m_pendingDownloadID, WTFMove(download));
     downloadPtr->didCreateDestination(m_pendingDownloadLocation);
index 720c883..e373934 100644 (file)
@@ -59,7 +59,6 @@ Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::copy()
     copy->m_shouldCaptureDisplayInUIProcess = this->m_shouldCaptureDisplayInUIProcess;
     copy->m_shouldConfigureJSCForTesting = this->m_shouldConfigureJSCForTesting;
     copy->m_isJITEnabled = this->m_isJITEnabled;
-    copy->m_downloadMonitorSpeedMultiplier = this->m_downloadMonitorSpeedMultiplier;
 #if PLATFORM(IOS_FAMILY)
     copy->m_ctDataConnectionServiceType = this->m_ctDataConnectionServiceType;
 #endif
index d609bcf..1fa7901 100644 (file)
@@ -54,9 +54,6 @@ public:
     bool usesSingleWebProcess() const { return m_usesSingleWebProcess; }
     void setUsesSingleWebProcess(bool enabled) { m_usesSingleWebProcess = enabled; }
 
-    uint32_t downloadMonitorSpeedMultiplier() const { return m_downloadMonitorSpeedMultiplier; }
-    void setDownloadMonitorSpeedMultiplier(uint32_t multiplier) { m_downloadMonitorSpeedMultiplier = multiplier; }
-    
     bool isAutomaticProcessWarmingEnabled() const
     {
         return m_isAutomaticProcessWarmingEnabledByClient.valueOr(m_clientWouldBenefitFromAutomaticProcessPrewarming);
@@ -178,7 +175,6 @@ private:
     bool m_shouldConfigureJSCForTesting { false };
     bool m_isJITEnabled { true };
     bool m_usesSingleWebProcess { false };
-    uint32_t m_downloadMonitorSpeedMultiplier { 1 };
 
 #if PLATFORM(IOS_FAMILY)
     WTF::String m_ctDataConnectionServiceType;
index 3987e4b..5a9c970 100644 (file)
@@ -70,7 +70,6 @@ WK_CLASS_AVAILABLE(macos(10.10), ios(8.0))
 @property (nonatomic) BOOL pageCacheEnabled WK_API_AVAILABLE(macos(10.14), ios(12.0));
 @property (nonatomic) BOOL suppressesConnectionTerminationOnSystemChange WK_API_AVAILABLE(macos(10.14), ios(12.0));
 @property (nonatomic, getter=isJITEnabled) BOOL JITEnabled WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
-@property (nonatomic) NSUInteger downloadMonitorSpeedMultiplierForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, nullable, copy, setter=setHSTSStorageDirectory:) NSURL *hstsStorageDirectory WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @property (nonatomic) BOOL configureJSCForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
index 245015a..877d52c 100644 (file)
     _processPoolConfiguration->setJITEnabled(enabled);
 }
 
-- (NSUInteger)downloadMonitorSpeedMultiplierForTesting
-{
-    return _processPoolConfiguration->downloadMonitorSpeedMultiplier();
-}
-
 - (void)setHSTSStorageDirectory:(NSURL *)directory
 {
     if (directory && ![directory isFileURL])
     return [NSURL fileURLWithPath:WebKit::LegacyGlobalSettings::singleton().hstsStorageDirectory() isDirectory:YES];
 }
 
-- (void)setDownloadMonitorSpeedMultiplierForTesting:(NSUInteger)multiplier
-{
-    _processPoolConfiguration->setDownloadMonitorSpeedMultiplier(multiplier);
-}
-
 - (void)setSuppressesConnectionTerminationOnSystemChange:(BOOL)suppressesConnectionTerminationOnSystemChange
 {
     _processPoolConfiguration->setSuppressesConnectionTerminationOnSystemChange(suppressesConnectionTerminationOnSystemChange);
index 663a56b..42cf511 100644 (file)
@@ -67,6 +67,7 @@ WK_CLASS_AVAILABLE(macos(10.13), ios(11.0))
 @property (nonatomic, nullable, copy) NSString *applicationCacheFlatFileSubdirectoryName WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, nullable, copy) NSURL *mediaCacheDirectory WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, nullable, copy) NSURL *mediaKeysStorageDirectory WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic) NSUInteger testSpeedMultiplier WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 // Testing only.
 @property (nonatomic) BOOL allLoadsBlockedByDeviceManagementRestrictionsForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
index ea8fb7a..1b87546 100644 (file)
@@ -330,6 +330,16 @@ static void checkURLArgument(NSURL *url)
     _configuration->setPerOriginStorageQuota(quota);
 }
 
+- (NSUInteger)testSpeedMultiplier
+{
+    return _configuration->testSpeedMultiplier();
+}
+
+- (void)setTestSpeedMultiplier:(NSUInteger)quota
+{
+    _configuration->setTestSpeedMultiplier(quota);
+}
+
 - (NSString *)boundInterfaceIdentifier
 {
     return _configuration->boundInterfaceIdentifier();
index e4f7fb1..af9fa3e 100644 (file)
@@ -305,7 +305,6 @@ void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationPara
     parameters.suppressesConnectionTerminationOnSystemChange = m_configuration->suppressesConnectionTerminationOnSystemChange();
 
     parameters.shouldEnableITPDatabase = [defaults boolForKey:[NSString stringWithFormat:@"InternalDebug%@", WebPreferencesKey::isITPDatabaseEnabledKey().createCFString().get()]];
-    parameters.downloadMonitorSpeedMultiplier = m_configuration->downloadMonitorSpeedMultiplier();
 
     parameters.enableAdClickAttributionDebugMode = [defaults boolForKey:[NSString stringWithFormat:@"Experimental%@", WebPreferencesKey::adClickAttributionDebugModeEnabledKey().createCFString().get()]];
 }
index d8688a5..547d946 100644 (file)
@@ -145,7 +145,8 @@ WebsiteDataStoreParameters WebsiteDataStore::parameters()
         m_configuration->dataConnectionServiceType(),
         m_configuration->fastServerTrustEvaluationEnabled(),
         m_configuration->networkCacheSpeculativeValidationEnabled(),
-        m_configuration->testingSessionEnabled()
+        m_configuration->testingSessionEnabled(),
+        m_configuration->testSpeedMultiplier(),
     };
     networkingHasBegun();
 
index d0892ea..2ceccc7 100644 (file)
@@ -84,6 +84,7 @@ Ref<WebsiteDataStoreConfiguration> WebsiteDataStoreConfiguration::copy()
     copy->m_allowsCellularAccess = this->m_allowsCellularAccess;
     copy->m_dataConnectionServiceType = this->m_dataConnectionServiceType;
     copy->m_testingSessionEnabled = this->m_testingSessionEnabled;
+    copy->m_testSpeedMultiplier = this->m_testSpeedMultiplier;
 #if PLATFORM(COCOA)
     if (m_proxyConfiguration)
         copy->m_proxyConfiguration = adoptCF(CFDictionaryCreateCopy(nullptr, this->m_proxyConfiguration.get()));
index e038e66..6c7c1de 100644 (file)
@@ -85,6 +85,9 @@ public:
     bool testingSessionEnabled() const { return m_testingSessionEnabled; }
     void setTestingSessionEnabled(bool enabled) { m_testingSessionEnabled = enabled; }
     
+    unsigned testSpeedMultiplier() const { return m_testSpeedMultiplier; }
+    void setTestSpeedMultiplier(unsigned multiplier) { m_testSpeedMultiplier = multiplier; }
+    
 #if PLATFORM(COCOA)
     CFDictionaryRef proxyConfiguration() const { return m_proxyConfiguration.get(); }
     void setProxyConfiguration(CFDictionaryRef configuration) { m_proxyConfiguration = configuration; }
@@ -171,6 +174,7 @@ private:
     bool m_fastServerTrustEvaluationEnabled { false };
     bool m_serviceWorkerProcessTerminationDelayEnabled { true };
     bool m_testingSessionEnabled { false };
+    unsigned m_testSpeedMultiplier { 1 };
 #if PLATFORM(COCOA)
     RetainPtr<CFDictionaryRef> m_proxyConfiguration;
 #endif
index 5ea2b51..336dd6f 100644 (file)
@@ -1,3 +1,13 @@
+2019-09-30  Alex Christensen  <achristensen@webkit.org>
+
+        Move DownloadMonitor test speed multiplier from WebProcessPool to WebsiteDataStoreConfiguration
+        https://bugs.webkit.org/show_bug.cgi?id=202339
+
+        Reviewed by Youenn Fablet.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
+        (TestWebKitAPI::webViewWithDownloadMonitorSpeedMultiplier):
+
 2019-09-30  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] IconDatabase is not thread-safe
index 88ed5d6..6bca1ae 100644 (file)
 #import <WebKit/WKUIDelegatePrivate.h>
 #import <WebKit/WKWebView.h>
 #import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/_WKDownload.h>
 #import <WebKit/_WKDownloadDelegate.h>
 #import <WebKit/_WKProcessPoolConfiguration.h>
+#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
 #import <wtf/FileSystem.h>
 #import <wtf/MainThread.h>
 #import <wtf/MonotonicTime.h>
@@ -849,10 +851,11 @@ RetainPtr<WKWebView> webViewWithDownloadMonitorSpeedMultiplier(size_t multiplier
     static auto navigationDelegate = adoptNS([DownloadNavigationDelegate new]);
     static auto downloadDelegate = adoptNS([DownloadMonitorTestDelegate new]);
     auto processPoolConfiguration = adoptNS([_WKProcessPoolConfiguration new]);
-    [processPoolConfiguration setDownloadMonitorSpeedMultiplierForTesting:multiplier];
     auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+    _WKWebsiteDataStoreConfiguration *dataStoreConfiguration = [[_WKWebsiteDataStoreConfiguration new] autorelease];
+    dataStoreConfiguration.testSpeedMultiplier = multiplier;
     auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
-    [webViewConfiguration setProcessPool:processPool.get()];
+    [webViewConfiguration setWebsiteDataStore:[[[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration] autorelease]];
     auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     [webView setNavigationDelegate:navigationDelegate.get()];
     [webView configuration].processPool._downloadDelegate = downloadDelegate.get();