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

Unified Diff: third_party/WebKit/Source/core/fetch/FontResource.cpp

Issue 1829403002: Clean up font loading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Resource_status
Patch Set: Another rebase! Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/FontResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/FontResource.cpp b/third_party/WebKit/Source/core/fetch/FontResource.cpp
index 54a173f3deaeccc1dad10660d14b263a17859a6f..3da24888f599e9e0c5e697921c714d9eb8d5712d 100644
--- a/third_party/WebKit/Source/core/fetch/FontResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/FontResource.cpp
@@ -74,6 +74,9 @@ FontResource* FontResource::fetch(FetchRequest& request, ResourceFetcher* fetche
{
ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone);
request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestContextFont);
+ // Defer the load until the font is actually needed unless this is a preload.
+ if (!request.forPreload())
+ request.setDefer(FetchRequest::DeferredByClient);
return toFontResource(fetcher->requestResource(request, FontResourceFactory()));
}
@@ -90,25 +93,6 @@ FontResource::~FontResource()
{
}
-void FontResource::didScheduleLoad()
-{
- if (getStatus() == NotStarted)
- setStatus(LoadStartScheduled);
-}
-
-void FontResource::didUnscheduleLoad()
-{
- if (getStatus() == LoadStartScheduled)
- setStatus(NotStarted);
-}
-
-void FontResource::load(ResourceFetcher*)
-{
- // Don't load the file yet. Wait for an access before triggering the load.
- if (!m_revalidatingRequest.isNull())
- setStatus(NotStarted);
-}
-
void FontResource::didAddClient(ResourceClient* c)
{
ASSERT(FontResourceClient::isExpectedType(c));
@@ -121,17 +105,13 @@ void FontResource::didAddClient(ResourceClient* c)
static_cast<FontResourceClient*>(c)->fontLoadLongLimitExceeded(this);
}
-void FontResource::beginLoadIfNeeded(ResourceFetcher* dl)
+void FontResource::startLoadLimitTimersIfNeeded()
{
- if (stillNeedsLoad()) {
- Resource::load(dl);
- m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec, BLINK_FROM_HERE);
- m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec, BLINK_FROM_HERE);
-
- ResourceClientWalker<FontResourceClient> walker(m_clients);
- while (FontResourceClient* client = walker.next())
- client->didStartFontLoad(this);
- }
+ ASSERT(!stillNeedsLoad());
+ if (isLoaded() || m_fontLoadLongLimitTimer.isActive())
+ return;
+ m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec, BLINK_FROM_HERE);
+ m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec, BLINK_FROM_HERE);
}
bool FontResource::ensureCustomFontData()
« no previous file with comments | « third_party/WebKit/Source/core/fetch/FontResource.h ('k') | third_party/WebKit/Source/core/fetch/ImageResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698