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

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

Issue 2287483003: Stop ResourceCallback from being an on-heap class (Closed)
Patch Set: fix Created 4 years, 4 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/Resource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/Resource.cpp b/third_party/WebKit/Source/core/fetch/Resource.cpp
index 31065b424de1b0d4ae6081c43870045d0a58e1d1..ca35056b36931d066b15d2287ead0f511db42717 100644
--- a/third_party/WebKit/Source/core/fetch/Resource.cpp
+++ b/third_party/WebKit/Source/core/fetch/Resource.cpp
@@ -226,10 +226,12 @@ void Resource::ServiceWorkerResponseCachedMetadataHandler::sendToPlatform()
}
}
-class Resource::ResourceCallback final : public GarbageCollectedFinalized<ResourceCallback> {
+// This class cannot be on-heap because the first callbackHandler() call
+// instantiates the singleton object while we can call it in the
+// pre-finalization step.
+class Resource::ResourceCallback final {
public:
static ResourceCallback& callbackHandler();
- DECLARE_TRACE();
void schedule(Resource*);
void cancel(Resource*);
bool isScheduled(Resource*) const;
@@ -238,7 +240,7 @@ private:
void runTask();
std::unique_ptr<CancellableTaskFactory> m_callbackTaskFactory;
- HeapHashSet<Member<Resource>> m_resourcesWithPendingClients;
+ HashSet<Persistent<Resource>> m_resourcesWithPendingClients;
};
Resource::ResourceCallback& Resource::ResourceCallback::callbackHandler()
@@ -249,15 +251,10 @@ Resource::ResourceCallback& Resource::ResourceCallback::callbackHandler()
//
// Keep it out of LSan's reach instead.
LEAK_SANITIZER_DISABLED_SCOPE;
- DEFINE_STATIC_LOCAL(ResourceCallback, callbackHandler, (new ResourceCallback));
+ DEFINE_STATIC_LOCAL(ResourceCallback, callbackHandler, ());
return callbackHandler;
}
-DEFINE_TRACE(Resource::ResourceCallback)
-{
- visitor->trace(m_resourcesWithPendingClients);
-}
-
Resource::ResourceCallback::ResourceCallback()
: m_callbackTaskFactory(CancellableTaskFactory::create(this, &ResourceCallback::runTask))
{
« 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