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

Side by Side Diff: third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp

Issue 1667843003: Make Resource RefCountedWillBeGarbageCollectedFinalized, attempt #2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + address review comments Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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/Histogram.h" 11 #include "platform/Histogram.h"
12 #include "platform/RuntimeEnabledFeatures.h" 12 #include "platform/RuntimeEnabledFeatures.h"
13 #include "platform/fonts/FontCache.h" 13 #include "platform/fonts/FontCache.h"
14 #include "platform/fonts/FontDescription.h" 14 #include "platform/fonts/FontDescription.h"
15 #include "platform/fonts/SimpleFontData.h" 15 #include "platform/fonts/SimpleFontData.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
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
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 interventionResult |= 1 << 0; 290 interventionResult |= 1 << 0;
289 if (triggered) 291 if (triggered)
290 interventionResult |= 1 << 1; 292 interventionResult |= 1 << 1;
291 const int boundary = 1 << 2; 293 const int boundary = 1 << 2;
292 294
293 DEFINE_STATIC_LOCAL(EnumerationHistogram, interventionHistogram, ("WebFont.I nterventionResult", boundary)); 295 DEFINE_STATIC_LOCAL(EnumerationHistogram, interventionHistogram, ("WebFont.I nterventionResult", boundary));
294 interventionHistogram.count(interventionResult); 296 interventionHistogram.count(interventionResult);
295 } 297 }
296 298
297 } // namespace blink 299 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/RemoteFontFaceSource.h ('k') | third_party/WebKit/Source/core/css/StyleRuleImport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698