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

Unified Diff: ui/display/win/screen_win.cc

Issue 2151413002: Add a UMA histogram for a user's device scale at startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use vector 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/display/win/screen_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/win/screen_win.cc
diff --git a/ui/display/win/screen_win.cc b/ui/display/win/screen_win.cc
index a4ef468fa5d8a3cf6fd7a0decd940dfb1704fac2..2277ad50f37f101bad4efc26699f3d4d74d578ce 100644
--- a/ui/display/win/screen_win.cc
+++ b/ui/display/win/screen_win.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/metrics/sparse_histogram.h"
#include "base/win/win_util.h"
#include "ui/display/display.h"
#include "ui/display/manager/display_layout.h"
@@ -411,6 +412,7 @@ void ScreenWin::Initialize() {
new gfx::SingletonHwndObserver(
base::Bind(&ScreenWin::OnWndProc, base::Unretained(this))));
UpdateFromDisplayInfos(GetDisplayInfosFromSystem());
+ RecordDisplayScaleFactors();
}
MONITORINFOEX ScreenWin::MonitorInfoFromScreenPoint(
@@ -548,5 +550,22 @@ ScreenWinDisplay ScreenWin::GetScreenWinDisplayVia(Getter getter,
return (g_screen_win_instance->*getter)(value);
}
+void ScreenWin::RecordDisplayScaleFactors() const {
+ std::vector<int> unique_scale_factors;
+ for (const auto& screen_win_display : screen_win_displays_) {
+ const float scale_factor =
+ screen_win_display.display().device_scale_factor();
+ // Clamp the reported value so that if it's wildly out-of-band we won't send
+ // it to the backend.
robliao 2016/07/20 19:56:59 Comment that we multiply by 100 due to the percent
Bret 2016/07/20 21:03:22 Added comment. Raw DPI is a lot less intuitive I t
+ const int reported_scale = std::min(
+ std::max(base::checked_cast<int>(scale_factor * 100), 0), 1000);
+ if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(),
+ reported_scale) == unique_scale_factors.end()) {
+ unique_scale_factors.push_back(reported_scale);
+ UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale);
+ }
+ }
+}
+
} // namespace win
} // namespace display
« no previous file with comments | « ui/display/win/screen_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698