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/CSSFontSelector.h" | 9 #include "core/css/CSSFontSelector.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 is_intervention_triggered_(false) { | 74 is_intervention_triggered_(false) { |
75 if (ShouldTriggerWebFontsIntervention()) { | 75 if (ShouldTriggerWebFontsIntervention()) { |
76 is_intervention_triggered_ = true; | 76 is_intervention_triggered_ = true; |
77 period_ = kSwapPeriod; | 77 period_ = kSwapPeriod; |
78 font_selector_->GetDocument()->AddConsoleMessage(ConsoleMessage::Create( | 78 font_selector_->GetDocument()->AddConsoleMessage(ConsoleMessage::Create( |
79 kOtherMessageSource, kInfoMessageLevel, | 79 kOtherMessageSource, kInfoMessageLevel, |
80 "Slow network is detected. Fallback font will be used while loading: " + | 80 "Slow network is detected. Fallback font will be used while loading: " + |
81 font_->Url().ElidedString())); | 81 font_->Url().ElidedString())); |
82 } | 82 } |
83 | 83 |
84 // Note: this may call notifyFinished() and clear m_font. | 84 // Note: this may call notifyFinished() and clear font_. |
85 font_->AddClient(this); | 85 font_->AddClient(this); |
86 } | 86 } |
87 | 87 |
88 RemoteFontFaceSource::~RemoteFontFaceSource() {} | 88 RemoteFontFaceSource::~RemoteFontFaceSource() {} |
89 | 89 |
90 void RemoteFontFaceSource::Dispose() { | 90 void RemoteFontFaceSource::Dispose() { |
91 if (font_) { | 91 if (font_) { |
92 font_->RemoveClient(this); | 92 font_->RemoveClient(this); |
93 font_ = nullptr; | 93 font_ = nullptr; |
94 } | 94 } |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 DEFINE_STATIC_LOCAL(EnumerationHistogram, cors_histogram, | 340 DEFINE_STATIC_LOCAL(EnumerationHistogram, cors_histogram, |
341 ("WebFont.CORSSuccess", kCORSEnumMax)); | 341 ("WebFont.CORSSuccess", kCORSEnumMax)); |
342 cors_histogram.Count(cors_value); | 342 cors_histogram.Count(cors_value); |
343 } | 343 } |
344 } | 344 } |
345 | 345 |
346 void RemoteFontFaceSource::FontLoadHistograms::MaySetDataSource( | 346 void RemoteFontFaceSource::FontLoadHistograms::MaySetDataSource( |
347 DataSource data_source) { | 347 DataSource data_source) { |
348 if (data_source_ != kFromUnknown) | 348 if (data_source_ != kFromUnknown) |
349 return; | 349 return; |
350 // Classify as memory cache hit if |m_loadStartTime| is not set, i.e. | 350 // Classify as memory cache hit if |load_start_time_| is not set, i.e. |
351 // this RemoteFontFaceSource instance didn't trigger FontResource | 351 // this RemoteFontFaceSource instance didn't trigger FontResource |
352 // loading. | 352 // loading. |
353 if (load_start_time_ == 0) | 353 if (load_start_time_ == 0) |
354 data_source_ = kFromMemoryCache; | 354 data_source_ = kFromMemoryCache; |
355 else | 355 else |
356 data_source_ = data_source; | 356 data_source_ = data_source; |
357 } | 357 } |
358 | 358 |
359 void RemoteFontFaceSource::FontLoadHistograms::RecordLoadTimeHistogram( | 359 void RemoteFontFaceSource::FontLoadHistograms::RecordLoadTimeHistogram( |
360 const FontResource* font, | 360 const FontResource* font, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 return kMiss; | 485 return kMiss; |
486 case kFromUnknown: | 486 case kFromUnknown: |
487 // Fall through. | 487 // Fall through. |
488 default: | 488 default: |
489 NOTREACHED(); | 489 NOTREACHED(); |
490 } | 490 } |
491 return kMiss; | 491 return kMiss; |
492 } | 492 } |
493 | 493 |
494 } // namespace blink | 494 } // namespace blink |
OLD | NEW |