1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef FontLoader_h 6 #define FontLoader_h 7 8 #include "core/fetch/ResourceLoader.h" 9 #include "core/fetch/ResourcePtr.h" 10 #include "platform/Timer.h" 11 #include "platform/heap/Handle.h" 12 #include "wtf/Vector.h" 13 14 namespace blink { 15 16 class CSSFontSelector; 17 class FontResource; 18 19 class FontLoader : public RefCountedWillBeGarbageCollectedFinalized<FontLoader> { 20 public: create(CSSFontSelector * fontSelector,ResourceFetcher * fetcher)21 static PassRefPtrWillBeRawPtr<FontLoader> create(CSSFontSelector* fontSelector, ResourceFetcher* fetcher) 22 { 23 return adoptRefWillBeNoop(new FontLoader(fontSelector, fetcher)); 24 } 25 ~FontLoader(); 26 27 void addFontToBeginLoading(FontResource*); 28 void loadPendingFonts(); 29 void fontFaceInvalidated(); 30 31 #if !ENABLE(OILPAN) 32 void clearResourceFetcherAndFontSelector(); 33 #endif 34 35 void trace(Visitor*); 36 37 private: 38 FontLoader(CSSFontSelector*, ResourceFetcher*); 39 void beginLoadTimerFired(Timer<FontLoader>*); 40 void clearPendingFonts(); 41 42 Timer<FontLoader> m_beginLoadingTimer; 43 44 typedef Vector<std::pair<ResourcePtr<FontResource>, ResourceLoader::RequestCountTracker> > FontsToLoadVector; 45 FontsToLoadVector m_fontsToBeginLoading; 46 RawPtrWillBeMember<CSSFontSelector> m_fontSelector; 47 RawPtrWillBeWeakMember<ResourceFetcher> m_resourceFetcher; 48 }; 49 50 } // namespace blink 51 52 #endif // FontLoader_h 53