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

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

Issue 2419753002: Prevent FontResource load limit timers from restarting during loading (Closed)
Patch Set: new LoadLimitState, text-only test 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 using ClientType = FontResourceClient; 47 using ClientType = FontResourceClient;
48 48
49 static FontResource* fetch(FetchRequest&, ResourceFetcher*); 49 static FontResource* fetch(FetchRequest&, ResourceFetcher*);
50 ~FontResource() override; 50 ~FontResource() override;
51 51
52 void didAddClient(ResourceClient*) override; 52 void didAddClient(ResourceClient*) override;
53 53
54 void setRevalidatingRequest(const ResourceRequest&) override; 54 void setRevalidatingRequest(const ResourceRequest&) override;
55 55
56 void allClientsAndObserversRemoved() override; 56 void allClientsAndObserversRemoved() override;
57 void startLoadLimitTimersIfNeeded(); 57 void startLoadLimitTimers();
58 58
59 void setCORSFailed() override { m_corsFailed = true; } 59 void setCORSFailed() override { m_corsFailed = true; }
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 private: 70 private:
71 class FontResourceFactory : public ResourceFactory { 71 class FontResourceFactory : public ResourceFactory {
72 public: 72 public:
73 FontResourceFactory() : ResourceFactory(Resource::Font) {} 73 FontResourceFactory() : ResourceFactory(Resource::Font) {}
74 74
75 Resource* create(const ResourceRequest& request, 75 Resource* create(const ResourceRequest& request,
76 const ResourceLoaderOptions& options, 76 const ResourceLoaderOptions& options,
77 const String& charset) const override { 77 const String& charset) const override {
78 return new FontResource(request, options); 78 return new FontResource(request, options);
79 } 79 }
80 }; 80 };
81 FontResource(const ResourceRequest&, const ResourceLoaderOptions&); 81 FontResource(const ResourceRequest&, const ResourceLoaderOptions&);
82 82
83 void checkNotify() override; 83 void checkNotify() override;
84 void fontLoadShortLimitCallback(TimerBase*); 84 void fontLoadShortLimitCallback(TimerBase*);
85 void fontLoadLongLimitCallback(TimerBase*); 85 void fontLoadLongLimitCallback(TimerBase*);
86 86
87 enum LoadLimitState { UnderLimit, ShortLimitExceeded, LongLimitExceeded }; 87 enum LoadLimitState {
88 LoadNotStarted,
89 UnderLimit,
90 ShortLimitExceeded,
91 LongLimitExceeded
92 };
88 93
89 std::unique_ptr<FontCustomPlatformData> m_fontData; 94 std::unique_ptr<FontCustomPlatformData> m_fontData;
90 String m_otsParsingMessage; 95 String m_otsParsingMessage;
91 LoadLimitState m_loadLimitState; 96 LoadLimitState m_loadLimitState;
92 bool m_corsFailed; 97 bool m_corsFailed;
93 Timer<FontResource> m_fontLoadShortLimitTimer; 98 Timer<FontResource> m_fontLoadShortLimitTimer;
94 Timer<FontResource> m_fontLoadLongLimitTimer; 99 Timer<FontResource> m_fontLoadLongLimitTimer;
95 100
96 friend class MemoryCache; 101 friend class MemoryCache;
97 }; 102 };
98 103
99 DEFINE_RESOURCE_TYPE_CASTS(Font); 104 DEFINE_RESOURCE_TYPE_CASTS(Font);
100 105
101 class FontResourceClient : public ResourceClient { 106 class FontResourceClient : public ResourceClient {
102 public: 107 public:
103 ~FontResourceClient() override {} 108 ~FontResourceClient() override {}
104 static bool isExpectedType(ResourceClient* client) { 109 static bool isExpectedType(ResourceClient* client) {
105 return client->getResourceClientType() == FontType; 110 return client->getResourceClientType() == FontType;
106 } 111 }
107 ResourceClientType getResourceClientType() const final { return FontType; } 112 ResourceClientType getResourceClientType() const final { return FontType; }
108 virtual void fontLoadShortLimitExceeded(FontResource*) {} 113 virtual void fontLoadShortLimitExceeded(FontResource*) {}
109 virtual void fontLoadLongLimitExceeded(FontResource*) {} 114 virtual void fontLoadLongLimitExceeded(FontResource*) {}
110 }; 115 };
111 116
112 } // namespace blink 117 } // namespace blink
113 118
114 #endif 119 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp ('k') | third_party/WebKit/Source/core/fetch/FontResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698