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

Side by Side Diff: content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc

Issue 2103293004: Add font failure telemetry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change units in histograms Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 22 matching lines...) Expand all
33 enum DirectWriteLoadFamilyResult { 33 enum DirectWriteLoadFamilyResult {
34 LOAD_FAMILY_SUCCESS_SINGLE_FAMILY = 0, 34 LOAD_FAMILY_SUCCESS_SINGLE_FAMILY = 0,
35 LOAD_FAMILY_SUCCESS_MATCHED_FAMILY = 1, 35 LOAD_FAMILY_SUCCESS_MATCHED_FAMILY = 1,
36 LOAD_FAMILY_ERROR_MULTIPLE_FAMILIES = 2, 36 LOAD_FAMILY_ERROR_MULTIPLE_FAMILIES = 2,
37 LOAD_FAMILY_ERROR_NO_FAMILIES = 3, 37 LOAD_FAMILY_ERROR_NO_FAMILIES = 3,
38 LOAD_FAMILY_ERROR_NO_COLLECTION = 4, 38 LOAD_FAMILY_ERROR_NO_COLLECTION = 4,
39 39
40 LOAD_FAMILY_MAX_VALUE 40 LOAD_FAMILY_MAX_VALUE
41 }; 41 };
42 42
43 // This enum is used to define the buckets for an enumerated UMA histogram.
44 // Hence,
45 // (a) existing enumerated constants should never be deleted or reordered, and
46 // (b) new constants should only be appended at the end of the enumeration.
47 enum FontProxyError {
48 FIND_FAMILY_SEND_FAILED = 0,
49 GET_FAMILY_COUNT_SEND_FAILED = 1,
50 COLLECTION_KEY_INVALID = 2,
51 FAMILY_INDEX_OUT_OF_RANGE = 3,
52 GET_FONT_FILES_SEND_FAILED = 4,
53 MAPPED_FILE_FAILED = 5,
54
55 FONT_PROXY_ERROR_MAX_VALUE
56 };
57
43 const char kFontKeyName[] = "font_key_name"; 58 const char kFontKeyName[] = "font_key_name";
44 59
45 void LogLoadFamilyResult(DirectWriteLoadFamilyResult result) { 60 void LogLoadFamilyResult(DirectWriteLoadFamilyResult result) {
46 UMA_HISTOGRAM_ENUMERATION("DirectWrite.Fonts.Proxy.LoadFamilyResult", result, 61 UMA_HISTOGRAM_ENUMERATION("DirectWrite.Fonts.Proxy.LoadFamilyResult", result,
47 LOAD_FAMILY_MAX_VALUE); 62 LOAD_FAMILY_MAX_VALUE);
48 } 63 }
49 64
65 void LogFamilyCount(uint32_t count) {
66 UMA_HISTOGRAM_COUNTS_1000("DirectWrite.Fonts.Proxy.FamilyCount", count);
67 }
68
69 void LogFontProxyError(FontProxyError error) {
70 UMA_HISTOGRAM_ENUMERATION("DirectWrite.Fonts.Proxy.FontProxyError", error,
71 FONT_PROXY_ERROR_MAX_VALUE);
72 }
73
50 } // namespace 74 } // namespace
51 75
52 DWriteFontCollectionProxy::DWriteFontCollectionProxy() = default; 76 DWriteFontCollectionProxy::DWriteFontCollectionProxy() = default;
53 77
54 DWriteFontCollectionProxy::~DWriteFontCollectionProxy() = default; 78 DWriteFontCollectionProxy::~DWriteFontCollectionProxy() = default;
55 79
56 HRESULT DWriteFontCollectionProxy::FindFamilyName(const WCHAR* family_name, 80 HRESULT DWriteFontCollectionProxy::FindFamilyName(const WCHAR* family_name,
57 UINT32* index, 81 UINT32* index,
58 BOOL* exists) { 82 BOOL* exists) {
59 DCHECK(family_name); 83 DCHECK(family_name);
60 DCHECK(index); 84 DCHECK(index);
61 DCHECK(exists); 85 DCHECK(exists);
62 TRACE_EVENT0("dwrite", "FontProxy::FindFamilyName"); 86 TRACE_EVENT0("dwrite", "FontProxy::FindFamilyName");
63 87
64 uint32_t family_index = 0; 88 uint32_t family_index = 0;
65 base::string16 name(family_name); 89 base::string16 name(family_name);
66 90
67 auto iter = family_names_.find(name); 91 auto iter = family_names_.find(name);
68 if (iter != family_names_.end()) { 92 if (iter != family_names_.end()) {
69 *index = iter->second; 93 *index = iter->second;
70 *exists = iter->second != UINT_MAX; 94 *exists = iter->second != UINT_MAX;
71 return S_OK; 95 return S_OK;
72 } 96 }
73 97
74 if (!GetSender()->Send( 98 if (!GetSender()->Send(
75 new DWriteFontProxyMsg_FindFamily(name, &family_index))) { 99 new DWriteFontProxyMsg_FindFamily(name, &family_index))) {
100 LogFontProxyError(FIND_FAMILY_SEND_FAILED);
76 return E_FAIL; 101 return E_FAIL;
77 } 102 }
78 103
79 if (family_index != UINT32_MAX) { 104 if (family_index != UINT32_MAX) {
80 if (!CreateFamily(family_index)) 105 if (!CreateFamily(family_index))
81 return E_FAIL; 106 return E_FAIL;
82 *exists = TRUE; 107 *exists = TRUE;
83 *index = family_index; 108 *index = family_index;
84 families_[family_index]->SetName(name); 109 families_[family_index]->SetName(name);
85 } else { 110 } else {
(...skipping 24 matching lines...) Expand all
110 135
111 UINT32 DWriteFontCollectionProxy::GetFontFamilyCount() { 136 UINT32 DWriteFontCollectionProxy::GetFontFamilyCount() {
112 if (family_count_ != UINT_MAX) 137 if (family_count_ != UINT_MAX)
113 return family_count_; 138 return family_count_;
114 139
115 TRACE_EVENT0("dwrite", "FontProxy::GetFontFamilyCount"); 140 TRACE_EVENT0("dwrite", "FontProxy::GetFontFamilyCount");
116 141
117 uint32_t family_count = 0; 142 uint32_t family_count = 0;
118 if (!GetSender()->Send( 143 if (!GetSender()->Send(
119 new DWriteFontProxyMsg_GetFamilyCount(&family_count))) { 144 new DWriteFontProxyMsg_GetFamilyCount(&family_count))) {
145 LogFontProxyError(GET_FAMILY_COUNT_SEND_FAILED);
120 return 0; 146 return 0;
121 } 147 }
148
149 LogFamilyCount(family_count);
122 family_count_ = family_count; 150 family_count_ = family_count;
123 return family_count; 151 return family_count;
124 } 152 }
125 153
126 HRESULT DWriteFontCollectionProxy::GetFontFromFontFace( 154 HRESULT DWriteFontCollectionProxy::GetFontFromFontFace(
127 IDWriteFontFace* font_face, 155 IDWriteFontFace* font_face,
128 IDWriteFont** font) { 156 IDWriteFont** font) {
129 DCHECK(font_face); 157 DCHECK(font_face);
130 DCHECK(font); 158 DCHECK(font);
131 159
132 for (const auto& family : families_) { 160 for (const auto& family : families_) {
133 if (family && family->GetFontFromFontFace(font_face, font)) { 161 if (family && family->GetFontFromFontFace(font_face, font)) {
134 return S_OK; 162 return S_OK;
135 } 163 }
136 } 164 }
137 // If the font came from our collection, at least one family should match 165 // If the font came from our collection, at least one family should match
138 DCHECK(false); 166 DCHECK(false);
139 167
140 return E_FAIL; 168 return E_FAIL;
141 } 169 }
142 170
143 HRESULT DWriteFontCollectionProxy::CreateEnumeratorFromKey( 171 HRESULT DWriteFontCollectionProxy::CreateEnumeratorFromKey(
144 IDWriteFactory* factory, 172 IDWriteFactory* factory,
145 const void* collection_key, 173 const void* collection_key,
146 UINT32 collection_key_size, 174 UINT32 collection_key_size,
147 IDWriteFontFileEnumerator** font_file_enumerator) { 175 IDWriteFontFileEnumerator** font_file_enumerator) {
148 if (!collection_key || collection_key_size != sizeof(uint32_t)) { 176 if (!collection_key || collection_key_size != sizeof(uint32_t)) {
177 LogFontProxyError(COLLECTION_KEY_INVALID);
149 return E_INVALIDARG; 178 return E_INVALIDARG;
150 } 179 }
151 180
152 TRACE_EVENT0("dwrite", "FontProxy::LoadingFontFiles"); 181 TRACE_EVENT0("dwrite", "FontProxy::LoadingFontFiles");
153 182
154 const uint32_t* family_index = 183 const uint32_t* family_index =
155 reinterpret_cast<const uint32_t*>(collection_key); 184 reinterpret_cast<const uint32_t*>(collection_key);
156 185
157 if (*family_index >= GetFontFamilyCount()) { 186 if (*family_index >= GetFontFamilyCount()) {
187 LogFontProxyError(FAMILY_INDEX_OUT_OF_RANGE);
158 return E_INVALIDARG; 188 return E_INVALIDARG;
159 } 189 }
160 190
161 // If we already loaded the family we should reuse the existing collection. 191 // If we already loaded the family we should reuse the existing collection.
162 DCHECK(!families_[*family_index]->IsLoaded()); 192 DCHECK(!families_[*family_index]->IsLoaded());
163 193
164 std::vector<base::string16> file_names; 194 std::vector<base::string16> file_names;
165 if (!GetSender()->Send( 195 if (!GetSender()->Send(
166 new DWriteFontProxyMsg_GetFontFiles(*family_index, &file_names))) { 196 new DWriteFontProxyMsg_GetFontFiles(*family_index, &file_names))) {
197 LogFontProxyError(GET_FONT_FILES_SEND_FAILED);
167 return E_FAIL; 198 return E_FAIL;
168 } 199 }
169 200
170 HRESULT hr = mswr::MakeAndInitialize<FontFileEnumerator>( 201 HRESULT hr = mswr::MakeAndInitialize<FontFileEnumerator>(
171 font_file_enumerator, factory, this, &file_names); 202 font_file_enumerator, factory, this, &file_names);
172 203
173 if (!SUCCEEDED(hr)) { 204 if (!SUCCEEDED(hr)) {
174 DCHECK(false); 205 DCHECK(false);
175 return E_FAIL; 206 return E_FAIL;
176 } 207 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 if (fragment_offset + fragment_size > data_.length()) 576 if (fragment_offset + fragment_size > data_.length())
546 return E_FAIL; 577 return E_FAIL;
547 *fragment_start = data_.data() + fragment_offset; 578 *fragment_start = data_.data() + fragment_offset;
548 *fragment_context = nullptr; 579 *fragment_context = nullptr;
549 return S_OK; 580 return S_OK;
550 } 581 }
551 582
552 HRESULT FontFileStream::RuntimeClassInitialize( 583 HRESULT FontFileStream::RuntimeClassInitialize(
553 const base::string16& file_name) { 584 const base::string16& file_name) {
554 data_.Initialize(base::FilePath(file_name)); 585 data_.Initialize(base::FilePath(file_name));
555 if (!data_.IsValid()) 586 if (!data_.IsValid()) {
587 LogFontProxyError(MAPPED_FILE_FAILED);
556 return E_FAIL; 588 return E_FAIL;
589 }
557 return S_OK; 590 return S_OK;
558 } 591 }
559 592
560 } // namespace content 593 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/dwrite_font_proxy_message_filter_win.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698