| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 WebURLRequest::FrameTypeNone); | 76 WebURLRequest::FrameTypeNone); |
| 77 request.mutableResourceRequest().setRequestContext( | 77 request.mutableResourceRequest().setRequestContext( |
| 78 WebURLRequest::RequestContextFont); | 78 WebURLRequest::RequestContextFont); |
| 79 return toFontResource( | 79 return toFontResource( |
| 80 fetcher->requestResource(request, FontResourceFactory())); | 80 fetcher->requestResource(request, FontResourceFactory())); |
| 81 } | 81 } |
| 82 | 82 |
| 83 FontResource::FontResource(const ResourceRequest& resourceRequest, | 83 FontResource::FontResource(const ResourceRequest& resourceRequest, |
| 84 const ResourceLoaderOptions& options) | 84 const ResourceLoaderOptions& options) |
| 85 : Resource(resourceRequest, Font, options), | 85 : Resource(resourceRequest, Font, options), |
| 86 m_loadLimitState(UnderLimit), | 86 m_loadLimitState(LoadNotStarted), |
| 87 m_corsFailed(false), | 87 m_corsFailed(false), |
| 88 m_fontLoadShortLimitTimer(this, | 88 m_fontLoadShortLimitTimer(this, |
| 89 &FontResource::fontLoadShortLimitCallback), | 89 &FontResource::fontLoadShortLimitCallback), |
| 90 m_fontLoadLongLimitTimer(this, &FontResource::fontLoadLongLimitCallback) { | 90 m_fontLoadLongLimitTimer(this, &FontResource::fontLoadLongLimitCallback) { |
| 91 } | 91 } |
| 92 | 92 |
| 93 FontResource::~FontResource() {} | 93 FontResource::~FontResource() {} |
| 94 | 94 |
| 95 void FontResource::didAddClient(ResourceClient* c) { | 95 void FontResource::didAddClient(ResourceClient* c) { |
| 96 DCHECK(FontResourceClient::isExpectedType(c)); | 96 DCHECK(FontResourceClient::isExpectedType(c)); |
| 97 Resource::didAddClient(c); | 97 Resource::didAddClient(c); |
| 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 m_loadLimitState = UnderLimit; | 108 m_loadLimitState = LoadNotStarted; |
| 109 Resource::setRevalidatingRequest(request); | 109 Resource::setRevalidatingRequest(request); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void FontResource::startLoadLimitTimersIfNeeded() { | 112 void FontResource::startLoadLimitTimers() { |
| 113 DCHECK(!stillNeedsLoad()); | 113 DCHECK(isLoading()); |
| 114 if (isLoaded() || m_fontLoadLongLimitTimer.isActive()) | 114 DCHECK_EQ(m_loadLimitState, LoadNotStarted); |
| 115 return; | 115 m_loadLimitState = UnderLimit; |
| 116 DCHECK_EQ(m_loadLimitState, UnderLimit); | |
| 117 m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec, | 116 m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec, |
| 118 BLINK_FROM_HERE); | 117 BLINK_FROM_HERE); |
| 119 m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec, | 118 m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec, |
| 120 BLINK_FROM_HERE); | 119 BLINK_FROM_HERE); |
| 121 } | 120 } |
| 122 | 121 |
| 123 bool FontResource::ensureCustomFontData() { | 122 bool FontResource::ensureCustomFontData() { |
| 124 if (!m_fontData && !errorOccurred() && !isLoading()) { | 123 if (!m_fontData && !errorOccurred() && !isLoading()) { |
| 125 if (data()) | 124 if (data()) |
| 126 m_fontData = FontCustomPlatformData::create(data(), m_otsParsingMessage); | 125 m_fontData = FontCustomPlatformData::create(data(), m_otsParsingMessage); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 169 } |
| 171 | 170 |
| 172 void FontResource::checkNotify() { | 171 void FontResource::checkNotify() { |
| 173 m_fontLoadShortLimitTimer.stop(); | 172 m_fontLoadShortLimitTimer.stop(); |
| 174 m_fontLoadLongLimitTimer.stop(); | 173 m_fontLoadLongLimitTimer.stop(); |
| 175 | 174 |
| 176 Resource::checkNotify(); | 175 Resource::checkNotify(); |
| 177 } | 176 } |
| 178 | 177 |
| 179 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |