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

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorResourceAgent.cpp

Issue 1807323002: [WeakMemoryCache 1a] Make Reference from Inspector to Resource weak, remove removedFromMemoryCache() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove some comments 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
Index: third_party/WebKit/Source/core/inspector/InspectorResourceAgent.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorResourceAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorResourceAgent.cpp
index e1ddb5588dc6f4207fd02cb1937250ef7f7babe2..473835c7598d44adbef87916c615ff6dc2ecbf91 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorResourceAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorResourceAgent.cpp
@@ -569,12 +569,11 @@ void InspectorResourceAgent::didReceiveResourceResponse(LocalFrame* frame, unsig
if (type == InspectorPageAgent::DocumentResource && loader && loader->substituteData().isValid())
return;
- // It's only safe to reference a Resource in m_resourcesData if it's in the
- // cache at this point. Resources are added to NetworkResourcesData here
- // and removed in removedResourceFromMemoryCache(), so if the Resource isn't
- // in the cache here, NetworkResourceData's strong reference to the
- // Resource will keep it alive indefinitely.
- if (cachedResource && memoryCache()->contains(cachedResource))
+ // Resources are added to NetworkResourcesData as a WeakMember here and
+ // removed in willDestroyResource() called in the prefinalizer of Resource.
+ // Because NetworkResourceData retains weak references only, it
+ // doesn't affect Resource lifetime.
+ if (cachedResource)
m_resourcesData->addResource(requestId, cachedResource);
String frameId = IdentifiersFactory::frameId(frame);
String loaderId = loader ? IdentifiersFactory::loaderId(loader) : "";
@@ -778,7 +777,7 @@ void InspectorResourceAgent::didFinishEventSourceRequest(ThreadableLoaderClient*
clearPendingRequestData();
}
-void InspectorResourceAgent::removedResourceFromMemoryCache(Resource* cachedResource)
+void InspectorResourceAgent::willDestroyResource(Resource* cachedResource)
{
// Mark loaded resources or resources without the buffer as loaded.
if (cachedResource->isLoaded() || !cachedResource->resourceBuffer()) {

Powered by Google App Engine
This is Rietveld 408576698