Diff
Modified: trunk/Source/WebKit/ChangeLog (239739 => 239740)
--- trunk/Source/WebKit/ChangeLog 2019-01-08 21:15:04 UTC (rev 239739)
+++ trunk/Source/WebKit/ChangeLog 2019-01-08 21:23:00 UTC (rev 239740)
@@ -1,5 +1,36 @@
2019-01-08 Alex Christensen <achristen...@webkit.org>
+ Stop using NetworkProcess::singleton in NetworkCache code
+ https://bugs.webkit.org/show_bug.cgi?id=193243
+
+ Reviewed by Brent Fulgham.
+
+ * 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 <achristen...@webkit.org>
+
Call CompletionHandler when destroying a NetworkCache::Storage::WriteOperation
https://bugs.webkit.org/show_bug.cgi?id=193251
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp (239739 => 239740)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp 2019-01-08 21:15:04 UTC (rev 239739)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp 2019-01-08 21:23:00 UTC (rev 239740)
@@ -59,7 +59,7 @@
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 @@
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 @@
}
#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)) {
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h (239739 => 239740)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h 2019-01-08 21:15:04 UTC (rev 239739)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h 2019-01-08 21:23:00 UTC (rev 239740)
@@ -41,6 +41,9 @@
}
namespace WebKit {
+
+class NetworkProcess;
+
namespace NetworkCache {
class Cache;
@@ -97,7 +100,7 @@
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 @@
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 @@
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 @@
unsigned m_traverseCount { 0 };
};
-}
-}
+} // namespace NetworkCache
+} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp (239739 => 239740)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp 2019-01-08 21:15:04 UTC (rev 239739)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp 2019-01-08 21:23:00 UTC (rev 239740)
@@ -64,13 +64,13 @@
}
#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 @@
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,9 +326,9 @@
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;
}
@@ -335,7 +335,7 @@
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 @@
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 @@
if (satisfyPendingRequests(key, revalidatedEntry.get())) {
if (revalidatedEntry)
- logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey());
+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey());
return;
}
@@ -537,7 +537,7 @@
if (satisfyPendingRequests(key, entry.get())) {
if (entry)
- logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey());
+ logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey());
return;
}
@@ -560,7 +560,7 @@
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);
}));
}
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStatistics.cpp (239739 => 239740)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStatistics.cpp 2019-01-08 21:15:04 UTC (rev 239739)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStatistics.cpp 2019-01-08 21:23:00 UTC (rev 239740)
@@ -186,7 +186,7 @@
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 @@
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 @@
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 @@
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 @@
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)
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp (239739 => 239740)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp 2019-01-08 21:15:04 UTC (rev 239739)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp 2019-01-08 21:23:00 UTC (rev 239740)
@@ -65,7 +65,7 @@
Ref<Storage> storage;
const Key key;
- const RetrieveCompletionHandler completionHandler;
+ RetrieveCompletionHandler completionHandler;
std::unique_ptr<Record> resultRecord;
SHA1::Digest expectedBodyHash;
@@ -770,7 +770,7 @@
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;
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h (239739 => 239740)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h 2019-01-08 21:15:04 UTC (rev 239739)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h 2019-01-08 21:23:00 UTC (rev 239740)
@@ -78,7 +78,7 @@
};
// 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)>;
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm (239739 => 239740)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2019-01-08 21:15:04 UTC (rev 239739)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2019-01-08 21:23:00 UTC (rev 239740)
@@ -122,7 +122,7 @@
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");
Modified: trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp (239739 => 239740)
--- trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp 2019-01-08 21:15:04 UTC (rev 239739)
+++ trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp 2019-01-08 21:23:00 UTC (rev 239740)
@@ -119,7 +119,7 @@
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 (!parameters.cookiePersistentStoragePath.isEmpty()) {
supplement<WebCookieManager>()->setCookiePersistentStorage(parameters.cookiePersistentStoragePath,