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

Side by Side Diff: third_party/WebKit/Source/core/fetch/FontResource.h

Issue 2453813004: WebFonts cache-aware timeout adaptation (Closed)
Patch Set: rebase, disable cache-aware behavior for font-display: swap, histogram Created 4 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 bool isCORSFailed() const { return m_corsFailed; } 60 bool isCORSFailed() const { return m_corsFailed; }
61 String otsParsingMessage() const { return m_otsParsingMessage; } 61 String otsParsingMessage() const { return m_otsParsingMessage; }
62 62
63 bool ensureCustomFontData(); 63 bool ensureCustomFontData();
64 FontPlatformData platformDataFromCustomData( 64 FontPlatformData platformDataFromCustomData(
65 float size, 65 float size,
66 bool bold, 66 bool bold,
67 bool italic, 67 bool italic,
68 FontOrientation = FontOrientation::Horizontal); 68 FontOrientation = FontOrientation::Horizontal);
69 69
70 void willReloadAfterDiskCacheMiss() override;
71
70 private: 72 private:
71 class FontResourceFactory : public ResourceFactory { 73 class FontResourceFactory : public ResourceFactory {
72 public: 74 public:
73 FontResourceFactory() : ResourceFactory(Resource::Font) {} 75 FontResourceFactory() : ResourceFactory(Resource::Font) {}
74 76
75 Resource* create(const ResourceRequest& request, 77 Resource* create(const ResourceRequest& request,
76 const ResourceLoaderOptions& options, 78 const ResourceLoaderOptions& options,
77 const String& charset) const override { 79 const String& charset) const override {
78 return new FontResource(request, options); 80 return new FontResource(request, options);
79 } 81 }
80 }; 82 };
81 FontResource(const ResourceRequest&, const ResourceLoaderOptions&); 83 FontResource(const ResourceRequest&, const ResourceLoaderOptions&);
82 84
83 void checkNotify() override; 85 void checkNotify() override;
84 void fontLoadShortLimitCallback(TimerBase*); 86 void fontLoadShortLimitCallback(TimerBase*);
85 void fontLoadLongLimitCallback(TimerBase*); 87 void fontLoadLongLimitCallback(TimerBase*);
88 void notifyClientsShortLimitExceeded();
89 void notifyClientsLongLimitExceeded();
86 90
91 // This is used in UMA histograms, should not change order.
87 enum LoadLimitState { 92 enum LoadLimitState {
88 LoadNotStarted, 93 LoadNotStarted,
89 UnderLimit, 94 UnderLimit,
90 ShortLimitExceeded, 95 ShortLimitExceeded,
91 LongLimitExceeded 96 LongLimitExceeded,
97 LoadLimitStateEnumMax
92 }; 98 };
93 99
94 std::unique_ptr<FontCustomPlatformData> m_fontData; 100 std::unique_ptr<FontCustomPlatformData> m_fontData;
95 String m_otsParsingMessage; 101 String m_otsParsingMessage;
96 LoadLimitState m_loadLimitState; 102 LoadLimitState m_loadLimitState;
97 bool m_corsFailed; 103 bool m_corsFailed;
98 Timer<FontResource> m_fontLoadShortLimitTimer; 104 Timer<FontResource> m_fontLoadShortLimitTimer;
99 Timer<FontResource> m_fontLoadLongLimitTimer; 105 Timer<FontResource> m_fontLoadLongLimitTimer;
100 106
101 friend class MemoryCache; 107 friend class MemoryCache;
102 }; 108 };
103 109
104 DEFINE_RESOURCE_TYPE_CASTS(Font); 110 DEFINE_RESOURCE_TYPE_CASTS(Font);
105 111
106 class FontResourceClient : public ResourceClient { 112 class FontResourceClient : public ResourceClient {
107 public: 113 public:
108 ~FontResourceClient() override {} 114 ~FontResourceClient() override {}
109 static bool isExpectedType(ResourceClient* client) { 115 static bool isExpectedType(ResourceClient* client) {
110 return client->getResourceClientType() == FontType; 116 return client->getResourceClientType() == FontType;
111 } 117 }
112 ResourceClientType getResourceClientType() const final { return FontType; } 118 ResourceClientType getResourceClientType() const final { return FontType; }
119
120 // If cache-aware loading is activated, both callbacks will be blocked until
121 // disk cache miss. If called on cache miss, calls to addClient() and
122 // removeClient() is prohibited to prevent race issues regarding current
123 // loading state.
113 virtual void fontLoadShortLimitExceeded(FontResource*) {} 124 virtual void fontLoadShortLimitExceeded(FontResource*) {}
114 virtual void fontLoadLongLimitExceeded(FontResource*) {} 125 virtual void fontLoadLongLimitExceeded(FontResource*) {}
115 }; 126 };
116 127
117 } // namespace blink 128 } // namespace blink
118 129
119 #endif 130 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698