Commit f932c5fa authored by Olivier Yiptong's avatar Olivier Yiptong Committed by Commit Bot

FontAccess: Enumeration timer for windows

Adds an UMA metric to time font enumeration time on Windows.

Bug: 1043306
Change-Id: I6e8a3e51ee752f3e62388a08fd05b06456e7ccd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392992Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Auto-Submit: Olivier Yiptong <oyiptong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804493}
parent 3475bc3b
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h" #include "base/threading/scoped_blocking_call.h"
#include "base/timer/elapsed_timer.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
#include "ui/gfx/win/direct_write.h" #include "ui/gfx/win/direct_write.h"
...@@ -261,6 +262,9 @@ void FontEnumerationCacheWin::SchedulePrepareFontEnumerationCache() { ...@@ -261,6 +262,9 @@ void FontEnumerationCacheWin::SchedulePrepareFontEnumerationCache() {
void FontEnumerationCacheWin::PrepareFontEnumerationCache() { void FontEnumerationCacheWin::PrepareFontEnumerationCache() {
DCHECK(!enumeration_cache_built_.IsSet()); DCHECK(!enumeration_cache_built_.IsSet());
DCHECK(!enumeration_timer_);
enumeration_timer_ = std::make_unique<base::ElapsedTimer>();
font_enumeration_table_ = std::make_unique<blink::FontEnumerationTable>(); font_enumeration_table_ = std::make_unique<blink::FontEnumerationTable>();
...@@ -317,6 +321,7 @@ void FontEnumerationCacheWin::AppendFontDataAndFinalizeIfNeeded( ...@@ -317,6 +321,7 @@ void FontEnumerationCacheWin::AppendFontDataAndFinalizeIfNeeded(
void FontEnumerationCacheWin::FinalizeEnumerationCache() { void FontEnumerationCacheWin::FinalizeEnumerationCache() {
DCHECK(!enumeration_cache_built_.IsSet()); DCHECK(!enumeration_cache_built_.IsSet());
DCHECK(enumeration_timer_);
if (enumeration_errors_.size() > 0) { if (enumeration_errors_.size() > 0) {
auto most_frequent_hresult = std::max_element( auto most_frequent_hresult = std::max_element(
...@@ -347,6 +352,10 @@ void FontEnumerationCacheWin::FinalizeEnumerationCache() { ...@@ -347,6 +352,10 @@ void FontEnumerationCacheWin::FinalizeEnumerationCache() {
enumeration_cache_built_.Set(); enumeration_cache_built_.Set();
UMA_HISTOGRAM_MEDIUM_TIMES("Fonts.AccessAPI.EnumerationTime",
enumeration_timer_->Elapsed());
enumeration_timer_.reset();
// Respond to pending and future requests. // Respond to pending and future requests.
StartCallbacksTaskQueue(); StartCallbacksTaskQueue();
} }
......
...@@ -21,6 +21,8 @@ using blink::mojom::FontEnumerationStatus; ...@@ -21,6 +21,8 @@ using blink::mojom::FontEnumerationStatus;
namespace base { namespace base {
template <typename T> template <typename T>
class NoDestructor; class NoDestructor;
class ElapsedTimer;
} }
namespace content { namespace content {
...@@ -68,6 +70,7 @@ class CONTENT_EXPORT FontEnumerationCacheWin : public FontEnumerationCache { ...@@ -68,6 +70,7 @@ class CONTENT_EXPORT FontEnumerationCacheWin : public FontEnumerationCache {
uint32_t outstanding_family_results_ = 0; uint32_t outstanding_family_results_ = 0;
std::map<HRESULT, unsigned> enumeration_errors_; std::map<HRESULT, unsigned> enumeration_errors_;
std::unique_ptr<base::ElapsedTimer> enumeration_timer_;
DISALLOW_COPY_AND_ASSIGN(FontEnumerationCacheWin); DISALLOW_COPY_AND_ASSIGN(FontEnumerationCacheWin);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment