Changeset 194338 in webkit
- Timestamp:
- Dec 21, 2015, 12:01:35 PM (9 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r194337 r194338 1 2015-12-21 Antti Koivisto <antti@apple.com> 2 3 Factor NetworkResourceLoader code for storing a cache entry into a function 4 https://bugs.webkit.org/show_bug.cgi?id=152467 5 6 Reviewed by Andreas Kling. 7 8 * NetworkProcess/NetworkResourceLoader.cpp: 9 (WebKit::NetworkResourceLoader::didFinishLoading): 10 11 Having m_cacheEntryForValidation already implies canUseCache() so remove the test from this path. 12 Move storing to the end of the function so we don't delay DidFinishResourceLoad message on it. 13 14 (WebKit::NetworkResourceLoader::sendBufferMaybeAborting): 15 (WebKit::NetworkResourceLoader::tryStoreAsCacheEntry): 16 17 Factor to a function. 18 Remove m_response.isHTTP() test as it is covered by NetworkCache::store(). 19 Remove !isPrivateSession test as it is covered by NetworkResourceLoader::canUseCache(). 20 21 (WebKit::NetworkResourceLoader::didRetrieveCacheEntry): 22 * NetworkProcess/NetworkResourceLoader.h: 23 1 24 2015-12-21 Antti Koivisto <antti@apple.com> 2 25 -
trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
r194337 r194338 339 339 { 340 340 #if ENABLE(NETWORK_CACHE) 341 if (canUseCache(m_networkLoad->currentRequest())) { 342 if (m_cacheEntryForValidation) { 343 // 304 Not Modified 344 ASSERT(m_response.httpStatusCode() == 304); 345 LOG(NetworkCache, "(NetworkProcess) revalidated"); 346 didRetrieveCacheEntry(WTF::move(m_cacheEntryForValidation)); 347 return; 348 } 349 350 bool isPrivateSession = sessionID().isEphemeral(); 351 if (m_bufferedDataForCache && m_response.isHTTP() && !isPrivateSession) { 352 // Keep the connection alive. 353 RefPtr<NetworkConnectionToWebProcess> connection(&connectionToWebProcess()); 354 RefPtr<NetworkResourceLoader> loader(this); 355 NetworkCache::singleton().store(m_networkLoad->currentRequest(), m_response, WTF::move(m_bufferedDataForCache), [loader, connection](NetworkCache::MappedBody& mappedBody) { 356 #if ENABLE(SHAREABLE_RESOURCE) 357 if (mappedBody.shareableResourceHandle.isNull()) 358 return; 359 LOG(NetworkCache, "(NetworkProcess) sending DidCacheResource"); 360 loader->send(Messages::NetworkProcessConnection::DidCacheResource(loader->originalRequest(), mappedBody.shareableResourceHandle, loader->sessionID())); 361 #endif 362 }); 363 } 341 if (m_cacheEntryForValidation) { 342 // 304 Not Modified 343 ASSERT(m_response.httpStatusCode() == 304); 344 LOG(NetworkCache, "(NetworkProcess) revalidated"); 345 didRetrieveCacheEntry(WTF::move(m_cacheEntryForValidation)); 346 return; 364 347 } 365 348 #endif … … 376 359 send(Messages::WebResourceLoader::DidFinishResourceLoad(finishTime)); 377 360 } 361 362 #if ENABLE(NETWORK_CACHE) 363 tryStoreAsCacheEntry(); 364 #endif 378 365 379 366 cleanup(); … … 501 488 502 489 #if ENABLE(NETWORK_CACHE) 490 void NetworkResourceLoader::tryStoreAsCacheEntry() 491 { 492 if (!canUseCache(m_networkLoad->currentRequest())) 493 return; 494 if (!m_bufferedDataForCache) 495 return; 496 497 // Keep the connection alive. 498 RefPtr<NetworkConnectionToWebProcess> connection(&connectionToWebProcess()); 499 RefPtr<NetworkResourceLoader> loader(this); 500 NetworkCache::singleton().store(m_networkLoad->currentRequest(), m_response, WTF::move(m_bufferedDataForCache), [loader, connection](NetworkCache::MappedBody& mappedBody) { 501 #if ENABLE(SHAREABLE_RESOURCE) 502 if (mappedBody.shareableResourceHandle.isNull()) 503 return; 504 LOG(NetworkCache, "(NetworkProcess) sending DidCacheResource"); 505 loader->send(Messages::NetworkProcessConnection::DidCacheResource(loader->originalRequest(), mappedBody.shareableResourceHandle, loader->sessionID())); 506 #endif 507 }); 508 } 509 503 510 void NetworkResourceLoader::didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry> entry) 504 511 { -
trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
r194337 r194338 116 116 bool canUseCachedRedirect(const WebCore::ResourceRequest&) const; 117 117 118 void tryStoreAsCacheEntry(); 118 119 void retrieveCacheEntry(const WebCore::ResourceRequest&); 119 120 void didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry>);
Note:
See TracChangeset
for help on using the changeset viewer.