OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef RemoteFontFaceSource_h | 5 #ifndef RemoteFontFaceSource_h |
6 #define RemoteFontFaceSource_h | 6 #define RemoteFontFaceSource_h |
7 | 7 |
8 #include "core/css/CSSFontFaceSource.h" | 8 #include "core/css/CSSFontFaceSource.h" |
9 #include "core/fetch/FontResource.h" | 9 #include "core/fetch/FontResource.h" |
10 #include "core/fetch/ResourcePtr.h" | 10 #include "core/fetch/ResourcePtr.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class FontLoader; | 14 class FontLoader; |
15 | 15 |
16 class RemoteFontFaceSource : public CSSFontFaceSource, public FontResourceClient
{ | 16 class RemoteFontFaceSource : public CSSFontFaceSource, public FontResourceClient
{ |
17 public: | 17 public: |
18 explicit RemoteFontFaceSource(FontResource*, PassRefPtrWillBeRawPtr<FontLoad
er>); | 18 explicit RemoteFontFaceSource(FontResource*, PassRefPtrWillBeRawPtr<FontLoad
er>); |
19 virtual ~RemoteFontFaceSource(); | 19 virtual ~RemoteFontFaceSource(); |
20 | 20 |
21 virtual FontResource* resource() OVERRIDE { return m_font.get(); } | 21 virtual FontResource* resource() override { return m_font.get(); } |
22 virtual bool isLoading() const OVERRIDE; | 22 virtual bool isLoading() const override; |
23 virtual bool isLoaded() const OVERRIDE; | 23 virtual bool isLoaded() const override; |
24 virtual bool isValid() const OVERRIDE; | 24 virtual bool isValid() const override; |
25 | 25 |
26 void beginLoadIfNeeded() OVERRIDE; | 26 void beginLoadIfNeeded() override; |
27 virtual bool ensureFontData(); | 27 virtual bool ensureFontData(); |
28 | 28 |
29 #if ENABLE(SVG_FONTS) | 29 #if ENABLE(SVG_FONTS) |
30 virtual bool isSVGFontFaceSource() const { return false; } | 30 virtual bool isSVGFontFaceSource() const { return false; } |
31 #endif | 31 #endif |
32 | 32 |
33 virtual void didStartFontLoad(FontResource*) OVERRIDE; | 33 virtual void didStartFontLoad(FontResource*) override; |
34 virtual void fontLoaded(FontResource*) OVERRIDE; | 34 virtual void fontLoaded(FontResource*) override; |
35 virtual void fontLoadWaitLimitExceeded(FontResource*) OVERRIDE; | 35 virtual void fontLoadWaitLimitExceeded(FontResource*) override; |
36 | 36 |
37 // For UMA reporting | 37 // For UMA reporting |
38 virtual bool hadBlankText() OVERRIDE { return m_histograms.hadBlankText(); } | 38 virtual bool hadBlankText() override { return m_histograms.hadBlankText(); } |
39 void paintRequested() { m_histograms.fallbackFontPainted(); } | 39 void paintRequested() { m_histograms.fallbackFontPainted(); } |
40 | 40 |
41 virtual void trace(Visitor*) OVERRIDE; | 41 virtual void trace(Visitor*) override; |
42 | 42 |
43 protected: | 43 protected: |
44 virtual PassRefPtr<SimpleFontData> createFontData(const FontDescription&) OV
ERRIDE; | 44 virtual PassRefPtr<SimpleFontData> createFontData(const FontDescription&) ov
erride; |
45 PassRefPtr<SimpleFontData> createLoadingFallbackFontData(const FontDescripti
on&); | 45 PassRefPtr<SimpleFontData> createLoadingFallbackFontData(const FontDescripti
on&); |
46 void pruneTable(); | 46 void pruneTable(); |
47 | 47 |
48 private: | 48 private: |
49 class FontLoadHistograms { | 49 class FontLoadHistograms { |
50 public: | 50 public: |
51 FontLoadHistograms() : m_loadStartTime(0), m_fallbackPaintTime(0) { } | 51 FontLoadHistograms() : m_loadStartTime(0), m_fallbackPaintTime(0) { } |
52 void loadStarted(); | 52 void loadStarted(); |
53 void fallbackFontPainted(); | 53 void fallbackFontPainted(); |
54 void recordRemoteFont(const FontResource*); | 54 void recordRemoteFont(const FontResource*); |
55 void recordFallbackTime(const FontResource*); | 55 void recordFallbackTime(const FontResource*); |
56 bool hadBlankText() { return m_fallbackPaintTime; } | 56 bool hadBlankText() { return m_fallbackPaintTime; } |
57 private: | 57 private: |
58 const char* histogramName(const FontResource*); | 58 const char* histogramName(const FontResource*); |
59 double m_loadStartTime; | 59 double m_loadStartTime; |
60 double m_fallbackPaintTime; | 60 double m_fallbackPaintTime; |
61 }; | 61 }; |
62 | 62 |
63 ResourcePtr<FontResource> m_font; | 63 ResourcePtr<FontResource> m_font; |
64 RefPtrWillBeMember<FontLoader> m_fontLoader; | 64 RefPtrWillBeMember<FontLoader> m_fontLoader; |
65 FontLoadHistograms m_histograms; | 65 FontLoadHistograms m_histograms; |
66 }; | 66 }; |
67 | 67 |
68 } // namespace blink | 68 } // namespace blink |
69 | 69 |
70 #endif | 70 #endif |
OLD | NEW |