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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/power/user_activity_notifier.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/power/user_activity_notifier.h"
6
7 #include "ash/shell.h"
8 #include "ash/wm/user_activity_detector.h"
9 #include "chromeos/dbus/dbus_thread_manager.h"
10 #include "chromeos/dbus/power_manager_client.h"
11
12 namespace {
13
14 // Minimum number of seconds between notifications.
15 const int kNotifyIntervalSec = 5;
16
17 } // namespace
18
19 namespace chromeos {
20
21 UserActivityNotifier::UserActivityNotifier() {
22 ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this);
23 }
24
25 UserActivityNotifier::~UserActivityNotifier() {
26 ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this);
27 }
28
29 void UserActivityNotifier::OnUserActivity() {
30 base::TimeTicks now = base::TimeTicks::Now();
31 // InSeconds() truncates rather than rounding, so it's fine for this
32 // comparison.
33 if (last_notify_time_.is_null() ||
34 (now - last_notify_time_).InSeconds() >= kNotifyIntervalSec) {
35 DBusThreadManager::Get()->GetPowerManagerClient()->NotifyUserActivity(now);
36 last_notify_time_ = now;
37 }
38 }
39
40 } // namespace chromeos
OLDNEW
« 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