Changeset 239740 in webkit
- Timestamp:
- Jan 8, 2019 1:23:00 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r239738 r239740 1 2019-01-08 Alex Christensen <achristensen@webkit.org> 2 3 Stop using NetworkProcess::singleton in NetworkCache code 4 https://bugs.webkit.org/show_bug.cgi?id=193243 5 6 Reviewed by Brent Fulgham. 7 8 * NetworkProcess/cache/NetworkCache.cpp: 9 (WebKit::NetworkCache::Cache::open): 10 (WebKit::NetworkCache::Cache::Cache): 11 * NetworkProcess/cache/NetworkCache.h: 12 (WebKit::NetworkCache::Cache::networkProcess): 13 * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp: 14 (WebKit::NetworkCache::logSpeculativeLoadingDiagnosticMessage): 15 (WebKit::NetworkCache::SpeculativeLoadManager::canRetrieve const): 16 (WebKit::NetworkCache::SpeculativeLoadManager::addPreloadedEntry): 17 (WebKit::NetworkCache::SpeculativeLoadManager::revalidateSubresource): 18 (WebKit::NetworkCache::SpeculativeLoadManager::preloadEntry): 19 (WebKit::NetworkCache::SpeculativeLoadManager::startSpeculativeRevalidation): 20 * NetworkProcess/cache/NetworkCacheStatistics.cpp: 21 (WebKit::NetworkCache::Statistics::recordRetrievalRequest): 22 (WebKit::NetworkCache::Statistics::recordNotUsingCacheForRequest): 23 (WebKit::NetworkCache::Statistics::recordRetrievalFailure): 24 (WebKit::NetworkCache::Statistics::recordRetrievedCachedEntry): 25 (WebKit::NetworkCache::Statistics::recordRevalidationSuccess): 26 * NetworkProcess/cache/NetworkCacheStorage.cpp: 27 (WebKit::NetworkCache::retrieveFromMemory): 28 * NetworkProcess/cache/NetworkCacheStorage.h: 29 * NetworkProcess/cocoa/NetworkProcessCocoa.mm: 30 (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa): 31 1 32 2019-01-08 Alex Christensen <achristensen@webkit.org> 2 33 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
r239725 r239740 60 60 } 61 61 62 RefPtr<Cache> Cache::open( const String& cachePath, OptionSet<Option> options)62 RefPtr<Cache> Cache::open(NetworkProcess& networkProcess, const String& cachePath, OptionSet<Option> options) 63 63 { 64 64 auto storage = Storage::open(cachePath, options.contains(Option::TestingMode) ? Storage::Mode::AvoidRandomness : Storage::Mode::Normal); … … 69 69 return nullptr; 70 70 71 return adoptRef(*new Cache( storage.releaseNonNull(), options));71 return adoptRef(*new Cache(networkProcess, storage.releaseNonNull(), options)); 72 72 } 73 73 … … 79 79 #endif 80 80 81 Cache::Cache( Ref<Storage>&& storage, OptionSet<Option> options)81 Cache::Cache(NetworkProcess& networkProcess, Ref<Storage>&& storage, OptionSet<Option> options) 82 82 : m_storage(WTFMove(storage)) 83 , m_networkProcess(networkProcess) 83 84 { 84 85 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h
r239725 r239740 42 42 43 43 namespace WebKit { 44 45 class NetworkProcess; 46 44 47 namespace NetworkCache { 45 48 … … 98 101 #endif 99 102 }; 100 static RefPtr<Cache> open( const String& cachePath, OptionSet<Option>);103 static RefPtr<Cache> open(NetworkProcess&, const String& cachePath, OptionSet<Option>); 101 104 102 105 void setCapacity(size_t); … … 144 147 #endif 145 148 149 NetworkProcess& networkProcess() { return m_networkProcess.get(); } 150 146 151 ~Cache(); 147 152 148 153 private: 149 Cache( Ref<Storage>&&, OptionSet<Option> options);154 Cache(NetworkProcess&, Ref<Storage>&&, OptionSet<Option> options); 150 155 151 156 Key makeCacheKey(const WebCore::ResourceRequest&); … … 159 164 160 165 Ref<Storage> m_storage; 166 Ref<NetworkProcess> m_networkProcess; 161 167 162 168 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) … … 169 175 }; 170 176 171 } 172 } 177 } // namespace NetworkCache 178 } // namespace WebKit -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp
r239427 r239740 65 65 #endif 66 66 67 static void logSpeculativeLoadingDiagnosticMessage( const GlobalFrameID& frameID, const String& message)67 static void logSpeculativeLoadingDiagnosticMessage(NetworkProcess& networkProcess, const GlobalFrameID& frameID, const String& message) 68 68 { 69 69 #if !LOG_DISABLED … … 71 71 allSpeculativeLoadingDiagnosticMessages().add(message); 72 72 #endif 73 NetworkProcess::singleton().logDiagnosticMessage(frameID.first, WebCore::DiagnosticLoggingKeys::networkCacheKey(), message, WebCore::ShouldSample::Yes);73 networkProcess.logDiagnosticMessage(frameID.first, WebCore::DiagnosticLoggingKeys::networkCacheKey(), message, WebCore::ShouldSample::Yes); 74 74 } 75 75 … … 314 314 if (!canUsePreloadedEntry(*preloadedEntry, request)) { 315 315 LOG(NetworkCacheSpeculativePreloading, "(NetworkProcess) Retrieval: Could not use preloaded entry to satisfy request for '%s' due to HTTP headers mismatch:", storageKey.identifier().utf8().data()); 316 logSpeculativeLoadingDiagnosticMessage( frameID, preloadedEntry->wasRevalidated() ? DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey() : DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey());316 logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, preloadedEntry->wasRevalidated() ? DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey() : DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey()); 317 317 return false; 318 318 } 319 319 320 320 LOG(NetworkCacheSpeculativePreloading, "(NetworkProcess) Retrieval: Using preloaded entry to satisfy request for '%s':", storageKey.identifier().utf8().data()); 321 logSpeculativeLoadingDiagnosticMessage( frameID, preloadedEntry->wasRevalidated() ? DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey() : DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey());321 logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, preloadedEntry->wasRevalidated() ? DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey() : DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey()); 322 322 return true; 323 323 } … … 327 327 if (!pendingPreload) { 328 328 if (m_notPreloadedEntries.get(storageKey)) 329 logSpeculativeLoadingDiagnosticMessage( frameID, DiagnosticLoggingKeys::entryWronglyNotWarmedUpKey());329 logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::entryWronglyNotWarmedUpKey()); 330 330 else 331 logSpeculativeLoadingDiagnosticMessage( frameID, DiagnosticLoggingKeys::unknownEntryRequestKey());331 logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::unknownEntryRequestKey()); 332 332 333 333 return false; … … 336 336 if (!canUsePendingPreload(*pendingPreload, request)) { 337 337 LOG(NetworkCacheSpeculativePreloading, "(NetworkProcess) Retrieval: revalidation already in progress for '%s' but unusable due to HTTP headers mismatch:", storageKey.identifier().utf8().data()); 338 logSpeculativeLoadingDiagnosticMessage( frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey());338 logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey()); 339 339 return false; 340 340 } … … 409 409 ASSERT(preloadedEntry); 410 410 if (preloadedEntry->wasRevalidated()) 411 logSpeculativeLoadingDiagnosticMessage( frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey());411 logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey()); 412 412 else 413 logSpeculativeLoadingDiagnosticMessage( frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey());413 logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey()); 414 414 })); 415 415 } … … 478 478 if (satisfyPendingRequests(key, revalidatedEntry.get())) { 479 479 if (revalidatedEntry) 480 logSpeculativeLoadingDiagnosticMessage( frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey());480 logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey()); 481 481 return; 482 482 } … … 538 538 if (satisfyPendingRequests(key, entry.get())) { 539 539 if (entry) 540 logSpeculativeLoadingDiagnosticMessage( frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey());540 logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey()); 541 541 return; 542 542 } … … 561 561 LOG(NetworkCacheSpeculativePreloading, "(NetworkProcess) Not preloading '%s' because it is marked as transient", key.identifier().utf8().data()); 562 562 m_notPreloadedEntries.add(key, std::make_unique<ExpiringEntry>([this, key, frameID] { 563 logSpeculativeLoadingDiagnosticMessage( frameID, DiagnosticLoggingKeys::entryRightlyNotWarmedUpKey());563 logSpeculativeLoadingDiagnosticMessage(m_cache.networkProcess(), frameID, DiagnosticLoggingKeys::entryRightlyNotWarmedUpKey()); 564 564 m_notPreloadedEntries.remove(key); 565 565 })); -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStatistics.cpp
r239427 r239740 187 187 void Statistics::recordRetrievalRequest(uint64_t webPageID) 188 188 { 189 NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalRequestKey(), WebCore::ShouldSample::Yes);189 m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalRequestKey(), WebCore::ShouldSample::Yes); 190 190 } 191 191 … … 226 226 String diagnosticKey = retrieveDecisionToDiagnosticKey(retrieveDecision); 227 227 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()); 228 NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheUnusedReasonKey(), diagnosticKey, WebCore::ShouldSample::Yes);228 m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheUnusedReasonKey(), diagnosticKey, WebCore::ShouldSample::Yes); 229 229 } else { 230 NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheUnusedReasonKey(), WebCore::DiagnosticLoggingKeys::neverSeenBeforeKey(), WebCore::ShouldSample::Yes);230 m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheUnusedReasonKey(), WebCore::DiagnosticLoggingKeys::neverSeenBeforeKey(), WebCore::ShouldSample::Yes); 231 231 markAsRequested(hash); 232 232 } … … 266 266 String diagnosticKey = storeDecisionToDiagnosticKey(storeDecision.value()); 267 267 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()); 268 NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheFailureReasonKey(), diagnosticKey, WebCore::ShouldSample::Yes);268 m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheFailureReasonKey(), diagnosticKey, WebCore::ShouldSample::Yes); 269 269 } else { 270 NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheFailureReasonKey(), WebCore::DiagnosticLoggingKeys::neverSeenBeforeKey(), WebCore::ShouldSample::Yes);270 m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheFailureReasonKey(), WebCore::DiagnosticLoggingKeys::neverSeenBeforeKey(), WebCore::ShouldSample::Yes); 271 271 markAsRequested(hash); 272 272 } … … 296 296 if (decision == UseDecision::Use) { 297 297 LOG(NetworkCache, "(NetworkProcess) webPageID %" PRIu64 ": %s is in the cache and is used", webPageID, requestURL.string().ascii().data()); 298 NetworkProcess::singleton().logDiagnosticMessageWithResult(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalKey(), WebCore::DiagnosticLoggingResultPass, WebCore::ShouldSample::Yes);298 m_cache.networkProcess().logDiagnosticMessageWithResult(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalKey(), WebCore::DiagnosticLoggingResultPass, WebCore::ShouldSample::Yes); 299 299 return; 300 300 } … … 302 302 if (decision == UseDecision::Validate) { 303 303 LOG(NetworkCache, "(NetworkProcess) webPageID %" PRIu64 ": %s is in the cache but needs revalidation", webPageID, requestURL.string().ascii().data()); 304 NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::needsRevalidationKey(), WebCore::ShouldSample::Yes);304 m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::needsRevalidationKey(), WebCore::ShouldSample::Yes); 305 305 return; 306 306 } … … 308 308 String diagnosticKey = cachedEntryReuseFailureToDiagnosticKey(decision); 309 309 LOG(NetworkCache, "(NetworkProcess) webPageID %" PRIu64 ": %s is in the cache but wasn't used, reason: %s", webPageID, requestURL.string().ascii().data(), diagnosticKey.utf8().data()); 310 NetworkProcess::singleton().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheReuseFailureKey(), diagnosticKey, WebCore::ShouldSample::Yes);310 m_cache.networkProcess().logDiagnosticMessage(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheReuseFailureKey(), diagnosticKey, WebCore::ShouldSample::Yes); 311 311 } 312 312 … … 316 316 LOG(NetworkCache, "(NetworkProcess) webPageID %" PRIu64 ": %s was successfully revalidated", webPageID, requestURL.string().ascii().data()); 317 317 318 NetworkProcess::singleton().logDiagnosticMessageWithResult(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::revalidatingKey(), WebCore::DiagnosticLoggingResultPass, WebCore::ShouldSample::Yes);318 m_cache.networkProcess().logDiagnosticMessageWithResult(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::revalidatingKey(), WebCore::DiagnosticLoggingResultPass, WebCore::ShouldSample::Yes); 319 319 } 320 320 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp
r239738 r239740 66 66 67 67 const Key key; 68 constRetrieveCompletionHandler completionHandler;68 RetrieveCompletionHandler completionHandler; 69 69 70 70 std::unique_ptr<Record> resultRecord; … … 771 771 if (operation->record.key == key) { 772 772 LOG(NetworkCacheStorage, "(NetworkProcess) found write operation in progress"); 773 RunLoop::main().dispatch([record = operation->record, completionHandler = WTFMove(completionHandler)] {773 RunLoop::main().dispatch([record = operation->record, completionHandler = WTFMove(completionHandler)] () mutable { 774 774 completionHandler(std::make_unique<Storage::Record>(record), { }); 775 775 }); -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h
r239427 r239740 79 79 80 80 // This may call completion handler synchronously on failure. 81 using RetrieveCompletionHandler = Function<bool(std::unique_ptr<Record>, const Timings&)>;81 using RetrieveCompletionHandler = CompletionHandler<bool(std::unique_ptr<Record>, const Timings&)>; 82 82 void retrieve(const Key&, unsigned priority, RetrieveCompletionHandler&&); 83 83 -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
r239683 r239740 123 123 #endif 124 124 125 m_cache = NetworkCache::Cache::open( m_diskCacheDirectory, cacheOptions);125 m_cache = NetworkCache::Cache::open(*this, m_diskCacheDirectory, cacheOptions); 126 126 if (!m_cache) 127 127 RELEASE_LOG_ERROR(NetworkCache, "Failed to initialize the WebKit network disk cache"); -
trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp
r239671 r239740 120 120 #endif 121 121 122 m_cache = NetworkCache::Cache::open( m_diskCacheDirectory, cacheOptions);122 m_cache = NetworkCache::Cache::open(*this, m_diskCacheDirectory, cacheOptions); 123 123 124 124 if (!parameters.cookiePersistentStoragePath.isEmpty()) {
Note: See TracChangeset
for help on using the changeset viewer.