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..fa5fac0065c24bbe0931693be6a1c8d23f61daf7 100644 |
--- a/ui/display/win/screen_win.cc |
+++ b/ui/display/win/screen_win.cc |
@@ -8,9 +8,11 @@ |
#include <shellscalingapi.h> |
#include <algorithm> |
+#include <set> |
#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 +413,7 @@ void ScreenWin::Initialize() { |
new gfx::SingletonHwndObserver( |
base::Bind(&ScreenWin::OnWndProc, base::Unretained(this)))); |
UpdateFromDisplayInfos(GetDisplayInfosFromSystem()); |
+ RecordDisplayScaleFactors(); |
} |
MONITORINFOEX ScreenWin::MonitorInfoFromScreenPoint( |
@@ -548,5 +551,21 @@ ScreenWinDisplay ScreenWin::GetScreenWinDisplayVia(Getter getter, |
return (g_screen_win_instance->*getter)(value); |
} |
+void ScreenWin::RecordDisplayScaleFactors() const { |
+ std::set<int> already_reported_scale_factors; |
robliao
2016/07/20 00:58:10
Go with an unordered_set or a vector (n is small e
Bret
2016/07/20 18:59:42
Done.
|
+ 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. |
+ const int reported_scale = std::min( |
+ std::max(base::checked_cast<int>(scale_factor * 100), 0), 1000); |
+ if (!already_reported_scale_factors.count(reported_scale)) { |
+ already_reported_scale_factors.insert(reported_scale); |
+ UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); |
+ } |
+ } |
+} |
+ |
} // namespace win |
} // namespace display |