summaryrefslogtreecommitdiffstats
path: root/ash/wm
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-17 05:35:47 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-17 05:35:47 +0000
commit0b1eede37df1ab9ea33125fbf5dfb523b2fa7a8f (patch)
tree00503cceccc91aaafba2262a3f02307c0ca33147 /ash/wm
parent09a10057e09de243a53915d7ebeaad19c2f9e029 (diff)
downloadchromium_src-0b1eede37df1ab9ea33125fbf5dfb523b2fa7a8f.zip
chromium_src-0b1eede37df1ab9ea33125fbf5dfb523b2fa7a8f.tar.gz
chromium_src-0b1eede37df1ab9ea33125fbf5dfb523b2fa7a8f.tar.bz2
chromeos: Report user activity type to power manager.
This makes Chrome's reports of user activity to powerd include an enum describing the event type (currently just "brightness up", "brightness down", and "other"). To facilitate this, it makes UserActivityDetector pass the event that triggered the notification to observers. To facilitate _that_, it reorders UserActivityDetector to run after EventRewriterEventFilter instead of before it. It also updates the cros_system_api dependency to 59a6e103. BUG=254841 Review URL: https://chromiumcodereview.appspot.com/18906003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211957 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm')
-rw-r--r--ash/wm/user_activity_detector.cc14
-rw-r--r--ash/wm/user_activity_detector.h2
-rw-r--r--ash/wm/user_activity_detector_unittest.cc4
-rw-r--r--ash/wm/user_activity_observer.h9
4 files changed, 18 insertions, 11 deletions
diff --git a/ash/wm/user_activity_detector.cc b/ash/wm/user_activity_detector.cc
index db0d1d0..269b9ef 100644
--- a/ash/wm/user_activity_detector.cc
+++ b/ash/wm/user_activity_detector.cc
@@ -41,7 +41,7 @@ void UserActivityDetector::OnDisplayPowerChanging() {
}
void UserActivityDetector::OnKeyEvent(ui::KeyEvent* event) {
- HandleActivity();
+ HandleActivity(event);
}
void UserActivityDetector::OnMouseEvent(ui::MouseEvent* event) {
@@ -51,32 +51,32 @@ void UserActivityDetector::OnMouseEvent(ui::MouseEvent* event) {
GetCurrentTime() < honor_mouse_events_time_)
return;
- HandleActivity();
+ HandleActivity(event);
}
void UserActivityDetector::OnScrollEvent(ui::ScrollEvent* event) {
- HandleActivity();
+ HandleActivity(event);
}
void UserActivityDetector::OnTouchEvent(ui::TouchEvent* event) {
- HandleActivity();
+ HandleActivity(event);
}
void UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) {
- HandleActivity();
+ HandleActivity(event);
}
base::TimeTicks UserActivityDetector::GetCurrentTime() const {
return !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now();
}
-void UserActivityDetector::HandleActivity() {
+void UserActivityDetector::HandleActivity(const ui::Event* event) {
base::TimeTicks now = GetCurrentTime();
last_activity_time_ = now;
if (last_observer_notification_time_.is_null() ||
(now - last_observer_notification_time_).InMillisecondsF() >=
kNotifyIntervalMs) {
- FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity());
+ FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event));
last_observer_notification_time_ = now;
}
}
diff --git a/ash/wm/user_activity_detector.h b/ash/wm/user_activity_detector.h
index 0a4ad48..ca01ec1 100644
--- a/ash/wm/user_activity_detector.h
+++ b/ash/wm/user_activity_detector.h
@@ -54,7 +54,7 @@ class ASH_EXPORT UserActivityDetector : public ui::EventHandler {
// Updates |last_activity_time_|. Additionally notifies observers and
// updates |last_observer_notification_time_| if enough time has passed
// since the last notification.
- void HandleActivity();
+ void HandleActivity(const ui::Event* event);
ObserverList<UserActivityObserver> observers_;
diff --git a/ash/wm/user_activity_detector_unittest.cc b/ash/wm/user_activity_detector_unittest.cc
index 75af6cc..271d764 100644
--- a/ash/wm/user_activity_detector_unittest.cc
+++ b/ash/wm/user_activity_detector_unittest.cc
@@ -39,7 +39,9 @@ class TestUserActivityObserver : public UserActivityObserver {
void reset_stats() { num_invocations_ = 0; }
// UserActivityObserver implementation.
- virtual void OnUserActivity() OVERRIDE { num_invocations_++; }
+ virtual void OnUserActivity(const ui::Event* event) OVERRIDE {
+ num_invocations_++;
+ }
private:
// Number of times that OnUserActivity() has been called.
diff --git a/ash/wm/user_activity_observer.h b/ash/wm/user_activity_observer.h
index 5255ced..a65ebfa 100644
--- a/ash/wm/user_activity_observer.h
+++ b/ash/wm/user_activity_observer.h
@@ -8,6 +8,10 @@
#include "ash/ash_export.h"
#include "base/basictypes.h"
+namespace ui {
+class Event;
+}
+
namespace ash {
// Interface for classes that want to be notified about user activity.
@@ -15,8 +19,9 @@ namespace ash {
class ASH_EXPORT UserActivityObserver {
public:
// Invoked periodically while the user is active (i.e. generating input
- // events).
- virtual void OnUserActivity() = 0;
+ // events). |event| is the event that triggered the notification; it may
+ // be NULL in some cases (e.g. testing or synthetic invocations).
+ virtual void OnUserActivity(const ui::Event* event) = 0;
protected:
UserActivityObserver() {}