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

Unified Diff: Source/platform/fonts/FontCache.cpp

Issue 227083006: [Oilpan]: Moving the FontSelector/FontCacheClient, CSSSegmentedFontFace, and FontFaceCache to the o… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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: Source/platform/fonts/FontCache.cpp
diff --git a/Source/platform/fonts/FontCache.cpp b/Source/platform/fonts/FontCache.cpp
index 99fc13b34b1b14c466a790ac9b4c2f6b0e372da0..07626c259eae7bc24d8bc9c4bd1f3d545f714062 100644
--- a/Source/platform/fonts/FontCache.cpp
+++ b/Source/platform/fonts/FontCache.cpp
@@ -243,23 +243,29 @@ void FontCache::purge(PurgeSeverity PurgeSeverity)
purgeFontVerticalDataCache();
}
-static HashSet<FontCacheClient*>* gClients;
+static bool invalidateFontCache = false;
haraken 2014/04/07 14:10:12 invalidateFontCache => fontCacheMapIsInitialized ?
wibling-chromium 2014/04/08 09:35:59 It guards whether we need to invalidate the cache,
-void FontCache::addClient(FontCacheClient* client)
+WillBeHeapHashSet<RawPtrWillBeMember<FontCacheClient> >& fontCacheClients()
{
- if (!gClients)
- gClients = new HashSet<FontCacheClient*>;
+#if ENABLE(OILPAN)
+ DEFINE_STATIC_LOCAL(Persistent<HeapHashSet<Member<FontCacheClient> > >, clients, (new HeapHashSet<Member<FontCacheClient> >()));
haraken 2014/04/07 14:10:12 Shouldn't this be a hash set of weak members? I gu
wibling-chromium 2014/04/08 09:35:59 It is not strictly needed since removeClient is al
+#else
+ DEFINE_STATIC_LOCAL(HashSet<RawPtr<FontCacheClient> >*, clients, (new HashSet<RawPtr<FontCacheClient> >()));
+#endif
+ invalidateFontCache = true;
+ return *clients;
+}
- ASSERT(!gClients->contains(client));
- gClients->add(client);
+void FontCache::addClient(FontCacheClient* client)
+{
+ ASSERT(!fontCacheClients().contains(client));
+ fontCacheClients().add(client);
}
void FontCache::removeClient(FontCacheClient* client)
haraken 2014/04/07 14:10:12 If the FontCacheClients are weak, this method shou
wibling-chromium 2014/04/08 09:35:59 Done.
{
- ASSERT(gClients);
- ASSERT(gClients->contains(client));
-
- gClients->remove(client);
+ ASSERT(fontCacheClients().contains(client));
+ fontCacheClients().remove(client);
}
static unsigned short gGeneration = 0;
@@ -271,7 +277,7 @@ unsigned short FontCache::generation()
void FontCache::invalidate()
{
- if (!gClients) {
+ if (!invalidateFontCache) {
ASSERT(!gFontPlatformDataCache);
return;
}
@@ -283,11 +289,11 @@ void FontCache::invalidate()
gGeneration++;
- Vector<RefPtr<FontCacheClient> > clients;
- size_t numClients = gClients->size();
+ WillBeHeapVector<RefPtrWillBeMember<FontCacheClient> > clients;
+ size_t numClients = fontCacheClients().size();
clients.reserveInitialCapacity(numClients);
- HashSet<FontCacheClient*>::iterator end = gClients->end();
- for (HashSet<FontCacheClient*>::iterator it = gClients->begin(); it != end; ++it)
+ WillBeHeapHashSet<RawPtrWillBeMember<FontCacheClient> >::iterator end = fontCacheClients().end();
+ for (WillBeHeapHashSet<RawPtrWillBeMember<FontCacheClient> >::iterator it = fontCacheClients().begin(); it != end; ++it)
clients.append(*it);
ASSERT(numClients == clients.size());

Powered by Google App Engine
This is Rietveld 408576698