| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 103 } |
| 104 | 104 |
| 105 void FontResource::setRevalidatingRequest(const ResourceRequest& request) { | 105 void FontResource::setRevalidatingRequest(const ResourceRequest& request) { |
| 106 // Reload will use the same object, and needs to reset |m_loadLimitState| | 106 // Reload will use the same object, and needs to reset |m_loadLimitState| |
| 107 // before any didAddClient() is called again. | 107 // before any didAddClient() is called again. |
| 108 m_loadLimitState = LoadNotStarted; | 108 m_loadLimitState = LoadNotStarted; |
| 109 Resource::setRevalidatingRequest(request); | 109 Resource::setRevalidatingRequest(request); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void FontResource::startLoadLimitTimers() { | 112 void FontResource::startLoadLimitTimers() { |
| 113 CHECK(isLoading()); | 113 DCHECK(isLoading()); |
| 114 DCHECK_EQ(m_loadLimitState, LoadNotStarted); | 114 DCHECK_EQ(m_loadLimitState, LoadNotStarted); |
| 115 m_loadLimitState = UnderLimit; | 115 m_loadLimitState = UnderLimit; |
| 116 m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec, | 116 m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec, |
| 117 BLINK_FROM_HERE); | 117 BLINK_FROM_HERE); |
| 118 m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec, | 118 m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec, |
| 119 BLINK_FROM_HERE); | 119 BLINK_FROM_HERE); |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool FontResource::ensureCustomFontData() { | 122 bool FontResource::ensureCustomFontData() { |
| 123 if (!m_fontData && !errorOccurred() && !isLoading()) { | 123 if (!m_fontData && !errorOccurred() && !isLoading()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 137 FontPlatformData FontResource::platformDataFromCustomData( | 137 FontPlatformData FontResource::platformDataFromCustomData( |
| 138 float size, | 138 float size, |
| 139 bool bold, | 139 bool bold, |
| 140 bool italic, | 140 bool italic, |
| 141 FontOrientation orientation) { | 141 FontOrientation orientation) { |
| 142 DCHECK(m_fontData); | 142 DCHECK(m_fontData); |
| 143 return m_fontData->fontPlatformData(size, bold, italic, orientation); | 143 return m_fontData->fontPlatformData(size, bold, italic, orientation); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void FontResource::fontLoadShortLimitCallback(TimerBase*) { | 146 void FontResource::fontLoadShortLimitCallback(TimerBase*) { |
| 147 CHECK(isLoading()); | |
| 148 if (!isLoading()) | 147 if (!isLoading()) |
| 149 return; | 148 return; |
| 150 DCHECK_EQ(m_loadLimitState, UnderLimit); | 149 DCHECK_EQ(m_loadLimitState, UnderLimit); |
| 151 m_loadLimitState = ShortLimitExceeded; | 150 m_loadLimitState = ShortLimitExceeded; |
| 152 ResourceClientWalker<FontResourceClient> walker(clients()); | 151 ResourceClientWalker<FontResourceClient> walker(clients()); |
| 153 while (FontResourceClient* client = walker.next()) | 152 while (FontResourceClient* client = walker.next()) |
| 154 client->fontLoadShortLimitExceeded(this); | 153 client->fontLoadShortLimitExceeded(this); |
| 155 } | 154 } |
| 156 | 155 |
| 157 void FontResource::fontLoadLongLimitCallback(TimerBase*) { | 156 void FontResource::fontLoadLongLimitCallback(TimerBase*) { |
| 158 CHECK(isLoading()); | |
| 159 if (!isLoading()) | 157 if (!isLoading()) |
| 160 return; | 158 return; |
| 161 DCHECK_EQ(m_loadLimitState, ShortLimitExceeded); | 159 DCHECK_EQ(m_loadLimitState, ShortLimitExceeded); |
| 162 m_loadLimitState = LongLimitExceeded; | 160 m_loadLimitState = LongLimitExceeded; |
| 163 ResourceClientWalker<FontResourceClient> walker(clients()); | 161 ResourceClientWalker<FontResourceClient> walker(clients()); |
| 164 while (FontResourceClient* client = walker.next()) | 162 while (FontResourceClient* client = walker.next()) |
| 165 client->fontLoadLongLimitExceeded(this); | 163 client->fontLoadLongLimitExceeded(this); |
| 166 } | 164 } |
| 167 | 165 |
| 168 void FontResource::allClientsAndObserversRemoved() { | 166 void FontResource::allClientsAndObserversRemoved() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 194 Resource::onMemoryDump(level, memoryDump); | 192 Resource::onMemoryDump(level, memoryDump); |
| 195 if (!m_fontData) | 193 if (!m_fontData) |
| 196 return; | 194 return; |
| 197 const String name = getMemoryDumpName() + "/decoded_webfont"; | 195 const String name = getMemoryDumpName() + "/decoded_webfont"; |
| 198 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(name); | 196 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(name); |
| 199 dump->addScalar("size", "bytes", m_fontData->dataSize()); | 197 dump->addScalar("size", "bytes", m_fontData->dataSize()); |
| 200 memoryDump->addSuballocation(dump->guid(), "malloc"); | 198 memoryDump->addSuballocation(dump->guid(), "malloc"); |
| 201 } | 199 } |
| 202 | 200 |
| 203 } // namespace blink | 201 } // namespace blink |
| OLD | NEW |