Commit 8f05f8dd authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Add Night Light UMA Histograms

Add two histograms to track in which range the color temperature is
mostly selected, and the type of the schedule.

BUG=740759

Change-Id: I978a02bcfe84bf770a3db93a0727e90b91ec36fd
Reviewed-on: https://chromium-review.googlesource.com/569002
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486603}
parent e6f299c5
...@@ -19,6 +19,8 @@ struct SimpleGeoposition { ...@@ -19,6 +19,8 @@ struct SimpleGeoposition {
// Used by a client (e.g. Chrome) to provide the current user's geoposition. // Used by a client (e.g. Chrome) to provide the current user's geoposition.
interface NightLightController { interface NightLightController {
// These values are written to logs. New enum values can be added, but
// existing enums must never be renumbered or deleted and reused.
enum ScheduleType { enum ScheduleType {
// Automatic toggling of NightLight is turned off. // Automatic toggling of NightLight is turned off.
kNone = 0, kNone = 0,
...@@ -30,6 +32,9 @@ interface NightLightController { ...@@ -30,6 +32,9 @@ interface NightLightController {
// Toggled automatically based on the custom set start and end times // Toggled automatically based on the custom set start and end times
// selected by the user from the system settings. // selected by the user from the system settings.
kCustom = 2, kCustom = 2,
// Must be the last item, used for UMA histograms.
kLast = kCustom,
}; };
// Sets the client that will be notified of changes in the Night Light // Sets the client that will be notified of changes in the Night Light
......
...@@ -4,11 +4,14 @@ ...@@ -4,11 +4,14 @@
#include "ash/system/night_light/night_light_controller.h" #include "ash/system/night_light/night_light_controller.h"
#include <cmath>
#include "ash/ash_switches.h" #include "ash/ash_switches.h"
#include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/ash_pref_names.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/metrics/histogram_macros.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -78,6 +81,17 @@ class NightLightControllerDelegateImpl : public NightLightController::Delegate { ...@@ -78,6 +81,17 @@ class NightLightControllerDelegateImpl : public NightLightController::Delegate {
DISALLOW_COPY_AND_ASSIGN(NightLightControllerDelegateImpl); DISALLOW_COPY_AND_ASSIGN(NightLightControllerDelegateImpl);
}; };
// Returns the color temperature range bucket in which |temperature| resides.
// The range buckets are:
// 0 => Range [0 : 20) (least warm).
// 1 => Range [20 : 40).
// 2 => Range [40 : 60).
// 3 => Range [60 : 80).
// 4 => Range [80 : 100) (most warm).
int GetTemperatureRange(float temperature) {
return std::floor(5 * temperature);
}
// Applies the given |layer_temperature| to all the layers of the root windows // Applies the given |layer_temperature| to all the layers of the root windows
// with the given |animation_duration|. // with the given |animation_duration|.
// |layer_temperature| is the ui::Layer floating-point value in the range of // |layer_temperature| is the ui::Layer floating-point value in the range of
...@@ -94,6 +108,10 @@ void ApplyColorTemperatureToLayers(float layer_temperature, ...@@ -94,6 +108,10 @@ void ApplyColorTemperatureToLayers(float layer_temperature,
layer->SetLayerTemperature(layer_temperature); layer->SetLayerTemperature(layer_temperature);
} }
UMA_HISTOGRAM_EXACT_LINEAR(
"Ash.NightLight.Temperature", GetTemperatureRange(layer_temperature),
5 /* number of buckets defined in GetTemperatureRange() */);
} }
} // namespace } // namespace
...@@ -337,6 +355,10 @@ void NightLightController::OnScheduleTypePrefChanged() { ...@@ -337,6 +355,10 @@ void NightLightController::OnScheduleTypePrefChanged() {
DCHECK(active_user_pref_service_); DCHECK(active_user_pref_service_);
NotifyClientWithScheduleChange(); NotifyClientWithScheduleChange();
Refresh(true /* did_schedule_change */); Refresh(true /* did_schedule_change */);
// TODO(https://crbug.com/742517).
UMA_HISTOGRAM_ENUMERATION("Ash.NightLight.ScheduleType", GetScheduleType(),
static_cast<int>(ScheduleType::kLast) + 1);
} }
void NightLightController::OnCustomSchedulePrefsChanged() { void NightLightController::OnCustomSchedulePrefsChanged() {
......
...@@ -1292,6 +1292,24 @@ uploading your change for review. These are checked by presubmit scripts. ...@@ -1292,6 +1292,24 @@ uploading your change for review. These are checked by presubmit scripts.
<int value="5" label="INSUFFICIENT_RESOURCES"/> <int value="5" label="INSUFFICIENT_RESOURCES"/>
</enum> </enum>
<enum name="AshNightLightScheduleType">
<summary>Defines the possible Night Light schedule types</summary>
<int value="0" label="None"/>
<int value="1" label="Sunset to Sunrise"/>
<int value="2" label="Custom Schedule"/>
</enum>
<enum name="AshNightLightTemperatureRanges">
<summary>
Defines the ranges in which the value of the color temperature may reside
</summary>
<int value="0" label="[0 to 20) (coldest)"/>
<int value="1" label="[20 to 40)"/>
<int value="2" label="[40 to 60)"/>
<int value="3" label="[60 to 80)"/>
<int value="4" label="[80 to 100) (warmest)"/>
</enum>
<enum name="AsyncDNSConfigParsePosix"> <enum name="AsyncDNSConfigParsePosix">
<int value="0" label="OK"/> <int value="0" label="OK"/>
<int value="1" label="RES_INIT_FAILED"/> <int value="1" label="RES_INIT_FAILED"/>
...@@ -2254,6 +2254,24 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -2254,6 +2254,24 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Ash.NightLight.ScheduleType" enum="AshNightLightScheduleType">
<owner>afakhry@chromium.org</owner>
<summary>
The selected Night Light schedule type. Emitted when the user changes the
Night Light schedule type from the Display System Settings.
</summary>
</histogram>
<histogram name="Ash.NightLight.Temperature"
enum="AshNightLightTemperatureRanges">
<owner>afakhry@chromium.org</owner>
<summary>
The ranges in which the selected values of the Night Light color temperature
reside. Emitted when the user drags the Night Light color temperature slider
to change its value from the Display System Settings.
</summary>
</histogram>
<histogram name="Ash.NumberOfVisibleWindowsInPrimaryDisplay" units="Windows"> <histogram name="Ash.NumberOfVisibleWindowsInPrimaryDisplay" units="Windows">
<owner>tdanderson@google.com</owner> <owner>tdanderson@google.com</owner>
<owner>bruthig@google.com</owner> <owner>bruthig@google.com</owner>
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