| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/RemoteFontFaceSource.h" | 5 #include "core/css/RemoteFontFaceSource.h" |
| 6 | 6 |
| 7 #include "core/css/CSSCustomFontData.h" | 7 #include "core/css/CSSCustomFontData.h" |
| 8 #include "core/css/CSSFontFace.h" | 8 #include "core/css/CSSFontFace.h" |
| 9 #include "core/css/FontLoader.h" | 9 #include "core/css/FontLoader.h" |
| 10 #include "core/page/NetworkStateNotifier.h" | 10 #include "core/page/NetworkStateNotifier.h" |
| 11 #include "platform/RuntimeEnabledFeatures.h" | 11 #include "platform/RuntimeEnabledFeatures.h" |
| 12 #include "platform/fonts/FontCache.h" | 12 #include "platform/fonts/FontCache.h" |
| 13 #include "platform/fonts/FontDescription.h" | 13 #include "platform/fonts/FontDescription.h" |
| 14 #include "platform/fonts/SimpleFontData.h" | 14 #include "platform/fonts/SimpleFontData.h" |
| 15 #include "public/platform/Platform.h" | 15 #include "public/platform/Platform.h" |
| 16 #include "wtf/CurrentTime.h" | 16 #include "wtf/CurrentTime.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, PassRefPtrWillBeR
awPtr<FontLoader> fontLoader, FontDisplay display) | 20 RemoteFontFaceSource::RemoteFontFaceSource(PassRefPtrWillBeRawPtr<FontResource>
font, PassRefPtrWillBeRawPtr<FontLoader> fontLoader, FontDisplay display) |
| 21 : m_font(font) | 21 : m_font(font) |
| 22 , m_fontLoader(fontLoader) | 22 , m_fontLoader(fontLoader) |
| 23 , m_display(display) | 23 , m_display(display) |
| 24 , m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod) | 24 , m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod) |
| 25 , m_isInterventionTriggered(false) | 25 , m_isInterventionTriggered(false) |
| 26 { | 26 { |
| 27 #if ENABLE(OILPAN) | 27 #if ENABLE(OILPAN) |
| 28 ThreadState::current()->registerPreFinalizer(this); | 28 ThreadState::current()->registerPreFinalizer(this); |
| 29 #endif | 29 #endif |
| 30 m_font->addClient(this); | 30 m_font->addClient(this); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 42 RemoteFontFaceSource::~RemoteFontFaceSource() | 42 RemoteFontFaceSource::~RemoteFontFaceSource() |
| 43 { | 43 { |
| 44 #if !ENABLE(OILPAN) | 44 #if !ENABLE(OILPAN) |
| 45 dispose(); | 45 dispose(); |
| 46 #endif | 46 #endif |
| 47 } | 47 } |
| 48 | 48 |
| 49 void RemoteFontFaceSource::dispose() | 49 void RemoteFontFaceSource::dispose() |
| 50 { | 50 { |
| 51 m_font->removeClient(this); | 51 m_font->removeClient(this); |
| 52 m_font = nullptr; |
| 52 pruneTable(); | 53 pruneTable(); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void RemoteFontFaceSource::pruneTable() | 56 void RemoteFontFaceSource::pruneTable() |
| 56 { | 57 { |
| 57 if (m_fontDataTable.isEmpty()) | 58 if (m_fontDataTable.isEmpty()) |
| 58 return; | 59 return; |
| 59 | 60 |
| 60 for (const auto& item : m_fontDataTable) { | 61 for (const auto& item : m_fontDataTable) { |
| 61 SimpleFontData* fontData = item.value.get(); | 62 SimpleFontData* fontData = item.value.get(); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 { | 180 { |
| 180 if (m_font->stillNeedsLoad()) | 181 if (m_font->stillNeedsLoad()) |
| 181 m_fontLoader->addFontToBeginLoading(m_font.get()); | 182 m_fontLoader->addFontToBeginLoading(m_font.get()); |
| 182 | 183 |
| 183 if (m_face) | 184 if (m_face) |
| 184 m_face->didBeginLoad(); | 185 m_face->didBeginLoad(); |
| 185 } | 186 } |
| 186 | 187 |
| 187 DEFINE_TRACE(RemoteFontFaceSource) | 188 DEFINE_TRACE(RemoteFontFaceSource) |
| 188 { | 189 { |
| 190 visitor->trace(m_font); |
| 189 visitor->trace(m_fontLoader); | 191 visitor->trace(m_fontLoader); |
| 190 CSSFontFaceSource::trace(visitor); | 192 CSSFontFaceSource::trace(visitor); |
| 191 } | 193 } |
| 192 | 194 |
| 193 void RemoteFontFaceSource::FontLoadHistograms::loadStarted() | 195 void RemoteFontFaceSource::FontLoadHistograms::loadStarted() |
| 194 { | 196 { |
| 195 if (!m_loadStartTime) | 197 if (!m_loadStartTime) |
| 196 m_loadStartTime = currentTimeMS(); | 198 m_loadStartTime = currentTimeMS(); |
| 197 } | 199 } |
| 198 | 200 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 int interventionResult = 0; | 269 int interventionResult = 0; |
| 268 if (m_isLongLimitExceeded) | 270 if (m_isLongLimitExceeded) |
| 269 interventionResult |= 1 << 0; | 271 interventionResult |= 1 << 0; |
| 270 if (triggered) | 272 if (triggered) |
| 271 interventionResult |= 1 << 1; | 273 interventionResult |= 1 << 1; |
| 272 const int boundary = 1 << 2; | 274 const int boundary = 1 << 2; |
| 273 Platform::current()->histogramEnumeration("WebFont.InterventionResult", inte
rventionResult, boundary); | 275 Platform::current()->histogramEnumeration("WebFont.InterventionResult", inte
rventionResult, boundary); |
| 274 } | 276 } |
| 275 | 277 |
| 276 } // namespace blink | 278 } // namespace blink |
| OLD | NEW |