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

Unified Diff: chrome/browser/chromeos/power/user_activity_notifier.cc

Issue 10544011: chromeos: Notify power manager about user activity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RootWindowEventFilter -> EnvEventFilter Created 8 years, 6 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 | « chrome/browser/chromeos/power/user_activity_notifier.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/power/user_activity_notifier.cc
diff --git a/chrome/browser/chromeos/power/user_activity_notifier.cc b/chrome/browser/chromeos/power/user_activity_notifier.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7daa77a135569e4323f5784e91dae8144768fd3d
--- /dev/null
+++ b/chrome/browser/chromeos/power/user_activity_notifier.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/power/user_activity_notifier.h"
+
+#include "ash/shell.h"
+#include "ash/wm/user_activity_detector.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/power_manager_client.h"
+
+namespace {
+
+// Minimum number of seconds between notifications.
+const int kNotifyIntervalSec = 5;
+
+} // namespace
+
+namespace chromeos {
+
+UserActivityNotifier::UserActivityNotifier() {
+ ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this);
+}
+
+UserActivityNotifier::~UserActivityNotifier() {
+ ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this);
+}
+
+void UserActivityNotifier::OnUserActivity() {
+ base::TimeTicks now = base::TimeTicks::Now();
+ // InSeconds() truncates rather than rounding, so it's fine for this
+ // comparison.
+ if (last_notify_time_.is_null() ||
+ (now - last_notify_time_).InSeconds() >= kNotifyIntervalSec) {
+ DBusThreadManager::Get()->GetPowerManagerClient()->NotifyUserActivity(now);
+ last_notify_time_ = now;
+ }
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/power/user_activity_notifier.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698