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

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

Issue 2390583002: [WIP] WebFonts cache-aware timeout adaption (Closed)
Patch Set: revise RemoteFontFaceSource cache-aware logic, fix Created 4 years, 2 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 /* 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 28 matching lines...) Expand all
39 class FetchRequest; 39 class FetchRequest;
40 class ResourceFetcher; 40 class ResourceFetcher;
41 class FontPlatformData; 41 class FontPlatformData;
42 class FontCustomPlatformData; 42 class FontCustomPlatformData;
43 class FontResourceClient; 43 class FontResourceClient;
44 44
45 class CORE_EXPORT FontResource final : public Resource { 45 class CORE_EXPORT FontResource final : public Resource {
46 public: 46 public:
47 using ClientType = FontResourceClient; 47 using ClientType = FontResourceClient;
48 48
49 enum LoadLimitState { UnderLimit, ShortLimitExceeded, LongLimitExceeded };
50
49 static FontResource* fetch(FetchRequest&, ResourceFetcher*); 51 static FontResource* fetch(FetchRequest&, ResourceFetcher*);
50 ~FontResource() override; 52 ~FontResource() override;
51 53
52 void didAddClient(ResourceClient*) override; 54 void didAddClient(ResourceClient*) override;
53 55
54 void setRevalidatingRequest(const ResourceRequest&) override; 56 void setRevalidatingRequest(const ResourceRequest&) override;
55 57
56 void allClientsAndObserversRemoved() override; 58 void allClientsAndObserversRemoved() override;
57 void startLoadLimitTimersIfNeeded(); 59 void startLoadLimitTimersIfNeeded();
58 60
59 void setCORSFailed() override { m_corsFailed = true; } 61 void setCORSFailed() override { m_corsFailed = true; }
60 bool isCORSFailed() const { return m_corsFailed; } 62 bool isCORSFailed() const { return m_corsFailed; }
61 String otsParsingMessage() const { return m_otsParsingMessage; } 63 String otsParsingMessage() const { return m_otsParsingMessage; }
62 64
63 bool ensureCustomFontData(); 65 bool ensureCustomFontData();
64 FontPlatformData platformDataFromCustomData( 66 FontPlatformData platformDataFromCustomData(
65 float size, 67 float size,
66 bool bold, 68 bool bold,
67 bool italic, 69 bool italic,
68 FontOrientation = FontOrientation::Horizontal); 70 FontOrientation = FontOrientation::Horizontal);
69 71
72 LoadLimitState loadLimitState() const { return m_loadLimitState; }
73
74 void willReloadAfterDiskCacheMiss() override;
75
70 private: 76 private:
71 class FontResourceFactory : public ResourceFactory { 77 class FontResourceFactory : public ResourceFactory {
72 public: 78 public:
73 FontResourceFactory() : ResourceFactory(Resource::Font) {} 79 FontResourceFactory() : ResourceFactory(Resource::Font) {}
74 80
75 Resource* create(const ResourceRequest& request, 81 Resource* create(const ResourceRequest& request,
76 const ResourceLoaderOptions& options, 82 const ResourceLoaderOptions& options,
77 const String& charset) const override { 83 const String& charset) const override {
78 return new FontResource(request, options); 84 return new FontResource(request, options);
79 } 85 }
80 }; 86 };
81 FontResource(const ResourceRequest&, const ResourceLoaderOptions&); 87 FontResource(const ResourceRequest&, const ResourceLoaderOptions&);
82 88
83 void checkNotify() override; 89 void checkNotify() override;
84 void fontLoadShortLimitCallback(TimerBase*); 90 void fontLoadShortLimitCallback(TimerBase*);
85 void fontLoadLongLimitCallback(TimerBase*); 91 void fontLoadLongLimitCallback(TimerBase*);
86 92
87 enum LoadLimitState { UnderLimit, ShortLimitExceeded, LongLimitExceeded };
88
89 std::unique_ptr<FontCustomPlatformData> m_fontData; 93 std::unique_ptr<FontCustomPlatformData> m_fontData;
90 String m_otsParsingMessage; 94 String m_otsParsingMessage;
91 LoadLimitState m_loadLimitState; 95 LoadLimitState m_loadLimitState;
92 bool m_corsFailed; 96 bool m_corsFailed;
93 Timer<FontResource> m_fontLoadShortLimitTimer; 97 Timer<FontResource> m_fontLoadShortLimitTimer;
94 Timer<FontResource> m_fontLoadLongLimitTimer; 98 Timer<FontResource> m_fontLoadLongLimitTimer;
95 99
96 friend class MemoryCache; 100 friend class MemoryCache;
97 }; 101 };
98 102
99 DEFINE_RESOURCE_TYPE_CASTS(Font); 103 DEFINE_RESOURCE_TYPE_CASTS(Font);
100 104
101 class FontResourceClient : public ResourceClient { 105 class FontResourceClient : public ResourceClient {
102 public: 106 public:
103 ~FontResourceClient() override {} 107 ~FontResourceClient() override {}
104 static bool isExpectedType(ResourceClient* client) { 108 static bool isExpectedType(ResourceClient* client) {
105 return client->getResourceClientType() == FontType; 109 return client->getResourceClientType() == FontType;
106 } 110 }
107 ResourceClientType getResourceClientType() const final { return FontType; } 111 ResourceClientType getResourceClientType() const final { return FontType; }
108 virtual void fontLoadShortLimitExceeded(FontResource*) {} 112 virtual void fontLoadShortLimitExceeded(FontResource*) {}
109 virtual void fontLoadLongLimitExceeded(FontResource*) {} 113 virtual void fontLoadLongLimitExceeded(FontResource*) {}
114 virtual void willReloadAfterDiskCacheMiss(const FontResource*) {}
110 }; 115 };
111 116
112 } // namespace blink 117 } // namespace blink
113 118
114 #endif 119 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698