Changeset 220267 in webkit
- Timestamp:
- Aug 4, 2017 6:25:02 AM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r220261 r220267 1 2017-08-04 Antti Koivisto <antti@apple.com> 2 3 Network cache should be usable as non-singleton 4 https://bugs.webkit.org/show_bug.cgi?id=175139 5 6 Reviewed by Sam Weinig. 7 8 We might want to use it as a non-singleton in the future (for example as a backend for the cache API). 9 10 This patch makes NetworkCache::Cache and NetworkCache::Storage refcounted objects and takes 11 care to ref them properly during asynchronous operations. 12 13 The patch doesn't actually create any non-shared instances, it just adds the capability. 14 15 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 16 (WebKit::NetworkConnectionToWebProcess::storeDerivedDataToCache): 17 * NetworkProcess/NetworkProcess.cpp: 18 (WebKit::fetchDiskCacheEntries): 19 (WebKit::clearDiskCacheEntries): 20 (WebKit::NetworkProcess::setCacheModel): 21 * NetworkProcess/NetworkProcess.h: 22 (WebKit::NetworkProcess::cache): 23 24 Move the shared cache instance to the network process singleton. 25 26 * NetworkProcess/NetworkResourceLoader.cpp: 27 (WebKit::NetworkResourceLoader::NetworkResourceLoader): 28 29 Include shared cache as a reffed member for non-ephemeral instances. 30 31 (WebKit::NetworkResourceLoader::canUseCache const): 32 (WebKit::NetworkResourceLoader::retrieveCacheEntry): 33 (WebKit::NetworkResourceLoader::abort): 34 (WebKit::NetworkResourceLoader::didReceiveResponse): 35 (WebKit::NetworkResourceLoader::willSendRedirectedRequest): 36 (WebKit::NetworkResourceLoader::tryStoreAsCacheEntry): 37 (WebKit::NetworkResourceLoader::didRetrieveCacheEntry): 38 * NetworkProcess/NetworkResourceLoader.h: 39 * NetworkProcess/cache/NetworkCache.cpp: 40 (WebKit::NetworkCache::Cache::open): 41 42 Open now returns null if it fails. 43 Add RegisterNotify option to set up notify trigger for the shared instance. 44 45 (WebKit::NetworkCache::Cache::Cache): 46 (WebKit::NetworkCache::Cache::~Cache): 47 48 Add destructor. 49 50 (WebKit::NetworkCache::dumpFileChanged): 51 (WebKit::NetworkCache::Cache::setCapacity): 52 (WebKit::NetworkCache::Cache::retrieve): 53 54 Protect the cache instance during asynchronous operations. 55 56 (WebKit::NetworkCache::Cache::store): 57 (WebKit::NetworkCache::Cache::storeRedirect): 58 (WebKit::NetworkCache::Cache::remove): 59 (WebKit::NetworkCache::Cache::traverse): 60 (WebKit::NetworkCache::Cache::dumpContentsToFile): 61 (WebKit::NetworkCache::Cache::clear): 62 (WebKit::NetworkCache::Cache::recordsPath const): 63 (WebKit::NetworkCache::Cache::retrieveData): 64 (WebKit::NetworkCache::Cache::storeData): 65 (WebKit::NetworkCache::singleton): Deleted. 66 (WebKit::NetworkCache::Cache::initialize): Deleted. 67 * NetworkProcess/cache/NetworkCache.h: 68 (WebKit::NetworkCache::Cache::canUseSharedMemoryForBodyData const): 69 (WebKit::NetworkCache::Cache::isEnabled const): Deleted. 70 71 Remove isEnabled() state as a cache object now always represents an enabled cache. 72 73 * NetworkProcess/cache/NetworkCacheEntry.cpp: 74 (WebKit::NetworkCache::Entry::initializeShareableResourceHandleFromStorageRecord const): 75 * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp: 76 (WebKit::NetworkCache::SpeculativeLoad::willSendRedirectedRequest): 77 (WebKit::NetworkCache::SpeculativeLoad::didReceiveResponse): 78 (WebKit::NetworkCache::SpeculativeLoad::didFinishLoading): 79 * NetworkProcess/cache/NetworkCacheStatistics.cpp: 80 (WebKit::NetworkCache::Statistics::initialize): 81 (WebKit::NetworkCache::Statistics::shrinkIfNeeded): 82 * NetworkProcess/cache/NetworkCacheStorage.cpp: 83 (WebKit::NetworkCache::Storage::ReadOperation::ReadOperation): 84 (WebKit::NetworkCache::Storage::WriteOperation::WriteOperation): 85 (WebKit::NetworkCache::Storage::TraverseOperation::TraverseOperation): 86 87 Operations now ref the storage. They are already deleted in the main thread so 88 proper destruction is taken care of. 89 90 (WebKit::NetworkCache::Storage::open): 91 (WebKit::NetworkCache::Storage::~Storage): 92 (WebKit::NetworkCache::Storage::synchronize): 93 94 This and other asynchronous methods now protect the Storage instance. 95 96 (WebKit::NetworkCache::Storage::remove): 97 (WebKit::NetworkCache::Storage::retrieve): 98 (WebKit::NetworkCache::Storage::store): 99 (WebKit::NetworkCache::Storage::traverse): 100 (WebKit::NetworkCache::Storage::clear): 101 (WebKit::NetworkCache::Storage::shrink): 102 (WebKit::NetworkCache::Storage::deleteOldVersions): 103 * NetworkProcess/cache/NetworkCacheStorage.h: 104 * NetworkProcess/cocoa/NetworkProcessCocoa.mm: 105 (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa): 106 (WebKit::NetworkProcess::clearDiskCache): 107 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 108 (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): 109 * NetworkProcess/soup/NetworkProcessSoup.cpp: 110 (WebKit::NetworkProcess::platformInitializeNetworkProcess): 111 (WebKit::NetworkProcess::clearDiskCache): 112 1 113 2017-08-04 Frederic Wang <fwang@igalia.com> 2 114 -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
r220105 r220267 410 410 void NetworkConnectionToWebProcess::storeDerivedDataToCache(const WebKit::NetworkCache::DataKey& dataKey, const IPC::DataReference& data) 411 411 { 412 NetworkCache::singleton().storeData(dataKey, data.data(), data.size()); 412 if (auto* cache = NetworkProcess::singleton().cache()) 413 cache->storeData(dataKey, data.data(), data.size()); 413 414 } 414 415 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r220105 r220267 329 329 { 330 330 #if ENABLE(NETWORK_CACHE) 331 if ( NetworkCache::singleton().isEnabled()) {331 if (auto* cache = NetworkProcess::singleton().cache()) { 332 332 HashMap<SecurityOriginData, uint64_t> originsAndSizes; 333 NetworkCache::singleton().traverse([fetchOptions, completionHandler = WTFMove(completionHandler), originsAndSizes = WTFMove(originsAndSizes)](auto* traversalEntry) mutable {333 cache->traverse([fetchOptions, completionHandler = WTFMove(completionHandler), originsAndSizes = WTFMove(originsAndSizes)](auto* traversalEntry) mutable { 334 334 if (!traversalEntry) { 335 335 Vector<WebsiteData::Entry> entries; … … 437 437 { 438 438 #if ENABLE(NETWORK_CACHE) 439 if ( NetworkCache::singleton().isEnabled()) {439 if (auto* cache = NetworkProcess::singleton().cache()) { 440 440 HashSet<RefPtr<SecurityOrigin>> originsToDelete; 441 441 for (auto& origin : origins) … … 443 443 444 444 Vector<NetworkCache::Key> cacheKeysToDelete; 445 NetworkCache::singleton().traverse([completionHandler = WTFMove(completionHandler), originsToDelete = WTFMove(originsToDelete), cacheKeysToDelete = WTFMove(cacheKeysToDelete)](auto* traversalEntry) mutable {445 cache->traverse([cache, completionHandler = WTFMove(completionHandler), originsToDelete = WTFMove(originsToDelete), cacheKeysToDelete = WTFMove(cacheKeysToDelete)](auto* traversalEntry) mutable { 446 446 if (traversalEntry) { 447 447 if (originsToDelete.contains(SecurityOrigin::create(traversalEntry->entry.response().url()))) … … 450 450 } 451 451 452 NetworkCache::singleton().remove(cacheKeysToDelete, WTFMove(completionHandler));452 cache->remove(cacheKeysToDelete, WTFMove(completionHandler)); 453 453 return; 454 454 }); … … 576 576 577 577 #if ENABLE(NETWORK_CACHE) 578 auto& networkCache = NetworkCache::singleton(); 579 if (networkCache.isEnabled()) { 580 networkCache.setCapacity(urlCacheDiskCapacity); 578 if (m_cache) { 579 m_cache->setCapacity(urlCacheDiskCapacity); 581 580 return; 582 581 } -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r220105 r220267 64 64 struct WebsiteDataStoreParameters; 65 65 66 namespace NetworkCache { 67 class Cache; 68 } 69 66 70 class NetworkProcess : public ChildProcess, private DownloadManager::Client { 67 71 WTF_MAKE_NONCOPYABLE(NetworkProcess); … … 87 91 AuthenticationManager& authenticationManager(); 88 92 DownloadManager& downloadManager(); 93 94 NetworkCache::Cache* cache() { return m_cache.get(); } 95 89 96 bool canHandleHTTPSServerTrustEvaluation() const { return m_canHandleHTTPSServerTrustEvaluation; } 90 97 … … 221 228 Seconds m_loadThrottleLatency; 222 229 230 RefPtr<NetworkCache::Cache> m_cache; 231 223 232 typedef HashMap<const char*, std::unique_ptr<NetworkProcessSupplement>, PtrHash<const char*>> NetworkProcessSupplementMap; 224 233 NetworkProcessSupplementMap m_supplements; -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
r220185 r220267 87 87 , m_defersLoading(parameters.defersLoading) 88 88 , m_bufferingTimer(*this, &NetworkResourceLoader::bufferingTimerFired) 89 , m_cache(sessionID().isEphemeral() ? nullptr : NetworkProcess::singleton().cache()) 89 90 { 90 91 ASSERT(RunLoop::isMain()); … … 122 123 bool NetworkResourceLoader::canUseCache(const ResourceRequest& request) const 123 124 { 124 if (! NetworkCache::singleton().isEnabled())125 if (!m_cache) 125 126 return false; 126 if (sessionID().isEphemeral())127 return false; 127 ASSERT(!sessionID().isEphemeral()); 128 128 129 if (!request.url().protocolIsInHTTPFamily()) 129 130 return false; … … 182 183 183 184 RefPtr<NetworkResourceLoader> loader(this); 184 NetworkCache::singleton().retrieve(request, { m_parameters.webPageID, m_parameters.webFrameID }, [this, loader = WTFMove(loader), request](auto entry) {185 m_cache->retrieve(request, { m_parameters.webPageID, m_parameters.webFrameID }, [this, loader = WTFMove(loader), request](auto entry) { 185 186 if (loader->hasOneRef()) { 186 187 // The loader has been aborted and is only held alive by this lambda. … … 308 309 // We might already have used data from this incomplete load. Ensure older versions don't remain in the cache after cancel. 309 310 if (!m_response.isNull()) 310 NetworkCache::singleton().remove(m_networkLoad->currentRequest());311 m_cache->remove(m_networkLoad->currentRequest()); 311 312 } 312 313 #endif … … 335 336 bool validationSucceeded = m_response.httpStatusCode() == 304; // 304 Not Modified 336 337 if (validationSucceeded) { 337 m_cacheEntryForValidation = NetworkCache::singleton().update(originalRequest(), { m_parameters.webPageID, m_parameters.webFrameID }, *m_cacheEntryForValidation, m_response);338 m_cacheEntryForValidation = m_cache->update(originalRequest(), { m_parameters.webPageID, m_parameters.webFrameID }, *m_cacheEntryForValidation, m_response); 338 339 // If the request was conditional then this revalidation was not triggered by the network cache and we pass the 304 response to WebCore. 339 340 if (originalRequest().isConditional()) … … 471 472 #if ENABLE(NETWORK_CACHE) 472 473 if (canUseCachedRedirect(request)) 473 NetworkCache::singleton().storeRedirect(request, redirectResponse, redirectRequest);474 m_cache->storeRedirect(request, redirectResponse, redirectRequest); 474 475 #else 475 476 UNUSED_PARAM(request); … … 560 561 return; 561 562 562 NetworkCache::singleton().store(m_networkLoad->currentRequest(), m_response, WTFMove(m_bufferedDataForCache), [loader = makeRef(*this)](auto& mappedBody) mutable {563 m_cache->store(m_networkLoad->currentRequest(), m_response, WTFMove(m_bufferedDataForCache), [loader = makeRef(*this)](auto& mappedBody) mutable { 563 564 #if ENABLE(SHAREABLE_RESOURCE) 564 565 if (mappedBody.shareableResourceHandle.isNull()) … … 589 590 for (auto& type : m_parameters.derivedCachedDataTypesToRetrieve) { 590 591 NetworkCache::DataKey key { originalRequest().cachePartition(), type, bodyHash }; 591 NetworkCache::singleton().retrieveData(key, [loader = makeRef(*this), entryPtr, type, retrieveCount] (const uint8_t* data, size_t size) mutable {592 m_cache->retrieveData(key, [loader = makeRef(*this), entryPtr, type, retrieveCount] (const uint8_t* data, size_t size) mutable { 592 593 loader->m_retrievedDerivedDataCount++; 593 594 bool retrievedAll = loader->m_retrievedDerivedDataCount == retrieveCount; -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h
r220185 r220267 161 161 WebCore::Timer m_bufferingTimer; 162 162 #if ENABLE(NETWORK_CACHE) 163 RefPtr<NetworkCache::Cache> m_cache; 163 164 RefPtr<WebCore::SharedBuffer> m_bufferedDataForCache; 164 165 std::unique_ptr<NetworkCache::Entry> m_cacheEntryForValidation; -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
r219249 r220267 1 1 /* 2 * Copyright (C) 2014-201 5Apple Inc. All rights reserved.2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 63 63 } 64 64 65 Cache& singleton() 66 { 67 static NeverDestroyed<Cache> instance; 68 return instance; 65 RefPtr<Cache> Cache::open(const String& cachePath, OptionSet<Option> options) 66 { 67 auto storage = Storage::open(cachePath, options.contains(Option::TestingMode) ? Storage::Mode::Testing : Storage::Mode::Normal); 68 69 LOG(NetworkCache, "(NetworkProcess) opened cache storage, success %d", !!storage); 70 71 if (!storage) 72 return nullptr; 73 74 return adoptRef(*new Cache(storage.releaseNonNull(), options)); 69 75 } 70 76 … … 76 82 #endif 77 83 78 bool Cache::initialize(const String& cachePath, OptionSet<Option> options) 79 { 80 m_storage = Storage::open(cachePath, options.contains(Option::TestingMode) ? Storage::Mode::Testing : Storage::Mode::Normal); 81 84 Cache::Cache(Ref<Storage>&& storage, OptionSet<Option> options) 85 : m_storage(WTFMove(storage)) 86 { 82 87 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 83 88 if (options.contains(Option::SpeculativeRevalidation)) { … … 88 93 else { 89 94 ASSERT(!m_speculativeLoadManager); 90 m_speculativeLoadManager = std::make_unique<SpeculativeLoadManager>(* m_storage);95 m_speculativeLoadManager = std::make_unique<SpeculativeLoadManager>(*this, m_storage.get()); 91 96 } 92 97 }); 93 98 if (!m_lowPowerModeNotifier->isLowPowerModeEnabled()) 94 m_speculativeLoadManager = std::make_unique<SpeculativeLoadManager>(* m_storage);99 m_speculativeLoadManager = std::make_unique<SpeculativeLoadManager>(*this, m_storage.get()); 95 100 } 96 101 #endif 97 102 98 103 if (options.contains(Option::EfficacyLogging)) 99 m_statistics = Statistics::open(cachePath); 100 104 m_statistics = Statistics::open(*this, m_storage->basePath()); 105 106 if (options.contains(Option::RegisterNotify)) { 101 107 #if PLATFORM(COCOA) 102 // Triggers with "notifyutil -p com.apple.WebKit.Cache.dump". 103 if (m_storage) { 108 // Triggers with "notifyutil -p com.apple.WebKit.Cache.dump". 104 109 int token; 105 110 notify_register_dispatch("com.apple.WebKit.Cache.dump", &token, dispatch_get_main_queue(), ^(int) { 106 111 dumpContentsToFile(); 107 112 }); 108 }109 113 #endif 110 114 #if PLATFORM(GTK) 111 // Triggers with "touch $cachePath/dump". 112 if (m_storage) { 115 // Triggers with "touch $cachePath/dump". 113 116 CString dumpFilePath = WebCore::fileSystemRepresentation(WebCore::pathByAppendingComponent(m_storage->basePath(), "dump")); 114 117 GRefPtr<GFile> dumpFile = adoptGRef(g_file_new_for_path(dumpFilePath.data())); 115 118 GFileMonitor* monitor = g_file_monitor_file(dumpFile.get(), G_FILE_MONITOR_NONE, nullptr, nullptr); 116 119 g_signal_connect_swapped(monitor, "changed", G_CALLBACK(dumpFileChanged), this); 117 } 118 #endif 119 120 LOG(NetworkCache, "(NetworkProcess) opened cache storage, success %d", !!m_storage); 121 return !!m_storage; 120 #endif 121 } 122 } 123 124 Cache::~Cache() 125 { 122 126 } 123 127 124 128 void Cache::setCapacity(size_t maximumSize) 125 129 { 126 if (!m_storage)127 return;128 130 m_storage->setCapacity(maximumSize); 129 131 } … … 316 318 void Cache::retrieve(const WebCore::ResourceRequest& request, const GlobalFrameID& frameID, Function<void (std::unique_ptr<Entry>)>&& completionHandler) 317 319 { 318 ASSERT(isEnabled());319 320 ASSERT(request.url().protocolIsInHTTPFamily()); 320 321 … … 356 357 auto priority = static_cast<unsigned>(request.priority()); 357 358 358 m_storage->retrieve(storageKey, priority, [this, request, completionHandler = WTFMove(completionHandler), startTime, storageKey, frameID](auto record) {359 m_storage->retrieve(storageKey, priority, [this, protectedThis = makeRef(*this), request, completionHandler = WTFMove(completionHandler), startTime, storageKey, frameID](auto record) { 359 360 if (!record) { 360 361 LOG(NetworkCache, "(NetworkProcess) not found in storage"); … … 409 410 std::unique_ptr<Entry> Cache::store(const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& response, RefPtr<WebCore::SharedBuffer>&& responseData, Function<void (MappedBody&)>&& completionHandler) 410 411 { 411 ASSERT(isEnabled());412 412 ASSERT(responseData); 413 413 … … 434 434 auto record = cacheEntry->encodeAsStorageRecord(); 435 435 436 m_storage->store(record, [this, completionHandler = WTFMove(completionHandler)](const Data& bodyData) {436 m_storage->store(record, [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](const Data& bodyData) { 437 437 MappedBody mappedBody; 438 438 #if ENABLE(SHAREABLE_RESOURCE) … … 454 454 std::unique_ptr<Entry> Cache::storeRedirect(const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& response, const WebCore::ResourceRequest& redirectRequest) 455 455 { 456 ASSERT(isEnabled());457 458 456 LOG(NetworkCache, "(NetworkProcess) storing redirect %s -> %s", request.url().string().latin1().data(), redirectRequest.url().string().latin1().data()); 459 457 … … 496 494 void Cache::remove(const Key& key) 497 495 { 498 ASSERT(isEnabled());499 500 496 m_storage->remove(key); 501 497 } … … 508 504 void Cache::remove(const Vector<Key>& keys, Function<void ()>&& completionHandler) 509 505 { 510 ASSERT(isEnabled());511 512 506 m_storage->remove(keys, WTFMove(completionHandler)); 513 507 } … … 515 509 void Cache::traverse(Function<void (const TraversalEntry*)>&& traverseHandler) 516 510 { 517 ASSERT(isEnabled());518 519 511 // Protect against clients making excessive traversal requests. 520 512 const unsigned maximumTraverseCount = 3; … … 530 522 ++m_traverseCount; 531 523 532 m_storage->traverse(resourceType(), 0, [this, traverseHandler = WTFMove(traverseHandler)](const Storage::Record* record, const Storage::RecordInfo& recordInfo) {524 m_storage->traverse(resourceType(), 0, [this, protectedThis = makeRef(*this), traverseHandler = WTFMove(traverseHandler)](const Storage::Record* record, const Storage::RecordInfo& recordInfo) { 533 525 if (!record) { 534 526 --m_traverseCount; … … 553 545 void Cache::dumpContentsToFile() 554 546 { 555 if (!m_storage)556 return;557 547 auto fd = WebCore::openFile(dumpFilePath(), WebCore::OpenForWrite); 558 548 if (!WebCore::isHandleValid(fd)) … … 621 611 m_statistics->clear(); 622 612 623 if (!m_storage) {624 RunLoop::main().dispatch(WTFMove(completionHandler));625 return;626 }627 613 String anyType; 628 614 m_storage->clear(anyType, modifiedSince, WTFMove(completionHandler)); … … 638 624 String Cache::recordsPath() const 639 625 { 640 return m_storage ? m_storage->recordsPath() : String();626 return m_storage->recordsPath(); 641 627 } 642 628 643 629 void Cache::retrieveData(const DataKey& dataKey, Function<void (const uint8_t* data, size_t size)> completionHandler) 644 630 { 645 ASSERT(isEnabled());646 647 631 Key key { dataKey, m_storage->salt() }; 648 632 m_storage->retrieve(key, 4, [completionHandler = WTFMove(completionHandler)] (auto record) { … … 658 642 void Cache::storeData(const DataKey& dataKey, const uint8_t* data, size_t size) 659 643 { 660 if (!m_storage)661 return;662 644 Key key { dataKey, m_storage->salt() }; 663 645 Storage::Record record { key, std::chrono::system_clock::now(), { }, Data { data, size }, { } }; -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h
r219249 r220267 1 1 /* 2 * Copyright (C) 2014-201 5Apple Inc. All rights reserved.2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef NetworkCache_h 27 #define NetworkCache_h 26 #pragma once 28 27 29 28 #if ENABLE(NETWORK_CACHE) … … 50 49 class SpeculativeLoadManager; 51 50 class Statistics; 52 53 Cache& singleton();54 51 55 52 struct MappedBody { … … 92 89 using GlobalFrameID = std::pair<uint64_t /*webPageID*/, uint64_t /*webFrameID*/>; 93 90 94 class Cache { 95 WTF_MAKE_NONCOPYABLE(Cache); 96 friend class WTF::NeverDestroyed<Cache>; 91 class Cache : public RefCounted<Cache> { 97 92 public: 98 93 enum class Option { … … 100 95 // In testing mode we try to eliminate sources of randomness. Cache does not shrink and there are no read timeouts. 101 96 TestingMode = 1 << 1, 97 RegisterNotify = 1 << 2, 102 98 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 103 SpeculativeRevalidation = 1 << 2,99 SpeculativeRevalidation = 1 << 3, 104 100 #endif 105 101 }; 106 bool initialize(const String& cachePath, OptionSet<Option>); 102 static RefPtr<Cache> open(const String& cachePath, OptionSet<Option>); 103 107 104 void setCapacity(size_t); 108 109 bool isEnabled() const { return !!m_storage; }110 105 111 106 // Completion handler may get called back synchronously on failure. … … 136 131 137 132 String recordsPath() const; 138 bool canUseSharedMemoryForBodyData() const { return m_storage && m_storage->canUseSharedMemoryForBodyData(); }133 bool canUseSharedMemoryForBodyData() const { return m_storage->canUseSharedMemoryForBodyData(); } 139 134 140 135 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) … … 142 137 #endif 143 138 139 ~Cache(); 140 144 141 private: 145 Cache() = default; 146 ~Cache() = delete; 142 Cache(Ref<Storage>&&, OptionSet<Option> options); 147 143 148 144 Key makeCacheKey(const WebCore::ResourceRequest&); … … 151 147 void deleteDumpFile(); 152 148 153 std::unique_ptr<Storage> m_storage; 149 Ref<Storage> m_storage; 150 154 151 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 155 152 std::unique_ptr<WebCore::LowPowerModeNotifier> m_lowPowerModeNotifier; … … 164 161 } 165 162 #endif 166 #endif -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.cpp
r212244 r220267 29 29 #include "Logging.h" 30 30 #include "NetworkCacheCoders.h" 31 #include "NetworkProcess.h" 31 32 #include <WebCore/ResourceRequest.h> 32 33 #include <WebCore/SharedBuffer.h> … … 147 148 void Entry::initializeShareableResourceHandleFromStorageRecord() const 148 149 { 149 if (!NetworkCache::singleton().canUseSharedMemoryForBodyData()) 150 auto* cache = NetworkProcess::singleton().cache(); 151 if (!cache || !cache->canUseSharedMemoryForBodyData()) 150 152 return; 151 153 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp
r215078 r220267 42 42 using namespace WebCore; 43 43 44 SpeculativeLoad::SpeculativeLoad(const GlobalFrameID& frameID, const ResourceRequest& request, std::unique_ptr<NetworkCache::Entry> cacheEntryForValidation, RevalidationCompletionHandler&& completionHandler) 45 : m_frameID(frameID) 44 SpeculativeLoad::SpeculativeLoad(Cache& cache, const GlobalFrameID& frameID, const ResourceRequest& request, std::unique_ptr<NetworkCache::Entry> cacheEntryForValidation, RevalidationCompletionHandler&& completionHandler) 45 : m_cache(cache) 46 , m_frameID(frameID) 46 47 , m_completionHandler(WTFMove(completionHandler)) 47 48 , m_originalRequest(request) … … 72 73 LOG(NetworkCacheSpeculativePreloading, "Speculative redirect %s -> %s", request.url().string().utf8().data(), redirectRequest.url().string().utf8().data()); 73 74 74 m_cacheEntry = NetworkCache::singleton().storeRedirect(request, redirectResponse, redirectRequest);75 m_cacheEntry = m_cache->storeRedirect(request, redirectResponse, redirectRequest); 75 76 // Create a synthetic cache entry if we can't store. 76 77 if (!m_cacheEntry) 77 m_cacheEntry = NetworkCache::singleton().makeRedirectEntry(request, redirectResponse, redirectRequest);78 m_cacheEntry = m_cache->makeRedirectEntry(request, redirectResponse, redirectRequest); 78 79 79 80 // Don't follow the redirect. The redirect target will be registered for speculative load when it is loaded. … … 90 91 bool validationSucceeded = m_response.httpStatusCode() == 304; // 304 Not Modified 91 92 if (validationSucceeded && m_cacheEntry) 92 m_cacheEntry = NetworkCache::singleton().update(m_originalRequest, m_frameID, *m_cacheEntry, m_response);93 m_cacheEntry = m_cache->update(m_originalRequest, m_frameID, *m_cacheEntry, m_response); 93 94 else 94 95 m_cacheEntry = nullptr; … … 116 117 return; 117 118 if (!m_cacheEntry && m_bufferedDataForCache) { 118 m_cacheEntry = NetworkCache::singleton().store(m_originalRequest, m_response, m_bufferedDataForCache.copyRef(), [](auto& mappedBody) { });119 m_cacheEntry = m_cache->store(m_originalRequest, m_response, m_bufferedDataForCache.copyRef(), [](auto& mappedBody) { }); 119 120 // Create a synthetic cache entry if we can't store. 120 121 if (!m_cacheEntry && isStatusCodeCacheableByDefault(m_response.httpStatusCode())) 121 m_cacheEntry = NetworkCache::singleton().makeEntry(m_originalRequest, m_response, WTFMove(m_bufferedDataForCache));122 m_cacheEntry = m_cache->makeEntry(m_originalRequest, m_response, WTFMove(m_bufferedDataForCache)); 122 123 } 123 124 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h
r218024 r220267 24 24 */ 25 25 26 #ifndef NetworkCacheSpeculativeLoad_h 27 #define NetworkCacheSpeculativeLoad_h 26 #pragma once 28 27 29 28 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) … … 46 45 public: 47 46 typedef Function<void (std::unique_ptr<NetworkCache::Entry>)> RevalidationCompletionHandler; 48 SpeculativeLoad( const GlobalFrameID&, const WebCore::ResourceRequest&, std::unique_ptr<NetworkCache::Entry>, RevalidationCompletionHandler&&);47 SpeculativeLoad(Cache&, const GlobalFrameID&, const WebCore::ResourceRequest&, std::unique_ptr<NetworkCache::Entry>, RevalidationCompletionHandler&&); 49 48 50 49 virtual ~SpeculativeLoad(); … … 67 66 void didComplete(); 68 67 68 Ref<Cache> m_cache; 69 69 GlobalFrameID m_frameID; 70 70 RevalidationCompletionHandler m_completionHandler; … … 84 84 85 85 #endif // ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 86 87 #endif // NetworkCacheSpeculativeLoad_h -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp
r217979 r220267 246 246 }; 247 247 248 SpeculativeLoadManager::SpeculativeLoadManager(Storage& storage) 249 : m_storage(storage) 248 SpeculativeLoadManager::SpeculativeLoadManager(Cache& cache, Storage& storage) 249 : m_cache(cache) 250 , m_storage(storage) 250 251 { 251 252 } … … 467 468 LOG(NetworkCacheSpeculativePreloading, "(NetworkProcess) Speculatively revalidating '%s':", key.identifier().utf8().data()); 468 469 469 auto revalidator = std::make_unique<SpeculativeLoad>( frameID, revalidationRequest, WTFMove(entry), [this, key, revalidationRequest, frameID](std::unique_ptr<Entry> revalidatedEntry) {470 auto revalidator = std::make_unique<SpeculativeLoad>(m_cache, frameID, revalidationRequest, WTFMove(entry), [this, key, revalidationRequest, frameID](std::unique_ptr<Entry> revalidatedEntry) { 470 471 ASSERT(!revalidatedEntry || !revalidatedEntry->needsValidation()); 471 472 ASSERT(!revalidatedEntry || revalidatedEntry->key() == key); -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h
r217947 r220267 47 47 WTF_MAKE_FAST_ALLOCATED; 48 48 public: 49 explicit SpeculativeLoadManager( Storage&);49 explicit SpeculativeLoadManager(Cache&, Storage&); 50 50 ~SpeculativeLoadManager(); 51 51 … … 71 71 static bool canUsePendingPreload(const SpeculativeLoad&, const WebCore::ResourceRequest& actualRequest); 72 72 73 Cache& m_cache; 73 74 Storage& m_storage; 74 75 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStatistics.cpp
r216841 r220267 75 75 } 76 76 77 std::unique_ptr<Statistics> Statistics::open( const String& cachePath)77 std::unique_ptr<Statistics> Statistics::open(Cache& cache, const String& cachePath) 78 78 { 79 79 ASSERT(RunLoop::isMain()); 80 80 81 81 String databasePath = WebCore::pathByAppendingComponent(cachePath, StatisticsDatabaseName); 82 return std::make_unique<Statistics>(databasePath); 83 } 84 85 Statistics::Statistics(const String& databasePath) 86 : m_serialBackgroundIOQueue(WorkQueue::create("com.apple.WebKit.Cache.Statistics.Background", WorkQueue::Type::Serial, WorkQueue::QOS::Background)) 82 return std::make_unique<Statistics>(cache, databasePath); 83 } 84 85 Statistics::Statistics(Cache& cache, const String& databasePath) 86 : m_cache(cache) 87 , m_serialBackgroundIOQueue(WorkQueue::create("com.apple.WebKit.Cache.Statistics.Background", WorkQueue::Type::Serial, WorkQueue::QOS::Background)) 87 88 , m_writeTimer(*this, &Statistics::writeTimerFired) 88 89 { … … 96 97 auto startTime = std::chrono::system_clock::now(); 97 98 98 serialBackgroundIOQueue().dispatch([this, databasePath = databasePath.isolatedCopy(), networkCachePath = singleton().recordsPath().isolatedCopy(), startTime] {99 serialBackgroundIOQueue().dispatch([this, databasePath = databasePath.isolatedCopy(), networkCachePath = m_cache.recordsPath(), startTime] { 99 100 WebCore::SQLiteTransactionInProgressAutoCounter transactionCounter; 100 101 … … 179 180 clear(); 180 181 181 serialBackgroundIOQueue().dispatch([this, networkCachePath = singleton().recordsPath().isolatedCopy()] {182 serialBackgroundIOQueue().dispatch([this, networkCachePath = m_cache.recordsPath()] { 182 183 bootstrapFromNetworkCache(networkCachePath); 183 184 LOG(NetworkCache, "(NetworkProcess) statistics cache shrink completed m_approximateEntryCount=%lu", static_cast<size_t>(m_approximateEntryCount)); -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStatistics.h
r218024 r220267 44 44 class Statistics { 45 45 public: 46 static std::unique_ptr<Statistics> open( const String& cachePath);47 explicit Statistics( const String& databasePath);46 static std::unique_ptr<Statistics> open(Cache&, const String& cachePath); 47 explicit Statistics(Cache&, const String& databasePath); 48 48 49 49 void clear(); … … 78 78 }; 79 79 80 Cache& m_cache; 81 80 82 std::atomic<size_t> m_approximateEntryCount { 0 }; 81 83 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp
r219249 r220267 1 1 /* 2 * Copyright (C) 2014-201 5Apple Inc. All rights reserved.2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 54 54 WTF_MAKE_FAST_ALLOCATED; 55 55 public: 56 ReadOperation(const Key& key, RetrieveCompletionHandler&& completionHandler) 57 : key(key) 56 ReadOperation(Storage& storage, const Key& key, RetrieveCompletionHandler&& completionHandler) 57 : storage(storage) 58 , key(key) 58 59 , completionHandler(WTFMove(completionHandler)) 59 60 { } … … 61 62 void cancel(); 62 63 bool finish(); 64 65 Ref<Storage> storage; 63 66 64 67 const Key key; … … 100 103 WTF_MAKE_FAST_ALLOCATED; 101 104 public: 102 WriteOperation(const Record& record, MappedBodyHandler&& mappedBodyHandler) 103 : record(record) 105 WriteOperation(Storage& storage, const Record& record, MappedBodyHandler&& mappedBodyHandler) 106 : storage(storage) 107 , record(record) 104 108 , mappedBodyHandler(WTFMove(mappedBodyHandler)) 105 109 { } 106 110 Ref<Storage> storage; 111 107 112 const Record record; 108 113 const MappedBodyHandler mappedBodyHandler; … … 114 119 WTF_MAKE_FAST_ALLOCATED; 115 120 public: 116 TraverseOperation(const String& type, TraverseFlags flags, TraverseHandler&& handler) 117 : type(type) 121 TraverseOperation(Storage& storage, const String& type, TraverseFlags flags, TraverseHandler&& handler) 122 : storage(storage) 123 , type(type) 118 124 , flags(flags) 119 125 , handler(WTFMove(handler)) 120 126 { } 127 Ref<Storage> storage; 121 128 122 129 const String type; … … 150 157 } 151 158 152 std::unique_ptr<Storage> Storage::open(const String& cachePath, Mode mode)159 RefPtr<Storage> Storage::open(const String& cachePath, Mode mode) 153 160 { 154 161 ASSERT(RunLoop::isMain()); … … 159 166 if (!salt) 160 167 return nullptr; 161 return std::unique_ptr<Storage>(new Storage(cachePath, mode, *salt));168 return adoptRef(new Storage(cachePath, mode, *salt)); 162 169 } 163 170 … … 227 234 Storage::~Storage() 228 235 { 236 ASSERT(RunLoop::isMain()); 237 ASSERT(m_activeReadOperations.isEmpty()); 238 ASSERT(m_activeWriteOperations.isEmpty()); 239 ASSERT(m_activeTraverseOperations.isEmpty()); 240 ASSERT(!m_synchronizationInProgress); 241 ASSERT(!m_shrinkInProgress); 229 242 } 230 243 … … 259 272 LOG(NetworkCacheStorage, "(NetworkProcess) synchronizing cache"); 260 273 261 backgroundIOQueue().dispatch([this ]{274 backgroundIOQueue().dispatch([this, protectedThis = makeRef(*this)] () mutable { 262 275 auto recordFilter = std::make_unique<ContentsFilter>(); 263 276 auto blobFilter = std::make_unique<ContentsFilter>(); … … 310 323 311 324 LOG(NetworkCacheStorage, "(NetworkProcess) cache synchronization completed size=%zu count=%u", recordsSize, count); 325 326 RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis)] { }); 312 327 }); 313 328 } … … 555 570 removeFromPendingWriteOperations(key); 556 571 557 serialBackgroundIOQueue().dispatch([this, key]{572 serialBackgroundIOQueue().dispatch([this, protectedThis = makeRef(*this), key] () mutable { 558 573 deleteFiles(key); 574 RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis)] { }); 559 575 }); 560 576 } … … 574 590 } 575 591 576 serialBackgroundIOQueue().dispatch([this, keysToRemove = WTFMove(keysToRemove), completionHandler = WTFMove(completionHandler)] () mutable {592 serialBackgroundIOQueue().dispatch([this, protectedThis = makeRef(*this), keysToRemove = WTFMove(keysToRemove), completionHandler = WTFMove(completionHandler)] () mutable { 577 593 for (auto& key : keysToRemove) 578 594 deleteFiles(key); 579 595 580 if (completionHandler) 581 RunLoop::main().dispatch(WTFMove(completionHandler)); 596 RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)] { 597 if (completionHandler) 598 completionHandler(); 599 }); 582 600 }); 583 601 } … … 806 824 return; 807 825 808 auto readOperation = std::make_unique<ReadOperation>( key, WTFMove(completionHandler));826 auto readOperation = std::make_unique<ReadOperation>(*this, key, WTFMove(completionHandler)); 809 827 m_pendingReadOperationsByPriority[priority].prepend(WTFMove(readOperation)); 810 828 dispatchPendingReadOperations(); … … 819 837 return; 820 838 821 auto writeOperation = std::make_unique<WriteOperation>( record, WTFMove(mappedBodyHandler));839 auto writeOperation = std::make_unique<WriteOperation>(*this, record, WTFMove(mappedBodyHandler)); 822 840 m_pendingWriteOperations.prepend(WTFMove(writeOperation)); 823 841 … … 841 859 // Avoid non-thread safe Function copies. 842 860 843 auto traverseOperationPtr = std::make_unique<TraverseOperation>( type, flags, WTFMove(traverseHandler));861 auto traverseOperationPtr = std::make_unique<TraverseOperation>(*this, type, flags, WTFMove(traverseHandler)); 844 862 auto& traverseOperation = *traverseOperationPtr; 845 863 m_activeTraverseOperations.add(WTFMove(traverseOperationPtr)); … … 937 955 m_approximateRecordsSize = 0; 938 956 939 ioQueue().dispatch([this, modifiedSinceTime, completionHandler = WTFMove(completionHandler), type = type.isolatedCopy()] () mutable {957 ioQueue().dispatch([this, protectedThis = makeRef(*this), modifiedSinceTime, completionHandler = WTFMove(completionHandler), type = type.isolatedCopy()] () mutable { 940 958 auto recordsPath = this->recordsPath(); 941 959 traverseRecordsFiles(recordsPath, type, [modifiedSinceTime](const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath) { … … 954 972 m_blobStorage.synchronize(); 955 973 956 if (completionHandler){957 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {974 RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)] { 975 if (completionHandler) 958 976 completionHandler(); 959 }); 960 } 977 }); 961 978 }); 962 979 } … … 1020 1037 LOG(NetworkCacheStorage, "(NetworkProcess) shrinking cache approximateSize=%zu capacity=%zu", approximateSize(), m_capacity); 1021 1038 1022 backgroundIOQueue().dispatch([this ]{1039 backgroundIOQueue().dispatch([this, protectedThis = makeRef(*this)] () mutable { 1023 1040 auto recordsPath = this->recordsPath(); 1024 1041 String anyType; … … 1044 1061 }); 1045 1062 1046 RunLoop::main().dispatch([this ] {1063 RunLoop::main().dispatch([this, protectedThis = WTFMove(protectedThis)] { 1047 1064 m_shrinkInProgress = false; 1048 1065 // We could synchronize during the shrink traversal. However this is fast and it is better to have just one code path. … … 1056 1073 void Storage::deleteOldVersions() 1057 1074 { 1058 backgroundIOQueue().dispatch([this ]{1075 backgroundIOQueue().dispatch([this, protectedThis = makeRef(*this)] () mutable { 1059 1076 auto cachePath = basePath(); 1060 1077 traverseDirectory(cachePath, [&cachePath](const String& subdirName, DirectoryEntryType type) { … … 1080 1097 deleteDirectoryRecursively(oldVersionPath); 1081 1098 }); 1099 1100 RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis)] { }); 1082 1101 }); 1083 1102 } -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h
r219249 r220267 1 1 /* 2 * Copyright (C) 2014-201 5Apple Inc. All rights reserved.2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef NetworkCacheStorage_h 27 #define NetworkCacheStorage_h 26 #pragma once 28 27 29 28 #if ENABLE(NETWORK_CACHE) … … 46 45 class IOChannel; 47 46 48 class Storage { 49 WTF_MAKE_NONCOPYABLE(Storage); 47 class Storage : public ThreadSafeRefCounted<Storage> { 50 48 public: 51 49 enum class Mode { Normal, Testing }; 52 static std::unique_ptr<Storage> open(const String& cachePath, Mode);50 static RefPtr<Storage> open(const String& cachePath, Mode); 53 51 54 52 struct Record { … … 194 192 } 195 193 #endif 196 #endif -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
r220243 r220267 85 85 NetworkSessionCocoa::setSourceApplicationSecondaryIdentifier(parameters.sourceApplicationSecondaryIdentifier); 86 86 NetworkSessionCocoa::setAllowsCellularAccess(parameters.allowsCellularAccess); 87 NetworkSessionCocoa::setUsesNetworkCache(parameters.shouldEnableNetworkCache); 87 88 #if PLATFORM(IOS) 88 89 NetworkSessionCocoa::setCTDataConnectionServiceType(parameters.ctDataConnectionServiceType); … … 109 110 #if ENABLE(NETWORK_CACHE) 110 111 if (parameters.shouldEnableNetworkCache) { 111 OptionSet<NetworkCache::Cache::Option> cacheOptions ;112 OptionSet<NetworkCache::Cache::Option> cacheOptions { NetworkCache::Cache::Option::RegisterNotify }; 112 113 if (parameters.shouldEnableNetworkCacheEfficacyLogging) 113 114 cacheOptions |= NetworkCache::Cache::Option::EfficacyLogging; … … 118 119 cacheOptions |= NetworkCache::Cache::Option::SpeculativeRevalidation; 119 120 #endif 120 if (NetworkCache::singleton().initialize(m_diskCacheDirectory, cacheOptions)) { 121 m_cache = NetworkCache::Cache::open(m_diskCacheDirectory, cacheOptions); 122 123 if (m_cache) { 124 // Disable NSURLCache. 121 125 auto urlCache(adoptNS([[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil])); 122 126 [NSURLCache setSharedURLCache:urlCache.get()]; … … 188 192 189 193 #if ENABLE(NETWORK_CACHE) 190 auto group = m_clearCacheDispatchGroup; 191 dispatch_group_async(group, dispatch_get_main_queue(), BlockPtr<void()>::fromCallable([group, modifiedSince, completionHandler = WTFMove(completionHandler)] () mutable { 192 NetworkCache::singleton().clear(modifiedSince, [group, modifiedSince, completionHandler = WTFMove(completionHandler)] () mutable { 193 // FIXME: Probably not necessary. 194 clearNSURLCache(group, modifiedSince, WTFMove(completionHandler)); 195 }); 196 }).get()); 197 #else 194 if (auto* cache = NetworkProcess::singleton().cache()) { 195 auto group = m_clearCacheDispatchGroup; 196 dispatch_group_async(group, dispatch_get_main_queue(), BlockPtr<void()>::fromCallable([cache, group, modifiedSince, completionHandler = WTFMove(completionHandler)] () mutable { 197 cache->clear(modifiedSince, [group, modifiedSince, completionHandler = WTFMove(completionHandler)] () mutable { 198 // FIXME: Probably not necessary. 199 clearNSURLCache(group, modifiedSince, WTFMove(completionHandler)); 200 }); 201 }).get()); 202 return; 203 } 204 #endif 198 205 clearNSURLCache(m_clearCacheDispatchGroup, modifiedSince, WTFMove(completionHandler)); 199 #endif200 206 } 201 207 -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h
r213747 r220267 53 53 static void setSourceApplicationSecondaryIdentifier(const String&); 54 54 static void setAllowsCellularAccess(bool); 55 static void setUsesNetworkCache(bool); 55 56 #if PLATFORM(IOS) 56 57 static void setCTDataConnectionServiceType(const String&); -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r220243 r220267 34 34 #import "LegacyCustomProtocolManager.h" 35 35 #import "Logging.h" 36 #import "NetworkCache.h"37 36 #import "NetworkLoad.h" 38 37 #import "NetworkProcess.h" … … 450 449 451 450 static bool allowsCellularAccess { true }; 451 static bool usesNetworkCache { false }; 452 452 static LegacyCustomProtocolManager* legacyCustomProtocolManager; 453 453 … … 521 521 } 522 522 523 void NetworkSessionCocoa::setUsesNetworkCache(bool value) 524 { 525 usesNetworkCache = value; 526 } 527 523 528 #if PLATFORM(IOS) 524 529 void NetworkSessionCocoa::setCTDataConnectionServiceType(const String& type) … … 554 559 if (!allowsCellularAccess) 555 560 configuration.allowsCellularAccess = NO; 556 557 if ( NetworkCache::singleton().isEnabled())561 562 if (usesNetworkCache) 558 563 configuration.URLCache = nil; 559 564 560 565 if (auto& data = globalSourceApplicationAuditTokenData()) 561 566 configuration._sourceApplicationAuditTokenData = (NSData *)data.get(); -
trunk/Source/WebKit/NetworkProcess/ios/NetworkProcessIOS.mm
r220243 r220267 80 80 return; 81 81 #if ENABLE(NETWORK_CACHE) 82 NetworkCache::singleton().clear(); 82 if (m_cache) 83 m_cache->clear(); 83 84 #endif 84 85 } -
trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp
r218985 r220267 113 113 SoupNetworkSession::clearOldSoupCache(WebCore::directoryName(m_diskCacheDirectory)); 114 114 115 OptionSet<NetworkCache::Cache::Option> cacheOptions ;115 OptionSet<NetworkCache::Cache::Option> cacheOptions { NetworkCache::Cache::Option::RegisterNotify }; 116 116 if (parameters.shouldEnableNetworkCacheEfficacyLogging) 117 117 cacheOptions |= NetworkCache::Cache::Option::EfficacyLogging; … … 121 121 #endif 122 122 123 NetworkCache::singleton().initialize(m_diskCacheDirectory, cacheOptions);123 m_cache = NetworkCache::Cache::open(m_diskCacheDirectory, cacheOptions); 124 124 125 125 if (!parameters.cookiePersistentStoragePath.isEmpty()) { … … 159 159 void NetworkProcess::clearDiskCache(std::chrono::system_clock::time_point modifiedSince, Function<void ()>&& completionHandler) 160 160 { 161 NetworkCache::singleton().clear(modifiedSince, WTFMove(completionHandler)); 161 if (!m_cache) 162 return; 163 m_cache->clear(modifiedSince, WTFMove(completionHandler)); 162 164 } 163 165
Note: See TracChangeset
for help on using the changeset viewer.