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

Unified Diff: ash/rotator/screen_rotation_animator.cc

Issue 2771713004: Adds UMA for screen rotation animation smoothness. (Closed)
Patch Set: Respond to reviewers. Created 3 years, 9 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 | « ash/rotator/screen_rotation_animator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/rotator/screen_rotation_animator.cc
diff --git a/ash/rotator/screen_rotation_animator.cc b/ash/rotator/screen_rotation_animator.cc
index c0dbe2058d6f7a4c33314ed1f07650cde2446195..ef7f54464fb94a9d9dc8f46f9edc9edd18618262 100644
--- a/ash/rotator/screen_rotation_animator.cc
+++ b/ash/rotator/screen_rotation_animator.cc
@@ -14,6 +14,7 @@
#include "ash/shell.h"
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
+#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
@@ -47,6 +48,10 @@ const int kRotationDurationInMs = 250;
const int kCounterClockWiseRotationFactor = 1;
const int kClockWiseRotationFactor = -1;
+// The percentage histogram boundary.
+const int kPercentage_MIN = 1;
+const int kPercentage_MAX = 101;
+
// Aborts the active animations of the layer, and recurses upon its child
// layers.
void AbortAnimations(ui::Layer* layer) {
@@ -177,9 +182,21 @@ struct ScreenRotationAnimator::ScreenRotationRequest {
display::Display::RotationSource source;
};
+class ScreenRotationAnimator::ScreenRotationAnimationMetricsReporter
+ : public ui::AnimationMetricsReporter {
+ void Report(int value) override {
+ base::LinearHistogram::FactoryGet(
+ "Ash.Rotation.AnimationSmoothness", kPercentage_MIN, kPercentage_MAX,
bruthig 2017/03/24 14:25:39 FYI You will need to add an entry to histograms.xm
wutao 2017/03/24 20:24:37 Done.
+ kPercentage_MAX + 1, base::HistogramBase::kUmaTargetedHistogramFlag)
+ ->Add(value);
+ }
+};
+
ScreenRotationAnimator::ScreenRotationAnimator(int64_t display_id)
: display_id_(display_id),
is_rotating_(false),
+ metrics_reporter_(
+ base::MakeUnique<ScreenRotationAnimationMetricsReporter>()),
disable_animation_timers_for_test_(false),
weak_factory_(this) {}
@@ -278,6 +295,7 @@ void ScreenRotationAnimator::AnimateRotation(
// control the animation.
if (disable_animation_timers_for_test_)
bruthig 2017/03/24 14:25:39 Not related to this change but shouldn't we be dis
wutao 2017/03/24 20:24:37 Ideally yes, but it will not affect the test resul
animator->set_disable_timer_for_test(true);
+ animation_sequence->SetAnimationMetricsReporter(metrics_reporter_.get());
animator->StartAnimation(animation_sequence.release());
rotation_request.reset();
« no previous file with comments | « ash/rotator/screen_rotation_animator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698