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

Side by Side Diff: third_party/WebKit/Source/core/css/RemoteFontFaceSource.h

Issue 2289303004: WebFonts: measure network loading time (Closed)
Patch Set: minor fix Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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 "wtf/Allocator.h" 10 #include "wtf/Allocator.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class CSSFontSelector; 14 class CSSFontSelector;
15 15
16 enum FontDisplay { 16 enum FontDisplay {
17 FontDisplayAuto, 17 FontDisplayAuto,
18 FontDisplayBlock, 18 FontDisplayBlock,
19 FontDisplaySwap, 19 FontDisplaySwap,
20 FontDisplayFallback, 20 FontDisplayFallback,
21 FontDisplayOptional, 21 FontDisplayOptional,
22 FontDisplayEnumMax 22 FontDisplayEnumMax
23 }; 23 };
24 24
25 class RemoteFontFaceSource final : public CSSFontFaceSource, public FontResource Client { 25 class RemoteFontFaceSource final : public CSSFontFaceSource, public FontResource Client {
26 USING_PRE_FINALIZER(RemoteFontFaceSource, dispose); 26 USING_PRE_FINALIZER(RemoteFontFaceSource, dispose);
27 USING_GARBAGE_COLLECTED_MIXIN(RemoteFontFaceSource); 27 USING_GARBAGE_COLLECTED_MIXIN(RemoteFontFaceSource);
28 public: 28 public:
29 enum DisplayPeriod { BlockPeriod, SwapPeriod, FailurePeriod }; 29 enum DisplayPeriod { BlockPeriod, SwapPeriod, FailurePeriod };
30 enum DataSource { FromUnknown, FromDataURL, FromMemoryCache, FromDiskCache, FromNetwork };
30 31
31 explicit RemoteFontFaceSource(FontResource*, CSSFontSelector*, FontDisplay); 32 explicit RemoteFontFaceSource(FontResource*, CSSFontSelector*, FontDisplay);
32 ~RemoteFontFaceSource() override; 33 ~RemoteFontFaceSource() override;
33 void dispose(); 34 void dispose();
34 35
35 bool isLoading() const override; 36 bool isLoading() const override;
36 bool isLoaded() const override; 37 bool isLoaded() const override;
37 bool isValid() const override; 38 bool isValid() const override;
38 DisplayPeriod getDisplayPeriod() const { return m_period; } 39 DisplayPeriod getDisplayPeriod() const { return m_period; }
39 40
(...skipping 17 matching lines...) Expand all
57 PassRefPtr<SimpleFontData> createLoadingFallbackFontData(const FontDescripti on&); 58 PassRefPtr<SimpleFontData> createLoadingFallbackFontData(const FontDescripti on&);
58 void pruneTable(); 59 void pruneTable();
59 60
60 private: 61 private:
61 class FontLoadHistograms { 62 class FontLoadHistograms {
62 DISALLOW_NEW(); 63 DISALLOW_NEW();
63 public: 64 public:
64 FontLoadHistograms() : m_loadStartTime(0), m_blankPaintTime(0), m_isLong LimitExceeded(false) { } 65 FontLoadHistograms() : m_loadStartTime(0), m_blankPaintTime(0), m_isLong LimitExceeded(false) { }
65 void loadStarted(); 66 void loadStarted();
66 void fallbackFontPainted(DisplayPeriod); 67 void fallbackFontPainted(DisplayPeriod);
67 void fontLoaded(bool isInterventionTriggered, bool isLoadedFromNetwork); 68 void fontLoaded(bool isInterventionTriggered, DataSource);
68 void longLimitExceeded(bool isInterventionTriggered); 69 void longLimitExceeded(bool isInterventionTriggered, DataSource);
69 void recordFallbackTime(const FontResource*); 70 void recordFallbackTime(const FontResource*);
70 void recordRemoteFont(const FontResource*, bool isLoadedFromMemoryCache) ; 71 void recordRemoteFont(const FontResource*, DataSource);
71 bool hadBlankText() { return m_blankPaintTime; } 72 bool hadBlankText() { return m_blankPaintTime; }
72 private: 73 private:
73 void recordLoadTimeHistogram(const FontResource*, int duration); 74 void recordLoadTimeHistogram(const FontResource*, int duration, DataSour ce);
74 void recordInterventionResult(bool isTriggered, bool isLoadedFromNetwork ); 75 void recordInterventionResult(bool isTriggered, DataSource);
75 double m_loadStartTime; 76 double m_loadStartTime;
76 double m_blankPaintTime; 77 double m_blankPaintTime;
77 bool m_isLongLimitExceeded; 78 bool m_isLongLimitExceeded;
78 }; 79 };
79 80
80 void switchToSwapPeriod(); 81 void switchToSwapPeriod();
81 void switchToFailurePeriod(); 82 void switchToFailurePeriod();
82 83
83 Member<FontResource> m_font; 84 Member<FontResource> m_font;
84 Member<CSSFontSelector> m_fontSelector; 85 Member<CSSFontSelector> m_fontSelector;
85 const FontDisplay m_display; 86 const FontDisplay m_display;
86 DisplayPeriod m_period; 87 DisplayPeriod m_period;
87 FontLoadHistograms m_histograms; 88 FontLoadHistograms m_histograms;
88 bool m_isInterventionTriggered; 89 bool m_isInterventionTriggered;
89 bool m_isLoadedFromMemoryCache; 90 DataSource m_dataSource;
90 }; 91 };
91 92
92 } // namespace blink 93 } // namespace blink
93 94
94 #endif 95 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698