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

Side by Side Diff: third_party/WebKit/Source/core/loader/resource/FontResource.cpp

Issue 2558433002: FontResource: use DCHECKs for confirmed CHECKs (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (m_loadLimitState == ShortLimitExceeded || 98 if (m_loadLimitState == ShortLimitExceeded ||
99 m_loadLimitState == LongLimitExceeded) 99 m_loadLimitState == LongLimitExceeded)
100 static_cast<FontResourceClient*>(c)->fontLoadShortLimitExceeded(this); 100 static_cast<FontResourceClient*>(c)->fontLoadShortLimitExceeded(this);
101 if (m_loadLimitState == LongLimitExceeded) 101 if (m_loadLimitState == LongLimitExceeded)
102 static_cast<FontResourceClient*>(c)->fontLoadLongLimitExceeded(this); 102 static_cast<FontResourceClient*>(c)->fontLoadLongLimitExceeded(this);
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 // TODO(toyoshim): Change following CHECKs to DCHECKs once we confirm these do 108 DCHECK(isLoaded());
109 // not fire. 109 DCHECK(!m_fontLoadShortLimitTimer.isActive());
110 CHECK(isLoaded()); 110 DCHECK(!m_fontLoadLongLimitTimer.isActive());
111 CHECK(!m_fontLoadShortLimitTimer.isActive());
112 CHECK(!m_fontLoadLongLimitTimer.isActive());
113 m_loadLimitState = LoadNotStarted; 111 m_loadLimitState = LoadNotStarted;
114 Resource::setRevalidatingRequest(request); 112 Resource::setRevalidatingRequest(request);
115 } 113 }
116 114
117 void FontResource::startLoadLimitTimers() { 115 void FontResource::startLoadLimitTimers() {
118 // TODO(toyoshim): Change CHECK() to DCHECK() if this can survive on Canary 116 DCHECK(isLoading());
119 // for some days. http://crbug.com/670638
120 CHECK(isLoading());
121 DCHECK_EQ(m_loadLimitState, LoadNotStarted); 117 DCHECK_EQ(m_loadLimitState, LoadNotStarted);
122 m_loadLimitState = UnderLimit; 118 m_loadLimitState = UnderLimit;
123 m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec, 119 m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec,
124 BLINK_FROM_HERE); 120 BLINK_FROM_HERE);
125 m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec, 121 m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec,
126 BLINK_FROM_HERE); 122 BLINK_FROM_HERE);
127 } 123 }
128 124
129 bool FontResource::ensureCustomFontData() { 125 bool FontResource::ensureCustomFontData() {
130 if (!m_fontData && !errorOccurred() && !isLoading()) { 126 if (!m_fontData && !errorOccurred() && !isLoading()) {
(...skipping 13 matching lines...) Expand all
144 FontPlatformData FontResource::platformDataFromCustomData( 140 FontPlatformData FontResource::platformDataFromCustomData(
145 float size, 141 float size,
146 bool bold, 142 bool bold,
147 bool italic, 143 bool italic,
148 FontOrientation orientation) { 144 FontOrientation orientation) {
149 DCHECK(m_fontData); 145 DCHECK(m_fontData);
150 return m_fontData->fontPlatformData(size, bold, italic, orientation); 146 return m_fontData->fontPlatformData(size, bold, italic, orientation);
151 } 147 }
152 148
153 void FontResource::fontLoadShortLimitCallback(TimerBase*) { 149 void FontResource::fontLoadShortLimitCallback(TimerBase*) {
154 // TODO(toyoshim): Change CHECK() to DCHECK() and remove if(!isLoading()) if 150 DCHECK(isLoading());
155 // this can survive on Canary for some days. http://crbug.com/670638
156 CHECK(isLoading());
157 if (!isLoading())
158 return;
159 DCHECK_EQ(m_loadLimitState, UnderLimit); 151 DCHECK_EQ(m_loadLimitState, UnderLimit);
160 m_loadLimitState = ShortLimitExceeded; 152 m_loadLimitState = ShortLimitExceeded;
161 ResourceClientWalker<FontResourceClient> walker(clients()); 153 ResourceClientWalker<FontResourceClient> walker(clients());
162 while (FontResourceClient* client = walker.next()) 154 while (FontResourceClient* client = walker.next())
163 client->fontLoadShortLimitExceeded(this); 155 client->fontLoadShortLimitExceeded(this);
164 } 156 }
165 157
166 void FontResource::fontLoadLongLimitCallback(TimerBase*) { 158 void FontResource::fontLoadLongLimitCallback(TimerBase*) {
167 // TODO(toyoshim): Change CHECK() to DCHECK() and remove if(!isLoading()) if 159 DCHECK(isLoading());
168 // this can survive on Canary for some days. http://crbug.com/670638
169 CHECK(isLoading());
170 if (!isLoading())
171 return;
172 DCHECK_EQ(m_loadLimitState, ShortLimitExceeded); 160 DCHECK_EQ(m_loadLimitState, ShortLimitExceeded);
173 m_loadLimitState = LongLimitExceeded; 161 m_loadLimitState = LongLimitExceeded;
174 ResourceClientWalker<FontResourceClient> walker(clients()); 162 ResourceClientWalker<FontResourceClient> walker(clients());
175 while (FontResourceClient* client = walker.next()) 163 while (FontResourceClient* client = walker.next())
176 client->fontLoadLongLimitExceeded(this); 164 client->fontLoadLongLimitExceeded(this);
177 } 165 }
178 166
179 void FontResource::allClientsAndObserversRemoved() { 167 void FontResource::allClientsAndObserversRemoved() {
180 m_fontData.reset(); 168 m_fontData.reset();
181 Resource::allClientsAndObserversRemoved(); 169 Resource::allClientsAndObserversRemoved();
(...skipping 23 matching lines...) Expand all
205 Resource::onMemoryDump(level, memoryDump); 193 Resource::onMemoryDump(level, memoryDump);
206 if (!m_fontData) 194 if (!m_fontData)
207 return; 195 return;
208 const String name = getMemoryDumpName() + "/decoded_webfont"; 196 const String name = getMemoryDumpName() + "/decoded_webfont";
209 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(name); 197 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(name);
210 dump->addScalar("size", "bytes", m_fontData->dataSize()); 198 dump->addScalar("size", "bytes", m_fontData->dataSize());
211 memoryDump->addSuballocation(dump->guid(), "malloc"); 199 memoryDump->addSuballocation(dump->guid(), "malloc");
212 } 200 }
213 201
214 } // namespace blink 202 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698