ResourceRequest deserialization unnecessarily calls partitionName() on encoded cache partition
https://bugs.webkit.org/show_bug.cgi?id=137797
Reviewed by Darin Adler.
Source/WebCore:
ResourceRequest deserialization was unnecessarily calling partitionName()
on the decoded cache partition. In the deserialization case, we already
know the cache partition is a valid partition name so we can bypass the
call to partitionName() (which is fairly expensive) for performance.
This patch adds a setDomainForCachePartion() method to ResourceRequest
that calls partitionName() on the domain argument, and moves all the
callers of setCachedPartition() to this new setter, except
ArgumentCoder<ResourceRequest>::decode().
This patch updates the setCachedPartition() to merely set the
m_cachePartition member, without calling partitionName() on the
argument. There is also a new assertion in place to make sure the
argument is a valid partition name.
No new tests, no behavior change.
* html/DOMURL.cpp:
(WebCore::DOMURL::revokeObjectURL):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::cachedResource):
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::replayXHR):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::create):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
(WebCore::CachedResourceLoader::requestResource):
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::addImageToCache):
(WebCore::MemoryCache::removeImageFromCache):
* loader/cache/MemoryCache.h:
* page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::domainForCachePartition):
(WebCore::SecurityOrigin::cachePartition): Deleted.
Rename cachePartition() getter to domainForCachePartition() to make it
clear it returns a domain and not a partition name. As such, the caller
should then use ResourceRequest::setDomainForCachePartition(), not
setCachePartition().
* page/SecurityOrigin.h:
* platform/network/cf/ResourceRequest.h:
(WebCore::ResourceRequest::setCachePartition):
(WebCore::ResourceRequest::setDomainForCachePartition):
Source/WebKit/mac:
Call ResourceRequest::setDomainForPartitionName() instead of
setPartitionName() as the argument is a domain, not a valid
partition name.
* Misc/WebCache.mm:
(+[WebCache addImageToCache:forURL:forFrame:]):
(+[WebCache removeImageFromCacheForURL:forFrame:]):
Source/WebKit2:
This patch adds a |needsValidation| argument to
ResourceRequest::setCachePartition() setter so that the caller can
indicate that the partition name is valid (because it was already
processed by partitionName() before). Use this new argument in
ArgumentCoder<ResourceRequest>::decode() to spent a bit less time
deserializing resource requests.
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ResourceRequest>::decode):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174921 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index 24dd28a..fcb524a 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -1248,7 +1248,7 @@
}
#if ENABLE(CACHE_PARTITIONING)
if (&m_frame.tree().top() != &m_frame)
- request.setCachePartition(m_frame.tree().top().document()->securityOrigin()->cachePartition());
+ request.setDomainForCachePartition(m_frame.tree().top().document()->securityOrigin()->domainForCachePartition());
#endif
addExtraFieldsToRequest(request, newLoadType, true);
if (newLoadType == FrameLoadType::Reload || newLoadType == FrameLoadType::ReloadFromOrigin)