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

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

Issue 2453813004: WebFonts cache-aware timeout adaptation (Closed)
Patch Set: move commment 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
87 enum LoadLimitState { 91 enum LoadLimitState {
88 LoadNotStarted, 92 LoadNotStarted,
89 UnderLimit, 93 UnderLimit,
90 ShortLimitExceeded, 94 ShortLimitExceeded,
91 LongLimitExceeded 95 LongLimitExceeded
92 }; 96 };
93 97
94 std::unique_ptr<FontCustomPlatformData> m_fontData; 98 std::unique_ptr<FontCustomPlatformData> m_fontData;
95 String m_otsParsingMessage; 99 String m_otsParsingMessage;
96 LoadLimitState m_loadLimitState; 100 LoadLimitState m_loadLimitState;
97 bool m_corsFailed; 101 bool m_corsFailed;
98 Timer<FontResource> m_fontLoadShortLimitTimer; 102 Timer<FontResource> m_fontLoadShortLimitTimer;
99 Timer<FontResource> m_fontLoadLongLimitTimer; 103 Timer<FontResource> m_fontLoadLongLimitTimer;
100 104
101 friend class MemoryCache; 105 friend class MemoryCache;
102 }; 106 };
103 107
104 DEFINE_RESOURCE_TYPE_CASTS(Font); 108 DEFINE_RESOURCE_TYPE_CASTS(Font);
105 109
106 class FontResourceClient : public ResourceClient { 110 class FontResourceClient : public ResourceClient {
107 public: 111 public:
108 ~FontResourceClient() override {} 112 ~FontResourceClient() override {}
109 static bool isExpectedType(ResourceClient* client) { 113 static bool isExpectedType(ResourceClient* client) {
110 return client->getResourceClientType() == FontType; 114 return client->getResourceClientType() == FontType;
111 } 115 }
112 ResourceClientType getResourceClientType() const final { return FontType; } 116 ResourceClientType getResourceClientType() const final { return FontType; }
113 virtual void fontLoadShortLimitExceeded(FontResource*) {} 117 virtual void fontLoadShortLimitExceeded(FontResource*) {}
114 virtual void fontLoadLongLimitExceeded(FontResource*) {} 118 virtual void fontLoadLongLimitExceeded(FontResource*) {}
119
120 // Calls to addClient() and removeClient() is forbidden in this callback to
121 // prevent potential race issues.
122 virtual void willReloadAfterDiskCacheMiss(const FontResource*) {}
115 }; 123 };
116 124
117 } // namespace blink 125 } // namespace blink
118 126
119 #endif 127 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698