WebKit Bugzilla
Attachment 358604 Details for
Bug 193243
: Stop using NetworkProcess::singleton in NetworkCache code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193243-20190108094440.patch (text/plain), 20.26 KB, created by
Alex Christensen
on 2019-01-08 09:44:41 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2019-01-08 09:44:41 PST
Size:
20.26 KB
patch
obsolete
>Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 239725) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,34 @@ >+2019-01-08 Alex Christensen <achristensen@webkit.org> >+ >+ Stop using NetworkProcess::singleton in NetworkCache code >+ https://bugs.webkit.org/show_bug.cgi?id=193243 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * NetworkProcess/cache/NetworkCache.cpp: >+ (WebKit::NetworkCache::Cache::open): >+ (WebKit::NetworkCache::Cache::Cache): >+ * NetworkProcess/cache/NetworkCache.h: >+ (WebKit::NetworkCache::Cache::networkProcess): >+ * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp: >+ (WebKit::NetworkCache::logSpeculativeLoadingDiagnosticMessage): >+ (WebKit::NetworkCache::SpeculativeLoadManager::canRetrieve const): >+ (WebKit::NetworkCache::SpeculativeLoadManager::addPreloadedEntry): >+ (WebKit::NetworkCache::SpeculativeLoadManager::revalidateSubresource): >+ (WebKit::NetworkCache::SpeculativeLoadManager::preloadEntry): >+ (WebKit::NetworkCache::SpeculativeLoadManager::startSpeculativeRevalidation): >+ * NetworkProcess/cache/NetworkCacheStatistics.cpp: >+ (WebKit::NetworkCache::Statistics::recordRetrievalRequest): >+ (WebKit::NetworkCache::Statistics::recordNotUsingCacheForRequest): >+ (WebKit::NetworkCache::Statistics::recordRetrievalFailure): >+ (WebKit::NetworkCache::Statistics::recordRetrievedCachedEntry): >+ (WebKit::NetworkCache::Statistics::recordRevalidationSuccess): >+ * NetworkProcess/cache/NetworkCacheStorage.cpp: >+ (WebKit::NetworkCache::retrieveFromMemory): >+ * NetworkProcess/cache/NetworkCacheStorage.h: >+ * NetworkProcess/cocoa/NetworkProcessCocoa.mm: >+ (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa): >+ > 2019-01-08 Alex Christensen <achristensen@webkit.org> > > Always call CompletionHandler in Cache::store >Index: Source/WebKit/NetworkProcess/cache/NetworkCache.cpp >=================================================================== >--- Source/WebKit/NetworkProcess/cache/NetworkCache.cpp (revision 239725) >+++ Source/WebKit/NetworkProcess/cache/NetworkCache.cpp (working copy) >@@ -59,7 +59,7 @@ static const AtomicString& resourceType( > return resource; > } > >-RefPtr<Cache> Cache::open(const String& cachePath, OptionSet<Option> options) >+RefPtr<Cache> Cache::open(NetworkProcess& networkProcess, const String& cachePath, OptionSet<Option> options) > { > auto storage = Storage::open(cachePath, options.contains(Option::TestingMode) ? Storage::Mode::AvoidRandomness : Storage::Mode::Normal); > >@@ -68,7 +68,7 @@ RefPtr<Cache> Cache::open(const String& > if (!storage) > return nullptr; > >- return adoptRef(*new Cache(storage.releaseNonNull(), options)); >+ return adoptRef(*new Cache(networkProcess, storage.releaseNonNull(), options)); > } > > #if PLATFORM(GTK) >@@ -78,8 +78,9 @@ static void dumpFileChanged(Cache* cache > } > #endif > >-Cache::Cache(Ref<Storage>&& storage, OptionSet<Option> options) >+Cache::Cache(NetworkProcess& networkProcess, Ref<Storage>&& storage, OptionSet<Option> options) > : m_storage(WTFMove(storage)) >+ , m_networkProcess(networkProcess) > { > #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) > if (options.contains(Option::SpeculativeRevalidation)) { >Index: Source/WebKit/NetworkProcess/cache/NetworkCache.h >=================================================================== >--- Source/WebKit/NetworkProcess/cache/NetworkCache.h (revision 239725) >+++ Source/WebKit/NetworkProcess/cache/NetworkCache.h (working copy) >@@ -41,6 +41,9 @@ class SharedBuffer; > } > > namespace WebKit { >+ >+class NetworkProcess; >+ > namespace NetworkCache { > > class Cache; >@@ -97,7 +100,7 @@ public: > SpeculativeRevalidation = 1 << 3, > #endif > }; >- static RefPtr<Cache> open(const String& cachePath, OptionSet<Option>); >+ static RefPtr<Cache> open(NetworkProcess&, const String& cachePath, OptionSet<Option>); > > void setCapacity(size_t); > >@@ -143,10 +146,12 @@ public: > SpeculativeLoadManager* speculativeLoadManager() { return m_speculativeLoadManager.get(); } > #endif > >+ NetworkProcess& networkProcess() { return m_networkProcess.get(); } >+ > ~Cache(); > > private: >- Cache(Ref<Storage>&&, OptionSet<Option> options); >+ Cache(NetworkProcess&, Ref<Storage>&&, OptionSet<Option> options); > > Key makeCacheKey(const WebCore::ResourceRequest&); > >@@ -158,6 +163,7 @@ private: > Optional<Seconds> maxAgeCap(Entry&, const WebCore::ResourceRequest&, PAL::SessionID); > > Ref<Storage> m_storage; >+ Ref<NetworkProcess> m_networkProcess; > > #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) > std::unique_ptr<WebCore::LowPowerModeNotifier> m_lowPowerModeNotifier; >@@ -168,5 +174,5 @@ private: > unsigned m_traverseCount { 0 }; > }; > >-} >-} >+} // namespace NetworkCache >+} // namespace WebKit >Index: Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp >=================================================================== >--- Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp (revision 239670) >+++ Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp (working copy) >@@ -64,13 +64,13 @@ static void printSpeculativeLoadingDiagn > } > #endif > >-static void logSpeculativeLoadingDiagnosticMessage(const GlobalFrameID& frameID, const String& message) >+static void logSpeculativeLoadingDiagnosticMessage(NetworkProcess& networkProcess, const GlobalFrameID& frameID, const String& message) > { > #if !LOG_DISABLED > if (WebKit2LogNetworkCacheSpeculativePreloading.state == WTFLogChannelOn) > allSpeculativeLoadingDiagnosticMessages().add(message); > #endif >- NetworkProcess::singleton().logDiagnosticMessage(frameID.first, WebCore::DiagnosticLoggingKeys::networkCacheKey(), message, WebCore::ShouldSample::Yes); >+ networkProcess.logDiagnosticMessage(frameID.first, WebCore::DiagnosticLoggingKeys::networkCacheKey(), message, WebCore::ShouldSample::Yes); > } > > static const AtomicString& subresourcesType() >@@ -313,12 +313,12 @@ bool SpeculativeLoadManager::canRetrieve > if (auto preloadedEntry = m_preloadedEntries.get(storageKey)) { > if (!canUsePreloadedEntry(*preloadedEntry, request)) { > LOG(NetworkCacheSpeculativePreloading, "(NetworkProcess) Retrieval: Could not use preloaded entry to satisfy request for '%s' due to HTTP headers mismatch:", storageKey.identifier().utf8().data()); >- logSpeculativeLoadingDiagnosticMessage(frameID, preloadedEntry->wasRevalidated() ? DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey() : DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey()); >+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, preloadedEntry->wasRevalidated() ? DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey() : DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey()); > return false; > } > > LOG(NetworkCacheSpeculativePreloading, "(NetworkProcess) Retrieval: Using preloaded entry to satisfy request for '%s':", storageKey.identifier().utf8().data()); >- logSpeculativeLoadingDiagnosticMessage(frameID, preloadedEntry->wasRevalidated() ? DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey() : DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey()); >+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, preloadedEntry->wasRevalidated() ? DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey() : DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey()); > return true; > } > >@@ -326,16 +326,16 @@ bool SpeculativeLoadManager::canRetrieve > auto* pendingPreload = m_pendingPreloads.get(storageKey); > if (!pendingPreload) { > if (m_notPreloadedEntries.get(storageKey)) >- logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::entryWronglyNotWarmedUpKey()); >+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::entryWronglyNotWarmedUpKey()); > else >- logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::unknownEntryRequestKey()); >+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::unknownEntryRequestKey()); > > return false; > } > > if (!canUsePendingPreload(*pendingPreload, request)) { > LOG(NetworkCacheSpeculativePreloading, "(NetworkProcess) Retrieval: revalidation already in progress for '%s' but unusable due to HTTP headers mismatch:", storageKey.identifier().utf8().data()); >- logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey()); >+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey()); > return false; > } > >@@ -408,9 +408,9 @@ void SpeculativeLoadManager::addPreloade > auto preloadedEntry = m_preloadedEntries.take(key); > ASSERT(preloadedEntry); > if (preloadedEntry->wasRevalidated()) >- logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey()); >+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey()); > else >- logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey()); >+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey()); > })); > } > >@@ -477,7 +477,7 @@ void SpeculativeLoadManager::revalidateS > > if (satisfyPendingRequests(key, revalidatedEntry.get())) { > if (revalidatedEntry) >- logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey()); >+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey()); > return; > } > >@@ -537,7 +537,7 @@ void SpeculativeLoadManager::preloadEntr > > if (satisfyPendingRequests(key, entry.get())) { > if (entry) >- logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey()); >+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey()); > return; > } > >@@ -560,7 +560,7 @@ void SpeculativeLoadManager::startSpecul > else { > LOG(NetworkCacheSpeculativePreloading, "(NetworkProcess) Not preloading '%s' because it is marked as transient", key.identifier().utf8().data()); > m_notPreloadedEntries.add(key, std::make_unique<ExpiringEntry>([this, key, frameID] { >- logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::entryRightlyNotWarmedUpKey()); >+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::entryRightlyNotWarmedUpKey()); > m_notPreloadedEntries.remove(key); > })); > } >Index: Source/WebKit/NetworkProcess/cache/NetworkCacheStatistics.cpp >=================================================================== >--- Source/WebKit/NetworkProcess/cache/NetworkCacheStatistics.cpp (revision 239670) >+++ Source/WebKit/NetworkProcess/cache/NetworkCacheStatistics.cpp (working copy) >@@ -186,7 +186,7 @@ void Statistics::shrinkIfNeeded() > > void Statistics::recordRetrievalRequest(uint64_t webPageID) > { >- NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalRequestKey(), WebCore::ShouldSample::Yes); >+ m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalRequestKey(), WebCore::ShouldSample::Yes); > } > > void Statistics::recordNotCachingResponse(const Key& key, StoreDecision storeDecision) >@@ -225,9 +225,9 @@ void Statistics::recordNotUsingCacheForR > if (wasEverRequested) { > String diagnosticKey = retrieveDecisionToDiagnosticKey(retrieveDecision); > LOG(NetworkCache, "(NetworkProcess) webPageID %" PRIu64 ": %s was previously requested but we are not using the cache, reason: %s", webPageID, requestURL.string().ascii().data(), diagnosticKey.utf8().data()); >- NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheUnusedReasonKey(), diagnosticKey, WebCore::ShouldSample::Yes); >+ m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheUnusedReasonKey(), diagnosticKey, WebCore::ShouldSample::Yes); > } else { >- NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheUnusedReasonKey(), WebCore::DiagnosticLoggingKeys::neverSeenBeforeKey(), WebCore::ShouldSample::Yes); >+ m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheUnusedReasonKey(), WebCore::DiagnosticLoggingKeys::neverSeenBeforeKey(), WebCore::ShouldSample::Yes); > markAsRequested(hash); > } > }); >@@ -265,9 +265,9 @@ void Statistics::recordRetrievalFailure( > if (wasPreviouslyRequested) { > String diagnosticKey = storeDecisionToDiagnosticKey(storeDecision.value()); > LOG(NetworkCache, "(NetworkProcess) webPageID %" PRIu64 ": %s was previously request but is not in the cache, reason: %s", webPageID, requestURL.string().ascii().data(), diagnosticKey.utf8().data()); >- NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheFailureReasonKey(), diagnosticKey, WebCore::ShouldSample::Yes); >+ m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheFailureReasonKey(), diagnosticKey, WebCore::ShouldSample::Yes); > } else { >- NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheFailureReasonKey(), WebCore::DiagnosticLoggingKeys::neverSeenBeforeKey(), WebCore::ShouldSample::Yes); >+ m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheFailureReasonKey(), WebCore::DiagnosticLoggingKeys::neverSeenBeforeKey(), WebCore::ShouldSample::Yes); > markAsRequested(hash); > } > }); >@@ -295,19 +295,19 @@ void Statistics::recordRetrievedCachedEn > URL requestURL = request.url(); > if (decision == UseDecision::Use) { > LOG(NetworkCache, "(NetworkProcess) webPageID %" PRIu64 ": %s is in the cache and is used", webPageID, requestURL.string().ascii().data()); >- NetworkProcess::singleton().logDiagnosticMessageWithResult(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalKey(), WebCore::DiagnosticLoggingResultPass, WebCore::ShouldSample::Yes); >+ m_cache.networkProcess().logDiagnosticMessageWithResult(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalKey(), WebCore::DiagnosticLoggingResultPass, WebCore::ShouldSample::Yes); > return; > } > > if (decision == UseDecision::Validate) { > LOG(NetworkCache, "(NetworkProcess) webPageID %" PRIu64 ": %s is in the cache but needs revalidation", webPageID, requestURL.string().ascii().data()); >- NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::needsRevalidationKey(), WebCore::ShouldSample::Yes); >+ m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::needsRevalidationKey(), WebCore::ShouldSample::Yes); > return; > } > > String diagnosticKey = cachedEntryReuseFailureToDiagnosticKey(decision); > LOG(NetworkCache, "(NetworkProcess) webPageID %" PRIu64 ": %s is in the cache but wasn't used, reason: %s", webPageID, requestURL.string().ascii().data(), diagnosticKey.utf8().data()); >- NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheReuseFailureKey(), diagnosticKey, WebCore::ShouldSample::Yes); >+ m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheReuseFailureKey(), diagnosticKey, WebCore::ShouldSample::Yes); > } > > void Statistics::recordRevalidationSuccess(uint64_t webPageID, const Key& key, const WebCore::ResourceRequest& request) >@@ -315,7 +315,7 @@ void Statistics::recordRevalidationSucce > URL requestURL = request.url(); > LOG(NetworkCache, "(NetworkProcess) webPageID %" PRIu64 ": %s was successfully revalidated", webPageID, requestURL.string().ascii().data()); > >- NetworkProcess::singleton().logDiagnosticMessageWithResult(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::revalidatingKey(), WebCore::DiagnosticLoggingResultPass, WebCore::ShouldSample::Yes); >+ m_cache.networkProcess().logDiagnosticMessageWithResult(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::revalidatingKey(), WebCore::DiagnosticLoggingResultPass, WebCore::ShouldSample::Yes); > } > > void Statistics::markAsRequested(const String& hash) >Index: Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp >=================================================================== >--- Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp (revision 239725) >+++ Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp (working copy) >@@ -65,7 +65,7 @@ public: > Ref<Storage> storage; > > const Key key; >- const RetrieveCompletionHandler completionHandler; >+ RetrieveCompletionHandler completionHandler; > > std::unique_ptr<Record> resultRecord; > SHA1::Digest expectedBodyHash; >@@ -763,7 +763,7 @@ template <class T> bool retrieveFromMemo > for (auto& operation : operations) { > if (operation->record.key == key) { > LOG(NetworkCacheStorage, "(NetworkProcess) found write operation in progress"); >- RunLoop::main().dispatch([record = operation->record, completionHandler = WTFMove(completionHandler)] { >+ RunLoop::main().dispatch([record = operation->record, completionHandler = WTFMove(completionHandler)] () mutable { > completionHandler(std::make_unique<Storage::Record>(record), { }); > }); > return true; >Index: Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h >=================================================================== >--- Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h (revision 239670) >+++ Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h (working copy) >@@ -78,7 +78,7 @@ public: > }; > > // This may call completion handler synchronously on failure. >- using RetrieveCompletionHandler = Function<bool (std::unique_ptr<Record>, const Timings&)>; >+ using RetrieveCompletionHandler = CompletionHandler<bool(std::unique_ptr<Record>, const Timings&)>; > void retrieve(const Key&, unsigned priority, RetrieveCompletionHandler&&); > > using MappedBodyHandler = Function<void (const Data& mappedBody)>; >Index: Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm >=================================================================== >--- Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm (revision 239683) >+++ Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm (working copy) >@@ -122,7 +122,7 @@ void NetworkProcess::platformInitializeN > cacheOptions.add(NetworkCache::Cache::Option::SpeculativeRevalidation); > #endif > >- m_cache = NetworkCache::Cache::open(m_diskCacheDirectory, cacheOptions); >+ m_cache = NetworkCache::Cache::open(*this, m_diskCacheDirectory, cacheOptions); > if (!m_cache) > RELEASE_LOG_ERROR(NetworkCache, "Failed to initialize the WebKit network disk cache"); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193243
:
358604
|
358609