Changeset 247567 in webkit
- Timestamp:
- Jul 18, 2019 11:41:31 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r247565 r247567 1 2019-07-18 Alex Christensen <achristensen@webkit.org> 2 3 Move NetworkCache ownership from NetworkProcess to NetworkSession 4 https://bugs.webkit.org/show_bug.cgi?id=199817 5 6 Reviewed by Geoff Garen. 7 8 I also added SPI to set the path of the NetworkCache with an API test. 9 If this new SPI is not used, it falls back to getting the cache location from the NetworkProcess to maintain compatibility. 10 We still get options, cache size, and cache model from the NetworkProcess. Those should be migrated with new SPI later. 11 Clearing the cache and other operations now iterate the NetworkSessions instead of assuming there is only one cache. 12 13 * NetworkProcess/NetworkProcess.cpp: 14 (WebKit::NetworkProcess::fetchWebsiteData): 15 (WebKit::NetworkProcess::deleteWebsiteDataForOrigins): 16 (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomains): 17 (WebKit::NetworkProcess::registrableDomainsWithWebsiteData): 18 (WebKit::NetworkProcess::setCacheModel): 19 * NetworkProcess/NetworkProcess.h: 20 (WebKit::NetworkProcess::diskCacheDirectory const): 21 (WebKit::NetworkProcess::cacheOptions const): 22 (WebKit::NetworkProcess::cache): Deleted. 23 * NetworkProcess/NetworkResourceLoader.cpp: 24 (WebKit::m_shouldCaptureExtraNetworkLoadMetrics): 25 * NetworkProcess/NetworkSession.cpp: 26 (WebKit::NetworkSession::NetworkSession): 27 * NetworkProcess/NetworkSession.h: 28 (WebKit::NetworkSession::cache): 29 * NetworkProcess/NetworkSessionCreationParameters.cpp: 30 (WebKit::NetworkSessionCreationParameters::encode const): 31 (WebKit::NetworkSessionCreationParameters::decode): 32 * NetworkProcess/NetworkSessionCreationParameters.h: 33 * NetworkProcess/cache/NetworkCache.cpp: 34 (WebKit::NetworkCache::Cache::open): 35 (WebKit::NetworkCache::Cache::Cache): 36 * NetworkProcess/cache/NetworkCache.h: 37 * NetworkProcess/cocoa/NetworkProcessCocoa.mm: 38 (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa): 39 (WebKit::NetworkProcess::clearDiskCache): 40 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 41 (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): 42 * NetworkProcess/curl/NetworkSessionCurl.cpp: 43 (WebKit::NetworkSessionCurl::NetworkSessionCurl): 44 * NetworkProcess/soup/NetworkSessionSoup.cpp: 45 (WebKit::NetworkSessionSoup::NetworkSessionSoup): 46 * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: 47 (-[WKWebsiteDataStore _initWithConfiguration:]): 48 * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h: 49 * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm: 50 (-[_WKWebsiteDataStoreConfiguration networkCacheDirectory]): 51 (-[_WKWebsiteDataStoreConfiguration setNetworkCacheDirectory:]): 52 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 53 (WebKit::WebsiteDataStore::parameters): 54 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 55 (WebKit::WebsiteDataStore::resolveDirectoriesIfNecessary): 56 * UIProcess/WebsiteData/WebsiteDataStore.h: 57 (WebKit::WebsiteDataStore::resolvedNetworkCacheDirectory const): 58 1 59 2019-07-18 Chris Dumez <cdumez@apple.com> 2 60 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r247283 r247567 1358 1358 } 1359 1359 #endif 1360 1361 1360 if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { 1362 fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [callbackAggregator = WTFMove(callbackAggregator)](auto entries) mutable { 1363 callbackAggregator->m_websiteData.entries.appendVector(entries); 1364 }); 1361 for (auto& session : networkSessions().values()) { 1362 fetchDiskCacheEntries(session->cache(), sessionID, fetchOptions, [callbackAggregator = WTFMove(callbackAggregator)](auto entries) mutable { 1363 callbackAggregator->m_websiteData.entries.appendVector(entries); 1364 }); 1365 } 1365 1366 } 1366 1367 } … … 1517 1518 #endif 1518 1519 1519 if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral()) 1520 clearDiskCacheEntries(cache(), originDatas, [clearTasksHandler = WTFMove(clearTasksHandler)] { }); 1520 if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral()) { 1521 for (auto& session : networkSessions().values()) 1522 clearDiskCacheEntries(session->cache(), originDatas, [clearTasksHandler = WTFMove(clearTasksHandler)] { }); 1523 } 1521 1524 1522 1525 if (websiteDataTypes.contains(WebsiteDataType::Credentials)) { … … 1749 1752 } 1750 1753 #endif 1751 1754 1752 1755 if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { 1753 fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [this, domainsToDeleteAllButCookiesFor, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1754 1755 Vector<SecurityOriginData> entriesToDelete; 1756 for (auto& entry : entries) { 1757 if (!domainsToDeleteAllButCookiesFor.contains(RegistrableDomain::uncheckedCreateFromHost(entry.origin.host))) 1758 continue; 1759 entriesToDelete.append(entry.origin); 1760 callbackAggregator->m_domains.add(RegistrableDomain::uncheckedCreateFromHost(entry.origin.host)); 1761 } 1762 clearDiskCacheEntries(cache(), entriesToDelete, [callbackAggregator = callbackAggregator.copyRef()] { }); 1763 }); 1756 for (auto& session : networkSessions().values()) { 1757 fetchDiskCacheEntries(session->cache(), sessionID, fetchOptions, [domainsToDeleteAllButCookiesFor, callbackAggregator = callbackAggregator.copyRef(), session = session.copyRef()](auto entries) mutable { 1758 1759 Vector<SecurityOriginData> entriesToDelete; 1760 for (auto& entry : entries) { 1761 if (!domainsToDeleteAllButCookiesFor.contains(RegistrableDomain::uncheckedCreateFromHost(entry.origin.host))) 1762 continue; 1763 entriesToDelete.append(entry.origin); 1764 callbackAggregator->m_domains.add(RegistrableDomain::uncheckedCreateFromHost(entry.origin.host)); 1765 } 1766 clearDiskCacheEntries(session->cache(), entriesToDelete, [callbackAggregator = callbackAggregator.copyRef()] { }); 1767 }); 1768 } 1764 1769 } 1765 1770 … … 1883 1888 1884 1889 if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { 1885 fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1886 callbackAggregator->m_websiteData.entries.appendVector(entries); 1887 }); 1890 for (auto& session : networkSessions().values()) { 1891 fetchDiskCacheEntries(session->cache(), sessionID, fetchOptions, [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1892 callbackAggregator->m_websiteData.entries.appendVector(entries); 1893 }); 1894 } 1888 1895 } 1889 1896 } … … 1977 1984 calculateURLCacheSizes(cacheModel, diskFreeSize, urlCacheMemoryCapacity, urlCacheDiskCapacity); 1978 1985 } 1979 1980 if (m_cache) 1981 m_cache->setCapacity(urlCacheDiskCapacity); 1986 1987 for (auto& session : networkSessions().values()) { 1988 if (auto* cache = session->cache()) 1989 cache->setCapacity(urlCacheDiskCapacity); 1990 } 1982 1991 } 1983 1992 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r247270 r247567 112 112 #endif 113 113 114 namespace NetworkCache { 115 enum class CacheOption : uint8_t; 116 } 117 114 118 namespace CacheStorage { 115 119 class Engine; 116 }117 118 namespace NetworkCache {119 class Cache;120 120 } 121 121 … … 161 161 AuthenticationManager& authenticationManager(); 162 162 DownloadManager& downloadManager(); 163 164 NetworkCache::Cache* cache() { return m_cache.get(); }165 163 166 164 void setSession(const PAL::SessionID&, Ref<NetworkSession>&&); … … 344 342 void removeKeptAliveLoad(NetworkResourceLoader&); 345 343 344 const String& diskCacheDirectory() const { return m_diskCacheDirectory; } 345 const OptionSet<NetworkCache::CacheOption>& cacheOptions() const { return m_cacheOptions; } 346 346 347 private: 347 348 void platformInitializeNetworkProcess(const NetworkProcessCreationParameters&); … … 490 491 HashMap<PAL::SessionID, Ref<CacheStorage::Engine>> m_cacheEngines; 491 492 492 RefPtr<NetworkCache::Cache> m_cache;493 494 493 typedef HashMap<const char*, std::unique_ptr<NetworkProcessSupplement>, PtrHash<const char*>> NetworkProcessSupplementMap; 495 494 NetworkProcessSupplementMap m_supplements; … … 567 566 568 567 HashMap<IPC::Connection::UniqueID, PAL::SessionID> m_sessionByConnection; 568 569 OptionSet<NetworkCache::CacheOption> m_cacheOptions; 569 570 }; 570 571 -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
r247072 r247567 99 99 , m_isAllowedToAskUserForCredentials { m_parameters.clientCredentialPolicy == ClientCredentialPolicy::MayAskClientForCredentials } 100 100 , m_bufferingTimer { *this, &NetworkResourceLoader::bufferingTimerFired } 101 , m_cache { sessionID().isEphemeral() ? nullptr : connection.networkProcess().cache() }102 101 , m_shouldCaptureExtraNetworkLoadMetrics(m_connection->captureExtraNetworkLoadMetricsEnabled()) 103 102 { 104 103 ASSERT(RunLoop::isMain()); 104 105 if (auto* session = connection.networkProcess().networkSession(sessionID())) 106 m_cache = session->cache(); 107 105 108 // FIXME: This is necessary because of the existence of EmptyFrameLoaderClient in WebCore. 106 109 // Once bug 116233 is resolved, this ASSERT can just be "m_webPageID && m_webFrameID" -
trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp
r247370 r247567 28 28 29 29 #include "AdClickAttributionManager.h" 30 #include "Logging.h" 30 31 #include "NetworkProcess.h" 31 32 #include "NetworkProcessProxyMessages.h" … … 78 79 } 79 80 80 NetworkSession::NetworkSession(NetworkProcess& networkProcess, PAL::SessionID sessionID, String&& localStorageDirectory, SandboxExtension::Handle& handle)81 : m_sessionID( sessionID)81 NetworkSession::NetworkSession(NetworkProcess& networkProcess, const NetworkSessionCreationParameters& parameters) 82 : m_sessionID(parameters.sessionID) 82 83 , m_networkProcess(networkProcess) 83 , m_adClickAttribution(makeUniqueRef<AdClickAttributionManager>(sessionID)) 84 , m_storageManager(StorageManager::create(WTFMove(localStorageDirectory))) 85 { 86 SandboxExtension::consumePermanently(handle); 84 , m_adClickAttribution(makeUniqueRef<AdClickAttributionManager>(parameters.sessionID)) 85 , m_storageManager(StorageManager::create(String(parameters.localStorageDirectory))) 86 { 87 if (!m_sessionID.isEphemeral()) { 88 String networkCacheDirectory = parameters.networkCacheDirectory; 89 if (networkCacheDirectory.isNull()) 90 networkCacheDirectory = networkProcess.diskCacheDirectory(); 91 else 92 SandboxExtension::consumePermanently(parameters.networkCacheDirectoryExtensionHandle); 93 94 m_cache = NetworkCache::Cache::open(networkProcess, networkCacheDirectory, networkProcess.cacheOptions()); 95 if (!m_cache) 96 RELEASE_LOG_ERROR(NetworkCache, "Failed to initialize the WebKit network disk cache"); 97 } 98 99 SandboxExtension::consumePermanently(parameters.localStorageDirectoryExtensionHandle); 87 100 m_adClickAttribution->setPingLoadFunction([this, weakThis = makeWeakPtr(this)](NetworkResourceLoadParameters&& loadParameters, CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&)>&& completionHandler) { 88 101 if (!weakThis) -
trunk/Source/WebKit/NetworkProcess/NetworkSession.h
r247250 r247567 60 60 61 61 enum class WebsiteDataType; 62 62 63 namespace NetworkCache { 64 class Cache; 65 } 66 63 67 class NetworkSession : public RefCounted<NetworkSession>, public CanMakeWeakPtr<NetworkSession> { 64 68 public: … … 101 105 void removeKeptAliveLoad(NetworkResourceLoader&); 102 106 107 NetworkCache::Cache* cache() { return m_cache.get(); } 108 103 109 PrefetchCache& prefetchCache() { return m_prefetchCache; } 104 110 void clearPrefetchCache() { m_prefetchCache.clear(); } … … 109 115 110 116 protected: 111 NetworkSession(NetworkProcess&, PAL::SessionID, String&& localStorageDirectory, SandboxExtension::Handle&);117 NetworkSession(NetworkProcess&, const NetworkSessionCreationParameters&); 112 118 113 119 PAL::SessionID m_sessionID; … … 131 137 bool m_isInvalidated { false }; 132 138 #endif 139 RefPtr<NetworkCache::Cache> m_cache; 133 140 }; 134 141 -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp
r245979 r247567 51 51 , { }, { } 52 52 #endif 53 , { }, { }, false, { }, { }, { }, { }, { }, { }, { } 53 , { }, { }, false, { }, { }, { }, { }, { }, { }, { }, { }, { } 54 54 }; 55 55 } … … 86 86 87 87 encoder << localStorageDirectory << localStorageDirectoryExtensionHandle; 88 encoder << networkCacheDirectory << networkCacheDirectoryExtensionHandle; 88 89 89 90 encoder << deviceManagementRestrictionsEnabled; … … 210 211 decoder >> localStorageDirectoryExtensionHandle; 211 212 if (!localStorageDirectoryExtensionHandle) 213 return WTF::nullopt; 214 215 Optional<String> networkCacheDirectory; 216 decoder >> networkCacheDirectory; 217 if (!networkCacheDirectory) 218 return WTF::nullopt; 219 220 Optional<SandboxExtension::Handle> networkCacheDirectoryExtensionHandle; 221 decoder >> networkCacheDirectoryExtensionHandle; 222 if (!networkCacheDirectoryExtensionHandle) 212 223 return WTF::nullopt; 213 224 … … 254 265 , WTFMove(*localStorageDirectory) 255 266 , WTFMove(*localStorageDirectoryExtensionHandle) 267 , WTFMove(*networkCacheDirectory) 268 , WTFMove(*networkCacheDirectoryExtensionHandle) 256 269 }}; 257 270 } -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h
r245979 r247567 93 93 String localStorageDirectory; 94 94 SandboxExtension::Handle localStorageDirectoryExtensionHandle; 95 String networkCacheDirectory; 96 SandboxExtension::Handle networkCacheDirectoryExtensionHandle; 95 97 }; 96 98 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
r247362 r247567 60 60 } 61 61 62 RefPtr<Cache> Cache::open(NetworkProcess& networkProcess, const String& cachePath, OptionSet< Option> options)63 { 64 auto storage = Storage::open(cachePath, options.contains( Option::TestingMode) ? Storage::Mode::AvoidRandomness : Storage::Mode::Normal);62 RefPtr<Cache> Cache::open(NetworkProcess& networkProcess, const String& cachePath, OptionSet<CacheOption> options) 63 { 64 auto storage = Storage::open(cachePath, options.contains(CacheOption::TestingMode) ? Storage::Mode::AvoidRandomness : Storage::Mode::Normal); 65 65 66 66 LOG(NetworkCache, "(NetworkProcess) opened cache storage, success %d", !!storage); … … 79 79 #endif 80 80 81 Cache::Cache(NetworkProcess& networkProcess, Ref<Storage>&& storage, OptionSet< Option> options)81 Cache::Cache(NetworkProcess& networkProcess, Ref<Storage>&& storage, OptionSet<CacheOption> options) 82 82 : m_storage(WTFMove(storage)) 83 83 , m_networkProcess(networkProcess) 84 84 { 85 85 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 86 if (options.contains( Option::SpeculativeRevalidation)) {86 if (options.contains(CacheOption::SpeculativeRevalidation)) { 87 87 m_lowPowerModeNotifier = std::make_unique<WebCore::LowPowerModeNotifier>([this](bool isLowPowerModeEnabled) { 88 88 ASSERT(WTF::RunLoop::isMain()); … … 99 99 #endif 100 100 101 if (options.contains( Option::RegisterNotify)) {101 if (options.contains(CacheOption::RegisterNotify)) { 102 102 #if PLATFORM(COCOA) 103 103 // Triggers with "notifyutil -p com.apple.WebKit.Cache.dump". -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h
r245796 r247567 88 88 using GlobalFrameID = std::pair<WebCore::PageIdentifier, uint64_t /*webFrameID*/>; 89 89 90 enum class CacheOption : uint8_t { 91 // In testing mode we try to eliminate sources of randomness. Cache does not shrink and there are no read timeouts. 92 TestingMode = 1 << 0, 93 RegisterNotify = 1 << 1, 94 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 95 SpeculativeRevalidation = 1 << 2, 96 #endif 97 }; 98 90 99 class Cache : public RefCounted<Cache> { 91 100 public: 92 enum class Option { 93 // In testing mode we try to eliminate sources of randomness. Cache does not shrink and there are no read timeouts. 94 TestingMode = 1 << 0, 95 RegisterNotify = 1 << 1, 96 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 97 SpeculativeRevalidation = 1 << 2, 98 #endif 99 }; 100 static RefPtr<Cache> open(NetworkProcess&, const String& cachePath, OptionSet<Option>); 101 static RefPtr<Cache> open(NetworkProcess&, const String& cachePath, OptionSet<CacheOption>); 101 102 102 103 void setCapacity(size_t); … … 149 150 150 151 private: 151 Cache(NetworkProcess&, Ref<Storage>&&, OptionSet< Option> options);152 Cache(NetworkProcess&, Ref<Storage>&&, OptionSet<CacheOption>); 152 153 153 154 Key makeCacheKey(const WebCore::ResourceRequest&); -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
r247270 r247567 118 118 119 119 SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle); 120 OptionSet<NetworkCache::Cache::Option> cacheOptions { NetworkCache::Cache::Option::RegisterNotify };120 m_cacheOptions = { NetworkCache::CacheOption::RegisterNotify }; 121 121 if (parameters.shouldUseTestingNetworkSession) 122 cacheOptions.add(NetworkCache::Cache::Option::TestingMode);122 m_cacheOptions.add(NetworkCache::CacheOption::TestingMode); 123 123 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 124 124 if (parameters.shouldEnableNetworkCacheSpeculativeRevalidation) 125 cacheOptions.add(NetworkCache::Cache::Option::SpeculativeRevalidation); 126 #endif 127 128 m_cache = NetworkCache::Cache::open(*this, m_diskCacheDirectory, cacheOptions); 129 if (!m_cache) 130 RELEASE_LOG_ERROR(NetworkCache, "Failed to initialize the WebKit network disk cache"); 125 m_cacheOptions.add(NetworkCache::CacheOption::SpeculativeRevalidation); 126 #endif 131 127 132 128 // Disable NSURLCache. … … 201 197 m_clearCacheDispatchGroup = dispatch_group_create(); 202 198 203 auto* cache = this->cache();204 if (!cache) {205 completionHandler();206 return;207 }208 209 199 auto group = m_clearCacheDispatchGroup; 210 dispatch_group_async(group, dispatch_get_main_queue(), makeBlockPtr([cache, modifiedSince, completionHandler = WTFMove(completionHandler)] () mutable { 211 cache->clear(modifiedSince, WTFMove(completionHandler)); 200 dispatch_group_async(group, dispatch_get_main_queue(), makeBlockPtr([this, protectedThis = makeRef(*this), modifiedSince, completionHandler = WTFMove(completionHandler)] () mutable { 201 auto aggregator = CallbackAggregator::create(WTFMove(completionHandler)); 202 for (auto& session : networkSessions().values()) { 203 if (auto* cache = session->cache()) 204 cache->clear(modifiedSince, [aggregator = aggregator.copyRef()] () { }); 205 } 212 206 }).get()); 213 207 } -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r247250 r247567 925 925 926 926 NetworkSessionCocoa::NetworkSessionCocoa(NetworkProcess& networkProcess, NetworkSessionCreationParameters&& parameters) 927 : NetworkSession(networkProcess, parameters .sessionID, WTFMove(parameters.localStorageDirectory), parameters.localStorageDirectoryExtensionHandle)927 : NetworkSession(networkProcess, parameters) 928 928 , m_boundInterfaceIdentifier(parameters.boundInterfaceIdentifier) 929 929 , m_sourceApplicationBundleIdentifier(parameters.sourceApplicationBundleIdentifier) -
trunk/Source/WebKit/NetworkProcess/curl/NetworkSessionCurl.cpp
r247250 r247567 39 39 40 40 NetworkSessionCurl::NetworkSessionCurl(NetworkProcess& networkProcess, NetworkSessionCreationParameters&& parameters) 41 : NetworkSession(networkProcess, parameters .sessionID, WTFMove(parameters.localStorageDirectory), parameters.localStorageDirectoryExtensionHandle)41 : NetworkSession(networkProcess, parameters) 42 42 { 43 43 if (!parameters.cookiePersistentStorageFile.isEmpty()) -
trunk/Source/WebKit/NetworkProcess/ios/NetworkProcessIOS.mm
r246892 r247567 79 79 if (resourceCachesToClear == InMemoryResourceCachesOnly) 80 80 return; 81 if (m_cache) 82 m_cache->clear(); 81 for (auto& session : networkSessions().values()) { 82 if (auto* cache = session->cache()) 83 cache->clear(); 84 } 83 85 } 84 86 -
trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp
r246671 r247567 30 30 #include "NetworkCache.h" 31 31 #include "NetworkProcessCreationParameters.h" 32 #include "NetworkSession.h" 32 33 #include "ResourceCachesToClear.h" 33 34 #include "WebCookieManager.h" … … 39 40 #include <WebCore/SoupNetworkSession.h> 40 41 #include <libsoup/soup.h> 42 #include <wtf/CallbackAggregator.h> 41 43 #include <wtf/FileSystem.h> 42 44 #include <wtf/RAMSize.h> … … 116 118 SoupNetworkSession::clearOldSoupCache(FileSystem::directoryName(m_diskCacheDirectory)); 117 119 118 OptionSet<NetworkCache::Cache ::Option> cacheOptions { NetworkCache::Cache::Option::RegisterNotify };120 OptionSet<NetworkCache::CacheOption> cacheOptions { NetworkCache::CacheOption::RegisterNotify }; 119 121 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 120 122 if (parameters.shouldEnableNetworkCacheSpeculativeRevalidation) 121 cacheOptions.add(NetworkCache::Cache ::Option::SpeculativeRevalidation);123 cacheOptions.add(NetworkCache::CacheOption::SpeculativeRevalidation); 122 124 #endif 123 124 m_cache = NetworkCache::Cache::open(*this, m_diskCacheDirectory, cacheOptions);125 125 126 126 supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(parameters.cookieAcceptPolicy, OptionalCallbackID()); … … 157 157 void NetworkProcess::clearDiskCache(WallTime modifiedSince, CompletionHandler<void()>&& completionHandler) 158 158 { 159 if (!m_cache) { 160 completionHandler(); 161 return; 159 auto aggregator = CallbackAggregator::create(WTFMove(completionHandler)); 160 for (auto& session : networkSessions().values()) { 161 if (auto* cache = session->cache()) 162 cache->clear(modifiedSince, [aggregator = aggregator.copyRef()] () { }); 162 163 } 163 m_cache->clear(modifiedSince, WTFMove(completionHandler));164 164 } 165 165 -
trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp
r247250 r247567 41 41 42 42 NetworkSessionSoup::NetworkSessionSoup(NetworkProcess& networkProcess, NetworkSessionCreationParameters&& parameters) 43 : NetworkSession(networkProcess, parameters .sessionID, WTFMove(parameters.localStorageDirectory), parameters.localStorageDirectoryExtensionHandle)43 : NetworkSession(networkProcess, parameters) 44 44 { 45 45 networkStorageSession()->setCookieObserverHandler([this] { -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r246500 r247567 249 249 if (configuration._serviceWorkerRegistrationDirectory) 250 250 config->setServiceWorkerRegistrationDirectory(configuration._serviceWorkerRegistrationDirectory.path); 251 if (configuration.networkCacheDirectory) 252 config->setNetworkCacheDirectory(configuration.networkCacheDirectory.path); 251 253 } else { 252 254 RELEASE_ASSERT(!configuration._webStorageDirectory); … … 257 259 RELEASE_ASSERT(!configuration._cacheStorageDirectory); 258 260 RELEASE_ASSERT(!configuration._serviceWorkerRegistrationDirectory); 261 RELEASE_ASSERT(!configuration.networkCacheDirectory); 259 262 } 260 263 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h
r245979 r247567 54 54 @property (nonatomic, copy, setter=_setCacheStorageDirectory:) NSURL *_cacheStorageDirectory WK_API_AVAILABLE(macos(10.13.4), ios(11.3)); 55 55 @property (nonatomic, copy, setter=_setServiceWorkerRegistrationDirectory:) NSURL *_serviceWorkerRegistrationDirectory WK_API_AVAILABLE(macos(10.13.4), ios(11.3)); 56 @property (nonatomic, nullable, copy) NSURL *networkCacheDirectory WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 56 57 57 58 // Testing only. -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm
r247476 r247567 90 90 } 91 91 92 - (NSURL *)networkCacheDirectory 93 { 94 return [NSURL fileURLWithPath:_configuration->networkCacheDirectory() isDirectory:YES]; 95 } 96 97 - (void)setNetworkCacheDirectory:(NSURL *)url 98 { 99 if (!_configuration->isPersistent()) 100 [NSException raise:NSInvalidArgumentException format:@"Cannot set networkCacheDirectory on a non-persistent _WKWebsiteDataStoreConfiguration."]; 101 checkURLArgument(url); 102 _configuration->setNetworkCacheDirectory(url.path); 103 } 104 92 105 - (NSURL *)_webSQLDatabaseDirectory 93 106 { -
trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
r245979 r247567 113 113 SandboxExtension::createHandleForReadWriteDirectory(localStorageDirectory, localStorageDirectoryExtensionHandle); 114 114 115 auto networkCacheDirectory = resolvedNetworkCacheDirectory(); 116 SandboxExtension::Handle networkCacheDirectoryExtensionHandle; 117 if (!networkCacheDirectory.isEmpty()) 118 SandboxExtension::createHandleForReadWriteDirectory(networkCacheDirectory, networkCacheDirectoryExtensionHandle); 119 115 120 bool shouldIncludeLocalhostInResourceLoadStatistics = isSafari; 116 121 WebsiteDataStoreParameters parameters; … … 136 141 WTFMove(resourceLoadStatisticsManualPrevalentResource), 137 142 WTFMove(localStorageDirectory), 138 WTFMove(localStorageDirectoryExtensionHandle) 143 WTFMove(localStorageDirectoryExtensionHandle), 144 WTFMove(networkCacheDirectory), 145 WTFMove(networkCacheDirectoryExtensionHandle), 139 146 }; 140 147 networkingHasBegun(); -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r247270 r247567 207 207 if (!m_configuration->deviceIdHashSaltsStorageDirectory().isEmpty()) 208 208 m_resolvedConfiguration->setDeviceIdHashSaltsStorageDirectory(resolveAndCreateReadWriteDirectoryForSandboxExtension(m_configuration->deviceIdHashSaltsStorageDirectory())); 209 if (!m_configuration->networkCacheDirectory().isEmpty()) 210 m_resolvedConfiguration->setNetworkCacheDirectory(resolveAndCreateReadWriteDirectoryForSandboxExtension(m_configuration->networkCacheDirectory())); 209 211 if (!m_configuration->resourceLoadStatisticsDirectory().isEmpty()) 210 212 m_resolvedConfiguration->setResourceLoadStatisticsDirectory(resolveAndCreateReadWriteDirectoryForSandboxExtension(m_configuration->resourceLoadStatisticsDirectory())); -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r247146 r247567 185 185 const String& resolvedApplicationCacheDirectory() const { return m_resolvedConfiguration->applicationCacheDirectory(); } 186 186 const String& resolvedLocalStorageDirectory() const { return m_resolvedConfiguration->localStorageDirectory(); } 187 const String& resolvedNetworkCacheDirectory() const { return m_resolvedConfiguration->networkCacheDirectory(); } 187 188 const String& resolvedMediaCacheDirectory() const { return m_resolvedConfiguration->mediaCacheDirectory(); } 188 189 const String& resolvedMediaKeysDirectory() const { return m_resolvedConfiguration->mediaKeysStorageDirectory(); } -
trunk/Tools/ChangeLog
r247566 r247567 1 2019-07-18 Alex Christensen <achristensen@webkit.org> 2 3 Move NetworkCache ownership from NetworkProcess to NetworkSession 4 https://bugs.webkit.org/show_bug.cgi?id=199817 5 6 Reviewed by Geoff Garen. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm: 9 (TEST): 10 * TestWebKitAPI/cocoa/TestWKWebView.h: 11 * TestWebKitAPI/cocoa/TestWKWebView.mm: 12 (-[WKWebView synchronouslyLoadRequest:]): 13 1 14 2019-07-18 Youenn Fablet <youenn@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm
r245979 r247567 27 27 28 28 #import "PlatformUtilities.h" 29 #import "TCPServer.h" 29 30 #import "Test.h" 30 31 #import "TestNavigationDelegate.h" … … 522 523 EXPECT_TRUE([[websiteDataStoreConfiguration sourceApplicationBundleIdentifier] isEqualToString:@"testidentifier"]); 523 524 } 525 526 TEST(WebKit, NetworkCacheDirectory) 527 { 528 using namespace TestWebKitAPI; 529 TCPServer server([] (int socket) { 530 TCPServer::read(socket); 531 const char* response = 532 "HTTP/1.1 200 OK\r\n" 533 "Cache-Control: max-age=1000000\r\n" 534 "Content-Length: 6\r\n\r\n" 535 "Hello!"; 536 TCPServer::write(socket, response, strlen(response)); 537 }); 538 539 NSURL *tempDir = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"CustomPathsTest"] isDirectory:YES]; 540 541 auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]); 542 [websiteDataStoreConfiguration setNetworkCacheDirectory:tempDir]; 543 544 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 545 [webViewConfiguration setWebsiteDataStore:[[[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()] autorelease]]; 546 547 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); 548 [webView synchronouslyLoadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", server.port()]]]]; 549 NSString *path = tempDir.path; 550 NSFileManager *fileManager = [NSFileManager defaultManager]; 551 while (![fileManager fileExistsAtPath:path]) 552 Util::spinRunLoop(); 553 NSError *error = nil; 554 [fileManager removeItemAtPath:path error:&error]; 555 EXPECT_FALSE(error); 556 } -
trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h
r246924 r247567 53 53 - (void)synchronouslyLoadHTMLString:(NSString *)html; 54 54 - (void)synchronouslyLoadHTMLString:(NSString *)html baseURL:(NSURL *)url; 55 - (void)synchronouslyLoadRequest:(NSURLRequest *)request; 55 56 - (void)synchronouslyLoadTestPageNamed:(NSString *)pageName; 56 57 - (BOOL)_synchronouslyExecuteEditCommand:(NSString *)command argument:(NSString *)argument; -
trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm
r246198 r247567 72 72 } 73 73 74 - (void)synchronouslyLoadRequest:(NSURLRequest *)request 75 { 76 [self loadRequest:request]; 77 [self _test_waitForDidFinishNavigation]; 78 } 79 74 80 - (void)synchronouslyLoadHTMLString:(NSString *)html baseURL:(NSURL *)url 75 81 {
Note: See TracChangeset
for help on using the changeset viewer.