Commit 20ef07ea authored by Malay Keshav's avatar Malay Keshav Committed by Commit Bot

Add UMA metrics for internal display zoom factor changes

This patch records UMA metrics for any change to the internal display's
zoom factor. It does not record temporary zoom factor changes by
debouncing signals that are within a small interval and only allowing
the last signal to pass through.

Bug: 849894
Change-Id: I2dc7d31e9910855ca4a59834a56d8322641a9f5b
Component: Display Manager, UMA, Zoom
Reviewed-on: https://chromium-review.googlesource.com/1093270Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Malay Keshav <malaykeshav@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567855}
parent bf1382f3
...@@ -17818,6 +17818,15 @@ uploading your change for review. ...@@ -17818,6 +17818,15 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="DisplayManager.InternalDisplayZoomPercentage" units="%">
<owner>malaykeshav@chromium.org</owner>
<summary>
The zoom percentage that the user has set on the internal display and is
actively using. This is emitted when the zoom factor has been updated in
display manager and has not been changed for a while.
</summary>
</histogram>
<histogram name="DisplayManager.MirroringDisplayCountRanges" <histogram name="DisplayManager.MirroringDisplayCountRanges"
enum="MultiDisplayModeDisplayCountRanges"> enum="MultiDisplayModeDisplayCountRanges">
<owner>weidongg@chromium.org</owner> <owner>weidongg@chromium.org</owner>
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "base/sys_info.h" #include "base/sys_info.h"
#include "base/time/time.h"
#include "chromeos/system/devicemode.h" #include "chromeos/system/devicemode.h"
#include "ui/display/manager/display_util.h" #include "ui/display/manager/display_util.h"
#endif #endif
...@@ -64,6 +65,17 @@ const char kMirrorModeTypesHistogram[] = "DisplayManager.MirrorModeTypes"; ...@@ -64,6 +65,17 @@ const char kMirrorModeTypesHistogram[] = "DisplayManager.MirrorModeTypes";
const char kMirroringDisplayCountRangesHistogram[] = const char kMirroringDisplayCountRangesHistogram[] =
"DisplayManager.MirroringDisplayCountRanges"; "DisplayManager.MirroringDisplayCountRanges";
#if defined(OS_CHROMEOS)
// The UMA historgram that logs the zoom percentage level of the intenral
// display.
constexpr char kInternalDisplayZoomPercentageHistogram[] =
"DisplayManager.InternalDisplayZoomPercentage";
// Timeout in seconds after which we consider the change to the display zoom
// is not temporary.
constexpr int kDisplayZoomModifyTimeoutSec = 15;
#endif // defined(OS_CHROMEOS)
struct DisplaySortFunctor { struct DisplaySortFunctor {
bool operator()(const Display& a, const Display& b) { bool operator()(const Display& a, const Display& b) {
return CompareDisplayIds(a.id(), b.id()); return CompareDisplayIds(a.id(), b.id());
...@@ -305,6 +317,19 @@ enum class MirrorModeTypes { ...@@ -305,6 +317,19 @@ enum class MirrorModeTypes {
kCount, kCount,
}; };
#if defined(OS_CHROMEOS)
void OnInternalDisplayZoomChanged(float zoom_factor) {
constexpr static int kMaxValue = 300;
constexpr static int kBucketSize = 5;
constexpr static int kNumBuckets = kMaxValue / kBucketSize + 1;
base::LinearHistogram::FactoryGet(
kInternalDisplayZoomPercentageHistogram, kBucketSize, kMaxValue,
kNumBuckets, base::HistogramBase::kUmaTargetedHistogramFlag)
->Add(std::round(zoom_factor * 100));
}
#endif // defined(OS_CHROMEOS)
} // namespace } // namespace
DisplayManager::BeginEndNotifier::BeginEndNotifier( DisplayManager::BeginEndNotifier::BeginEndNotifier(
...@@ -343,6 +368,7 @@ DisplayManager::~DisplayManager() { ...@@ -343,6 +368,7 @@ DisplayManager::~DisplayManager() {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Reset the font params. // Reset the font params.
gfx::SetFontRenderParamsDeviceScaleFactor(1.0f); gfx::SetFontRenderParamsDeviceScaleFactor(1.0f);
on_display_zoom_modify_timeout_.Cancel();
#endif #endif
} }
...@@ -1516,6 +1542,15 @@ void DisplayManager::UpdateZoomFactor(int64_t display_id, float zoom_factor) { ...@@ -1516,6 +1542,15 @@ void DisplayManager::UpdateZoomFactor(int64_t display_id, float zoom_factor) {
if (iter == display_info_.end()) if (iter == display_info_.end())
return; return;
if (Display::IsInternalDisplayId(display_id)) {
on_display_zoom_modify_timeout_.Cancel();
on_display_zoom_modify_timeout_.Reset(
base::BindRepeating(&OnInternalDisplayZoomChanged, zoom_factor));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, on_display_zoom_modify_timeout_.callback(),
base::TimeDelta::FromSeconds(kDisplayZoomModifyTimeoutSec));
}
iter->second.set_zoom_factor(zoom_factor); iter->second.set_zoom_factor(zoom_factor);
for (const auto& display : active_display_list_) { for (const auto& display : active_display_list_) {
...@@ -1658,8 +1693,9 @@ bool DisplayManager::ZoomDisplay(int64_t display_id, bool up) { ...@@ -1658,8 +1693,9 @@ bool DisplayManager::ZoomDisplay(int64_t display_id, bool up) {
if (next_zoom_idx < 0 || next_zoom_idx >= zooms.size()) if (next_zoom_idx < 0 || next_zoom_idx >= zooms.size())
return false; return false;
iter->second.set_zoom_factor(zooms[next_zoom_idx]); // Update zoom factor via the display manager API to ensure UMA metrics are
UpdateDisplays(); // recorded.
UpdateZoomFactor(display_id, zooms[next_zoom_idx]);
return true; return true;
#else #else
return false; return false;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "ui/display/unified_desktop_utils.h" #include "ui/display/unified_desktop_utils.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "base/cancelable_callback.h"
#include "base/optional.h" #include "base/optional.h"
#include "ui/display/manager/display_configurator.h" #include "ui/display/manager/display_configurator.h"
#include "ui/display/manager/touch_device_manager.h" #include "ui/display/manager/touch_device_manager.h"
...@@ -686,6 +687,13 @@ class DISPLAY_MANAGER_EXPORT DisplayManager ...@@ -686,6 +687,13 @@ class DISPLAY_MANAGER_EXPORT DisplayManager
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
std::unique_ptr<TouchDeviceManager> touch_device_manager_; std::unique_ptr<TouchDeviceManager> touch_device_manager_;
// A cancelable callback to trigger sending UMA metrics when display zoom is
// updated. The reason we need a cancelable callback is because we dont want
// to record UMA metrics for changes to the display zoom that are temporary.
// Temporary changes may include things like the user trying out different
// zoom levels before making the final decision.
base::CancelableCallback<void()> on_display_zoom_modify_timeout_;
#endif #endif
// Whether mirroring across multiple displays is enabled. // Whether mirroring across multiple displays is enabled.
......
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