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

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

Issue 1802123002: Unify Resource loading status tracking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 static PassRefPtrWillBeRawPtr<FontResource> fetch(FetchRequest&, ResourceFet cher*); 47 static PassRefPtrWillBeRawPtr<FontResource> fetch(FetchRequest&, ResourceFet cher*);
48 ~FontResource() override; 48 ~FontResource() override;
49 49
50 void load(ResourceFetcher*, const ResourceLoaderOptions&) override; 50 void load(ResourceFetcher*, const ResourceLoaderOptions&) override;
51 51
52 void didAddClient(ResourceClient*) override; 52 void didAddClient(ResourceClient*) override;
53 53
54 void allClientsRemoved() override; 54 void allClientsRemoved() override;
55 void beginLoadIfNeeded(ResourceFetcher* dl); 55 void beginLoadIfNeeded(ResourceFetcher* dl);
56 bool stillNeedsLoad() const override { return m_state < LoadInitiated; }
57 56
58 bool loadScheduled() const { return m_state != Unloaded; } 57 bool loadScheduled() const { return getStatus() == LoadStartScheduled; }
59 void didScheduleLoad(); 58 void didScheduleLoad();
60 void didUnscheduleLoad(); 59 void didUnscheduleLoad();
61 60
62 void setCORSFailed() override { m_corsFailed = true; } 61 void setCORSFailed() override { m_corsFailed = true; }
63 bool isCORSFailed() const { return m_corsFailed; } 62 bool isCORSFailed() const { return m_corsFailed; }
64 String otsParsingMessage() const { return m_otsParsingMessage; } 63 String otsParsingMessage() const { return m_otsParsingMessage; }
65 64
66 bool ensureCustomFontData(); 65 bool ensureCustomFontData();
67 FontPlatformData platformDataFromCustomData(float size, bool bold, bool ital ic, FontOrientation = FontOrientation::Horizontal); 66 FontPlatformData platformDataFromCustomData(float size, bool bold, bool ital ic, FontOrientation = FontOrientation::Horizontal);
68 67
(...skipping 10 matching lines...) Expand all
79 { 78 {
80 return adoptRefWillBeNoop(new FontResource(request)); 79 return adoptRefWillBeNoop(new FontResource(request));
81 } 80 }
82 }; 81 };
83 FontResource(const ResourceRequest&); 82 FontResource(const ResourceRequest&);
84 83
85 void checkNotify() override; 84 void checkNotify() override;
86 void fontLoadShortLimitCallback(Timer<FontResource>*); 85 void fontLoadShortLimitCallback(Timer<FontResource>*);
87 void fontLoadLongLimitCallback(Timer<FontResource>*); 86 void fontLoadLongLimitCallback(Timer<FontResource>*);
88 87
89 enum State { Unloaded, LoadScheduled, LoadInitiated, ShortLimitExceeded, Lon gLimitExceeded }; 88 enum LoadLimitState { UnderLimit, ShortLimitExceeded, LongLimitExceeded };
90 89
91 OwnPtr<FontCustomPlatformData> m_fontData; 90 OwnPtr<FontCustomPlatformData> m_fontData;
92 String m_otsParsingMessage; 91 String m_otsParsingMessage;
93 State m_state; 92 LoadLimitState m_loadLimitState;
94 bool m_corsFailed; 93 bool m_corsFailed;
95 Timer<FontResource> m_fontLoadShortLimitTimer; 94 Timer<FontResource> m_fontLoadShortLimitTimer;
96 Timer<FontResource> m_fontLoadLongLimitTimer; 95 Timer<FontResource> m_fontLoadLongLimitTimer;
97 96
98 friend class MemoryCache; 97 friend class MemoryCache;
99 }; 98 };
100 99
101 DEFINE_RESOURCE_TYPE_CASTS(Font); 100 DEFINE_RESOURCE_TYPE_CASTS(Font);
102 101
103 class FontResourceClient : public ResourceClient { 102 class FontResourceClient : public ResourceClient {
104 public: 103 public:
105 ~FontResourceClient() override {} 104 ~FontResourceClient() override {}
106 static bool isExpectedType(ResourceClient* client) { return client->getResou rceClientType() == FontType; } 105 static bool isExpectedType(ResourceClient* client) { return client->getResou rceClientType() == FontType; }
107 ResourceClientType getResourceClientType() const final { return FontType; } 106 ResourceClientType getResourceClientType() const final { return FontType; }
108 virtual void fontLoaded(FontResource*) {} 107 virtual void fontLoaded(FontResource*) {}
109 virtual void didStartFontLoad(FontResource*) {} 108 virtual void didStartFontLoad(FontResource*) {}
110 virtual void fontLoadShortLimitExceeded(FontResource*) {} 109 virtual void fontLoadShortLimitExceeded(FontResource*) {}
111 virtual void fontLoadLongLimitExceeded(FontResource*) {} 110 virtual void fontLoadLongLimitExceeded(FontResource*) {}
112 }; 111 };
113 112
114 } // namespace blink 113 } // namespace blink
115 114
116 #endif 115 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698