Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // Calls to addClient() and removeClient() is forbidden in this callback to | |
|
Kunihiko Sakamoto
2016/10/31 08:22:46
Is this restriction specific to FontResource? If n
yhirano
2016/10/31 12:44:32
The comment is for FontResourceClient implementers
Shao-Chuan Lee
2016/11/01 08:57:07
Moved comment to FontResourceClient.
| |
| 71 // prevent potential race issues. | |
| 72 void willReloadAfterDiskCacheMiss() override; | |
| 73 | |
| 70 private: | 74 private: |
| 71 class FontResourceFactory : public ResourceFactory { | 75 class FontResourceFactory : public ResourceFactory { |
| 72 public: | 76 public: |
| 73 FontResourceFactory() : ResourceFactory(Resource::Font) {} | 77 FontResourceFactory() : ResourceFactory(Resource::Font) {} |
| 74 | 78 |
| 75 Resource* create(const ResourceRequest& request, | 79 Resource* create(const ResourceRequest& request, |
| 76 const ResourceLoaderOptions& options, | 80 const ResourceLoaderOptions& options, |
| 77 const String& charset) const override { | 81 const String& charset) const override { |
| 78 return new FontResource(request, options); | 82 return new FontResource(request, options); |
| 79 } | 83 } |
| 80 }; | 84 }; |
| 81 FontResource(const ResourceRequest&, const ResourceLoaderOptions&); | 85 FontResource(const ResourceRequest&, const ResourceLoaderOptions&); |
| 82 | 86 |
| 83 void checkNotify() override; | 87 void checkNotify() override; |
| 84 void fontLoadShortLimitCallback(TimerBase*); | 88 void fontLoadShortLimitCallback(TimerBase*); |
| 85 void fontLoadLongLimitCallback(TimerBase*); | 89 void fontLoadLongLimitCallback(TimerBase*); |
| 90 void notifyClientsShortLimitExceeded(); | |
| 91 void notifyClientsLongLimitExceeded(); | |
| 86 | 92 |
| 87 enum LoadLimitState { | 93 enum LoadLimitState { |
| 88 LoadNotStarted, | 94 LoadNotStarted, |
| 89 UnderLimit, | 95 UnderLimit, |
| 90 ShortLimitExceeded, | 96 ShortLimitExceeded, |
| 91 LongLimitExceeded | 97 LongLimitExceeded |
| 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; } |
| 113 virtual void fontLoadShortLimitExceeded(FontResource*) {} | 119 virtual void fontLoadShortLimitExceeded(FontResource*) {} |
|
Kunihiko Sakamoto
2016/10/31 08:22:46
Can you add a comment noting that these callbacks
Kunihiko Sakamoto
2016/11/02 03:46:36
Ping, in case you have missed this comment.
Shao-Chuan Lee
2016/11/07 06:52:47
Done.
| |
| 114 virtual void fontLoadLongLimitExceeded(FontResource*) {} | 120 virtual void fontLoadLongLimitExceeded(FontResource*) {} |
| 121 virtual void willReloadAfterDiskCacheMiss(const FontResource*) {} | |
| 115 }; | 122 }; |
| 116 | 123 |
| 117 } // namespace blink | 124 } // namespace blink |
| 118 | 125 |
| 119 #endif | 126 #endif |
| OLD | NEW |