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: https://svn.webkit.org/repository/webkit/trunk@174921
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-10-20 Chris Dumez <cdumez@apple.com>
+
+ ResourceRequest deserialization unnecessarily calls partitionName() on encoded cache partition
+ https://bugs.webkit.org/show_bug.cgi?id=137797
+
+ Reviewed by Darin Adler.
+
+ 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):
+
2014-10-20 Youenn Fablet <youenn.fablet@crf.canon.fr>
Tighten XMLHttpRequest setRequestHeader value check
URL url(URL(), urlString);
ResourceRequest request(url);
#if ENABLE(CACHE_PARTITIONING)
- request.setCachePartition(scriptExecutionContext->topOrigin()->cachePartition());
+ request.setDomainForCachePartition(scriptExecutionContext->topOrigin()->domainForCachePartition());
#endif
MemoryCache::removeRequestFromSessionCaches(scriptExecutionContext, request);
if (!cachedResource) {
ResourceRequest request(url);
#if ENABLE(CACHE_PARTITIONING)
- request.setCachePartition(frame->document()->topOrigin()->cachePartition());
+ request.setDomainForCachePartition(frame->document()->topOrigin()->domainForCachePartition());
#endif
cachedResource = memoryCache()->resourceForRequest(request, frame->page()->sessionID());
}
ResourceRequest request(xhrReplayData->url());
#if ENABLE(CACHE_PARTITIONING)
- request.setCachePartition(m_pageAgent->mainFrame()->document()->topOrigin()->cachePartition());
+ request.setDomainForCachePartition(m_pageAgent->mainFrame()->document()->topOrigin()->domainForCachePartition());
#endif
CachedResource* cachedResource = memoryCache()->resourceForRequest(request, m_pageAgent->page()->sessionID());
}
#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)
ResourceRequest request(subresourceURL);
#if ENABLE(CACHE_PARTITIONING)
- request.setCachePartition(frame->document()->topOrigin()->cachePartition());
+ request.setDomainForCachePartition(frame->document()->topOrigin()->domainForCachePartition());
#endif
CachedResource* cachedResource = memoryCache()->resourceForRequest(request, frame->page()->sessionID());
if (cachedResource) {
URL url = MemoryCache::removeFragmentIdentifierIfNeeded(request.resourceRequest().url());
#if ENABLE(CACHE_PARTITIONING)
- request.mutableResourceRequest().setCachePartition(document()->topOrigin()->cachePartition());
+ request.mutableResourceRequest().setDomainForCachePartition(document()->topOrigin()->domainForCachePartition());
#endif
if (CachedResource* existing = memoryCache()->resourceForRequest(request.resourceRequest(), sessionID())) {
CachedResourceHandle<CachedResource> resource;
#if ENABLE(CACHE_PARTITIONING)
if (document())
- request.mutableResourceRequest().setCachePartition(document()->topOrigin()->cachePartition());
+ request.mutableResourceRequest().setDomainForCachePartition(document()->topOrigin()->domainForCachePartition());
#endif
resource = memoryCache()->resourceForRequest(request.resourceRequest(), sessionID());
return client;
}
-bool MemoryCache::addImageToCache(NativeImagePtr image, const URL& url, const String& cachePartition)
+bool MemoryCache::addImageToCache(NativeImagePtr image, const URL& url, const String& domainForCachePartition)
{
ASSERT(image);
SessionID sessionID = SessionID::defaultSessionID();
- removeImageFromCache(url, cachePartition); // Remove cache entry if it already exists.
+ removeImageFromCache(url, domainForCachePartition); // Remove cache entry if it already exists.
RefPtr<BitmapImage> bitmapImage = BitmapImage::create(image, nullptr);
if (!bitmapImage)
cachedImage->addClient(&dummyCachedImageClient());
cachedImage->setDecodedSize(bitmapImage->decodedSize());
#if ENABLE(CACHE_PARTITIONING)
- cachedImage->resourceRequest().setCachePartition(cachePartition);
+ cachedImage->resourceRequest().setDomainForCachePartition(domainForCachePartition);
#endif
return add(cachedImage.release());
}
-void MemoryCache::removeImageFromCache(const URL& url, const String& cachePartition)
+void MemoryCache::removeImageFromCache(const URL& url, const String& domainForCachePartition)
{
CachedResourceMap& resources = getSessionMap(SessionID::defaultSessionID());
#if ENABLE(CACHE_PARTITIONING)
CachedResource* resource;
if (CachedResourceItem* item = resources.get(url))
- resource = item->get(ResourceRequest::partitionName(cachePartition));
+ resource = item->get(ResourceRequest::partitionName(domainForCachePartition));
else
resource = nullptr;
#else
- UNUSED_PARAM(cachePartition);
+ UNUSED_PARAM(domainForCachePartition);
CachedResource* resource = resources.get(url);
#endif
if (!resource)
#if USE(CG)
// FIXME: Remove the USE(CG) once we either make NativeImagePtr a smart pointer on all platforms or
// remove the usage of CFRetain() in MemoryCache::addImageToCache() so as to make the code platform-independent.
- WEBCORE_EXPORT bool addImageToCache(NativeImagePtr, const URL&, const String& cachePartition);
- WEBCORE_EXPORT void removeImageFromCache(const URL&, const String& cachePartition);
+ WEBCORE_EXPORT bool addImageToCache(NativeImagePtr, const URL&, const String& domainForCachePartition);
+ WEBCORE_EXPORT void removeImageFromCache(const URL&, const String& domainForCachePartition);
#endif
// pruneDead*() - Flush decoded and encoded data from resources not referenced by Web pages.
}
#if ENABLE(CACHE_PARTITIONING)
-String SecurityOrigin::cachePartition() const
+String SecurityOrigin::domainForCachePartition() const
{
if (m_storageBlockingPolicy != BlockThirdPartyStorage)
return String();
void setStorageBlockingPolicy(StorageBlockingPolicy policy) { m_storageBlockingPolicy = policy; }
#if ENABLE(CACHE_PARTITIONING)
- WEBCORE_EXPORT String cachePartition() const;
+ WEBCORE_EXPORT String domainForCachePartition() const;
#endif
bool canAccessDatabase(const SecurityOrigin* topOrigin = 0) const { return canAccessStorage(topOrigin); };
#if ENABLE(CACHE_PARTITIONING)
WEBCORE_EXPORT static String partitionName(const String& domain);
const String& cachePartition() const { return m_cachePartition.isNull() ? emptyString() : m_cachePartition; }
- void setCachePartition(const String& cachePartition) { m_cachePartition = partitionName(cachePartition); }
+ void setCachePartition(const String& cachePartition)
+ {
+ ASSERT(cachePartition == partitionName(cachePartition));
+ m_cachePartition = cachePartition;
+ }
+ void setDomainForCachePartition(const String& domain) { m_cachePartition = partitionName(domain); }
#endif
#if PLATFORM(COCOA) || USE(CFNETWORK)
+2014-10-20 Chris Dumez <cdumez@apple.com>
+
+ ResourceRequest deserialization unnecessarily calls partitionName() on encoded cache partition
+ https://bugs.webkit.org/show_bug.cgi?id=137797
+
+ Reviewed by Darin Adler.
+
+ 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:]):
+
2014-10-20 Andy Estes <aestes@apple.com>
Fix the iOS build.
if (frame)
topOrigin = core(frame)->document()->topOrigin();
#endif
- return WebCore::memoryCache()->addImageToCache(image, url, topOrigin ? topOrigin->cachePartition() : emptyString());
+ return WebCore::memoryCache()->addImageToCache(image, url, topOrigin ? topOrigin->domainForCachePartition() : emptyString());
}
+ (void)removeImageFromCacheForURL:(NSURL *)url
if (frame)
topOrigin = core(frame)->document()->topOrigin();
#endif
- WebCore::memoryCache()->removeImageFromCache(url, topOrigin ? topOrigin->cachePartition() : emptyString());
+ WebCore::memoryCache()->removeImageFromCache(url, topOrigin ? topOrigin->domainForCachePartition() : emptyString());
}
+ (CGImageRef)imageForURL:(NSURL *)url
+2014-10-20 Chris Dumez <cdumez@apple.com>
+
+ ResourceRequest deserialization unnecessarily calls partitionName() on encoded cache partition
+ https://bugs.webkit.org/show_bug.cgi?id=137797
+
+ Reviewed by Darin Adler.
+
+ 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):
+
2014-10-20 Beth Dakin <bdakin@apple.com>
Action menu items should have tags