Title: [194338] trunk/Source/WebKit2
- Revision
- 194338
- Author
- [email protected]
- Date
- 2015-12-21 12:01:35 -0800 (Mon, 21 Dec 2015)
Log Message
Factor NetworkResourceLoader code for storing a cache entry into a function
https://bugs.webkit.org/show_bug.cgi?id=152467
Reviewed by Andreas Kling.
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didFinishLoading):
Having m_cacheEntryForValidation already implies canUseCache() so remove the test from this path.
Move storing to the end of the function so we don't delay DidFinishResourceLoad message on it.
(WebKit::NetworkResourceLoader::sendBufferMaybeAborting):
(WebKit::NetworkResourceLoader::tryStoreAsCacheEntry):
Factor to a function.
Remove m_response.isHTTP() test as it is covered by NetworkCache::store().
Remove !isPrivateSession test as it is covered by NetworkResourceLoader::canUseCache().
(WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
* NetworkProcess/NetworkResourceLoader.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (194337 => 194338)
--- trunk/Source/WebKit2/ChangeLog 2015-12-21 19:54:46 UTC (rev 194337)
+++ trunk/Source/WebKit2/ChangeLog 2015-12-21 20:01:35 UTC (rev 194338)
@@ -1,5 +1,28 @@
2015-12-21 Antti Koivisto <[email protected]>
+ Factor NetworkResourceLoader code for storing a cache entry into a function
+ https://bugs.webkit.org/show_bug.cgi?id=152467
+
+ Reviewed by Andreas Kling.
+
+ * NetworkProcess/NetworkResourceLoader.cpp:
+ (WebKit::NetworkResourceLoader::didFinishLoading):
+
+ Having m_cacheEntryForValidation already implies canUseCache() so remove the test from this path.
+ Move storing to the end of the function so we don't delay DidFinishResourceLoad message on it.
+
+ (WebKit::NetworkResourceLoader::sendBufferMaybeAborting):
+ (WebKit::NetworkResourceLoader::tryStoreAsCacheEntry):
+
+ Factor to a function.
+ Remove m_response.isHTTP() test as it is covered by NetworkCache::store().
+ Remove !isPrivateSession test as it is covered by NetworkResourceLoader::canUseCache().
+
+ (WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
+ * NetworkProcess/NetworkResourceLoader.h:
+
+2015-12-21 Antti Koivisto <[email protected]>
+
Limit cached redirect chain length
https://bugs.webkit.org/show_bug.cgi?id=152477
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp (194337 => 194338)
--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp 2015-12-21 19:54:46 UTC (rev 194337)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp 2015-12-21 20:01:35 UTC (rev 194338)
@@ -338,29 +338,12 @@
void NetworkResourceLoader::didFinishLoading(double finishTime)
{
#if ENABLE(NETWORK_CACHE)
- if (canUseCache(m_networkLoad->currentRequest())) {
- if (m_cacheEntryForValidation) {
- // 304 Not Modified
- ASSERT(m_response.httpStatusCode() == 304);
- LOG(NetworkCache, "(NetworkProcess) revalidated");
- didRetrieveCacheEntry(WTF::move(m_cacheEntryForValidation));
- return;
- }
-
- bool isPrivateSession = sessionID().isEphemeral();
- if (m_bufferedDataForCache && m_response.isHTTP() && !isPrivateSession) {
- // Keep the connection alive.
- RefPtr<NetworkConnectionToWebProcess> connection(&connectionToWebProcess());
- RefPtr<NetworkResourceLoader> loader(this);
- NetworkCache::singleton().store(m_networkLoad->currentRequest(), m_response, WTF::move(m_bufferedDataForCache), [loader, connection](NetworkCache::MappedBody& mappedBody) {
-#if ENABLE(SHAREABLE_RESOURCE)
- if (mappedBody.shareableResourceHandle.isNull())
- return;
- LOG(NetworkCache, "(NetworkProcess) sending DidCacheResource");
- loader->send(Messages::NetworkProcessConnection::DidCacheResource(loader->originalRequest(), mappedBody.shareableResourceHandle, loader->sessionID()));
-#endif
- });
- }
+ if (m_cacheEntryForValidation) {
+ // 304 Not Modified
+ ASSERT(m_response.httpStatusCode() == 304);
+ LOG(NetworkCache, "(NetworkProcess) revalidated");
+ didRetrieveCacheEntry(WTF::move(m_cacheEntryForValidation));
+ return;
}
#endif
@@ -376,6 +359,10 @@
send(Messages::WebResourceLoader::DidFinishResourceLoad(finishTime));
}
+#if ENABLE(NETWORK_CACHE)
+ tryStoreAsCacheEntry();
+#endif
+
cleanup();
}
@@ -500,6 +487,26 @@
}
#if ENABLE(NETWORK_CACHE)
+void NetworkResourceLoader::tryStoreAsCacheEntry()
+{
+ if (!canUseCache(m_networkLoad->currentRequest()))
+ return;
+ if (!m_bufferedDataForCache)
+ return;
+
+ // Keep the connection alive.
+ RefPtr<NetworkConnectionToWebProcess> connection(&connectionToWebProcess());
+ RefPtr<NetworkResourceLoader> loader(this);
+ NetworkCache::singleton().store(m_networkLoad->currentRequest(), m_response, WTF::move(m_bufferedDataForCache), [loader, connection](NetworkCache::MappedBody& mappedBody) {
+#if ENABLE(SHAREABLE_RESOURCE)
+ if (mappedBody.shareableResourceHandle.isNull())
+ return;
+ LOG(NetworkCache, "(NetworkProcess) sending DidCacheResource");
+ loader->send(Messages::NetworkProcessConnection::DidCacheResource(loader->originalRequest(), mappedBody.shareableResourceHandle, loader->sessionID()));
+#endif
+ });
+}
+
void NetworkResourceLoader::didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry> entry)
{
if (isSynchronous()) {
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h (194337 => 194338)
--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h 2015-12-21 19:54:46 UTC (rev 194337)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h 2015-12-21 20:01:35 UTC (rev 194338)
@@ -115,6 +115,7 @@
bool canUseCache(const WebCore::ResourceRequest&) const;
bool canUseCachedRedirect(const WebCore::ResourceRequest&) const;
+ void tryStoreAsCacheEntry();
void retrieveCacheEntry(const WebCore::ResourceRequest&);
void didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry>);
void validateCacheEntry(std::unique_ptr<NetworkCache::Entry>);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes