Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Unified Diff: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp

Issue 1955243002: Trim ResourceTimingInfoMap of non-relevant entries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove resources that fail to load also Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
index 89dc1c5f1bd288c7c5af28769e59990a812dc070..7989e4075e9232c8b875e7a2932a71b645731d05 100644
--- a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
@@ -581,10 +581,12 @@ Resource* ResourceFetcher::createResourceForLoading(FetchRequest& request, const
void ResourceFetcher::storeResourceTimingInitiatorInformation(Resource* resource)
{
- if (resource->options().initiatorInfo.name == FetchInitiatorTypeNames::internal)
+ const AtomicString& fetchInitiator = resource->options().initiatorInfo.name;
+ if (fetchInitiator == FetchInitiatorTypeNames::internal)
return;
- OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(resource->options().initiatorInfo.name, monotonicallyIncreasingTime(), resource->getType() == Resource::MainResource);
+ bool isMainResource = resource->getType() == Resource::MainResource;
+ OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(fetchInitiator, monotonicallyIncreasingTime(), isMainResource);
if (resource->isCacheValidator()) {
const AtomicString& timingAllowOrigin = resource->response().httpHeaderField(HTTPNames::Timing_Allow_Origin);
@@ -592,7 +594,7 @@ void ResourceFetcher::storeResourceTimingInitiatorInformation(Resource* resource
info->setOriginalTimingAllowOrigin(timingAllowOrigin);
}
- if (resource->getType() != Resource::MainResource || context().updateTimingInfoForIFrameNavigation(info.get()))
+ if (!isMainResource || context().updateTimingInfoForIFrameNavigation(info.get()))
m_resourceTimingInfoMap.add(resource, info.release());
}
@@ -889,13 +891,11 @@ void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in
{
TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource);
// The ResourceLoader might be in |m_nonBlockingLoaders| for multipart responses.
+ ASSERT(resource);
ASSERT(!(m_loaders && m_loaders->contains(resource->loader())));
- if (resource && resource->response().isHTTP() && resource->response().httpStatusCode() < 400) {
- ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource);
- if (it != m_resourceTimingInfoMap.end()) {
- OwnPtr<ResourceTimingInfo> info = it->value.release();
- m_resourceTimingInfoMap.remove(it);
+ if (OwnPtr<ResourceTimingInfo> info = m_resourceTimingInfoMap.take(resource)) {
+ if (resource->response().isHTTP() && resource->response().httpStatusCode() < 400) {
populateResourceTiming(info.get(), resource);
info->setLoadFinishTime(finishTime);
if (resource->options().requestInitiatorContext == DocumentContext)
@@ -910,6 +910,7 @@ void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr
{
TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource);
removeResourceLoader(resource->loader());
+ m_resourceTimingInfoMap.take(const_cast<Resource*>(resource));
bool isInternalRequest = resource->options().initiatorInfo.name == FetchInitiatorTypeNames::internal;
context().dispatchDidFail(resource->identifier(), error, isInternalRequest);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698