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

Unified Diff: third_party/WebKit/Source/core/css/FontLoader.cpp

Issue 1667843003: Make Resource RefCountedWillBeGarbageCollectedFinalized, attempt #2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + address review comments Created 4 years, 10 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/css/FontLoader.cpp
diff --git a/third_party/WebKit/Source/core/css/FontLoader.cpp b/third_party/WebKit/Source/core/css/FontLoader.cpp
index fda44d737d53b471deeda4749ceb542c028b5844..54958908a78e8a7a943fb99880e186fb60dce70c 100644
--- a/third_party/WebKit/Source/core/css/FontLoader.cpp
+++ b/third_party/WebKit/Source/core/css/FontLoader.cpp
@@ -12,16 +12,29 @@
namespace blink {
-struct FontLoader::FontToLoad {
+struct FontLoader::FontToLoad : public NoBaseWillBeGarbageCollectedFinalized<FontLoader::FontToLoad> {
public:
- static PassOwnPtr<FontToLoad> create(FontResource* fontResource, Document& document)
+ static PassOwnPtrWillBeRawPtr<FontToLoad> create(FontResource* fontResource, Document& document)
{
- return adoptPtr(new FontToLoad(fontResource, document));
+ return adoptPtrWillBeNoop(new FontToLoad(fontResource, document));
}
- ResourcePtr<FontResource> fontResource;
+ virtual ~FontToLoad()
+ {
+ ASSERT(!fontResource);
+ }
+
+ RefPtrWillBeMember<FontResource> fontResource;
OwnPtr<IncrementLoadEventDelayCount> delay;
+ void dispose()
+ {
+ fontResource = nullptr;
+ delay.clear();
+ }
+
+ DEFINE_INLINE_TRACE() { visitor->trace(fontResource); }
+
private:
FontToLoad(FontResource* resource, Document& document)
: fontResource(resource)
@@ -78,6 +91,7 @@ void FontLoader::loadPendingFonts()
fontToLoad->fontResource->beginLoadIfNeeded(m_document->fetcher());
else
fontToLoad->fontResource->error(Resource::LoadError);
+ fontToLoad->dispose();
}
// When the local fontsToBeginLoading vector goes out of scope it will
@@ -119,13 +133,16 @@ void FontLoader::clearDocumentAndFontSelector()
void FontLoader::clearPendingFonts()
{
- for (const auto& fontToLoad : m_fontsToBeginLoading)
+ for (const auto& fontToLoad : m_fontsToBeginLoading) {
fontToLoad->fontResource->didUnscheduleLoad();
+ fontToLoad->dispose();
+ }
m_fontsToBeginLoading.clear();
}
DEFINE_TRACE(FontLoader)
{
+ visitor->trace(m_fontsToBeginLoading);
visitor->trace(m_document);
visitor->trace(m_fontSelector);
}
« no previous file with comments | « third_party/WebKit/Source/core/css/FontLoader.h ('k') | third_party/WebKit/Source/core/css/RemoteFontFaceSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698