| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Torch Mobile, Inc. | 3 * Copyright (C) 2009 Torch Mobile, Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void FontResource::startLoadLimitTimers() { | 124 void FontResource::startLoadLimitTimers() { |
| 125 DCHECK(isLoading()); | 125 DCHECK(isLoading()); |
| 126 DCHECK_EQ(m_loadLimitState, LoadNotStarted); | 126 DCHECK_EQ(m_loadLimitState, LoadNotStarted); |
| 127 m_loadLimitState = UnderLimit; | 127 m_loadLimitState = UnderLimit; |
| 128 m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec, | 128 m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec, |
| 129 BLINK_FROM_HERE); | 129 BLINK_FROM_HERE); |
| 130 m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec, | 130 m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec, |
| 131 BLINK_FROM_HERE); | 131 BLINK_FROM_HERE); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool FontResource::ensureCustomFontData() { | 134 PassRefPtr<FontCustomPlatformData> FontResource::getCustomFontData() { |
| 135 if (!m_fontData && !errorOccurred() && !isLoading()) { | 135 if (!m_fontData && !errorOccurred() && !isLoading()) { |
| 136 if (data()) | 136 if (data()) |
| 137 m_fontData = FontCustomPlatformData::create(data(), m_otsParsingMessage); | 137 m_fontData = FontCustomPlatformData::create(data(), m_otsParsingMessage); |
| 138 | 138 |
| 139 if (m_fontData) { | 139 if (m_fontData) { |
| 140 recordPackageFormatHistogram(packageFormatOf(data())); | 140 recordPackageFormatHistogram(packageFormatOf(data())); |
| 141 } else { | 141 } else { |
| 142 setStatus(ResourceStatus::DecodeError); | 142 setStatus(ResourceStatus::DecodeError); |
| 143 recordPackageFormatHistogram(PackageFormatUnknown); | 143 recordPackageFormatHistogram(PackageFormatUnknown); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 return m_fontData.get(); | 146 return m_fontData; |
| 147 } | |
| 148 | |
| 149 FontPlatformData FontResource::platformDataFromCustomData( | |
| 150 float size, | |
| 151 bool bold, | |
| 152 bool italic, | |
| 153 FontOrientation orientation, | |
| 154 FontVariationSettings* fontVariationSettings) { | |
| 155 DCHECK(m_fontData); | |
| 156 return m_fontData->fontPlatformData(size, bold, italic, orientation, | |
| 157 fontVariationSettings); | |
| 158 } | 147 } |
| 159 | 148 |
| 160 void FontResource::willReloadAfterDiskCacheMiss() { | 149 void FontResource::willReloadAfterDiskCacheMiss() { |
| 161 DCHECK(isLoading()); | 150 DCHECK(isLoading()); |
| 162 DCHECK(loader()->isCacheAwareLoadingActivated()); | 151 DCHECK(loader()->isCacheAwareLoadingActivated()); |
| 163 if (m_loadLimitState == ShortLimitExceeded || | 152 if (m_loadLimitState == ShortLimitExceeded || |
| 164 m_loadLimitState == LongLimitExceeded) { | 153 m_loadLimitState == LongLimitExceeded) { |
| 165 notifyClientsShortLimitExceeded(); | 154 notifyClientsShortLimitExceeded(); |
| 166 } | 155 } |
| 167 if (m_loadLimitState == LongLimitExceeded) | 156 if (m_loadLimitState == LongLimitExceeded) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 192 } |
| 204 | 193 |
| 205 void FontResource::notifyClientsLongLimitExceeded() { | 194 void FontResource::notifyClientsLongLimitExceeded() { |
| 206 ProhibitAddRemoveClientInScope prohibitAddRemoveClient(this); | 195 ProhibitAddRemoveClientInScope prohibitAddRemoveClient(this); |
| 207 ResourceClientWalker<FontResourceClient> walker(clients()); | 196 ResourceClientWalker<FontResourceClient> walker(clients()); |
| 208 while (FontResourceClient* client = walker.next()) | 197 while (FontResourceClient* client = walker.next()) |
| 209 client->fontLoadLongLimitExceeded(this); | 198 client->fontLoadLongLimitExceeded(this); |
| 210 } | 199 } |
| 211 | 200 |
| 212 void FontResource::allClientsAndObserversRemoved() { | 201 void FontResource::allClientsAndObserversRemoved() { |
| 213 m_fontData.reset(); | 202 m_fontData.clear(); |
| 214 Resource::allClientsAndObserversRemoved(); | 203 Resource::allClientsAndObserversRemoved(); |
| 215 } | 204 } |
| 216 | 205 |
| 217 void FontResource::checkNotify() { | 206 void FontResource::checkNotify() { |
| 218 m_fontLoadShortLimitTimer.stop(); | 207 m_fontLoadShortLimitTimer.stop(); |
| 219 m_fontLoadLongLimitTimer.stop(); | 208 m_fontLoadLongLimitTimer.stop(); |
| 220 | 209 |
| 221 Resource::checkNotify(); | 210 Resource::checkNotify(); |
| 222 } | 211 } |
| 223 | 212 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 238 Resource::onMemoryDump(level, memoryDump); | 227 Resource::onMemoryDump(level, memoryDump); |
| 239 if (!m_fontData) | 228 if (!m_fontData) |
| 240 return; | 229 return; |
| 241 const String name = getMemoryDumpName() + "/decoded_webfont"; | 230 const String name = getMemoryDumpName() + "/decoded_webfont"; |
| 242 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(name); | 231 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(name); |
| 243 dump->addScalar("size", "bytes", m_fontData->dataSize()); | 232 dump->addScalar("size", "bytes", m_fontData->dataSize()); |
| 244 memoryDump->addSuballocation(dump->guid(), "malloc"); | 233 memoryDump->addSuballocation(dump->guid(), "malloc"); |
| 245 } | 234 } |
| 246 | 235 |
| 247 } // namespace blink | 236 } // namespace blink |
| OLD | NEW |