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

Side by Side Diff: chrome/browser/chromeos/idle_detector.cc

Issue 165173002: Style fixes for demo mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/idle_detector.h" 5 #include "chrome/browser/chromeos/idle_detector.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/user_activity_detector.h" 8 #include "ash/wm/user_activity_detector.h"
9 #include "base/bind.h" 9 #include "base/location.h"
10 #include "base/logging.h"
11 10
12 namespace chromeos { 11 namespace chromeos {
13 12
14 IdleDetector::IdleDetector(const base::Closure& on_active_callback, 13 IdleDetector::IdleDetector(const base::Closure& on_active_callback,
15 const base::Closure& on_idle_callback) 14 const base::Closure& on_idle_callback)
16 : active_callback_(on_active_callback), idle_callback_(on_idle_callback) {} 15 : active_callback_(on_active_callback), idle_callback_(on_idle_callback) {}
17 16
18 IdleDetector::~IdleDetector() { 17 IdleDetector::~IdleDetector() {
19 if (ash::Shell::HasInstance() && 18 if (ash::Shell::HasInstance() &&
20 ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this)) 19 ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this)) {
21 ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this); 20 ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this);
21 }
22 } 22 }
23 23
24 void IdleDetector::OnUserActivity(const ui::Event* event) { 24 void IdleDetector::OnUserActivity(const ui::Event* event) {
25 if (!active_callback_.is_null()) 25 if (!active_callback_.is_null())
26 active_callback_.Run(); 26 active_callback_.Run();
27 ResetTimer(); 27 ResetTimer();
28 } 28 }
29 29
30 void IdleDetector::Start(const base::TimeDelta& timeout) { 30 void IdleDetector::Start(const base::TimeDelta& timeout) {
31 timeout_ = timeout; 31 timeout_ = timeout;
32 if (!ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this)) 32 if (!ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this))
33 ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this); 33 ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this);
34 ResetTimer(); 34 ResetTimer();
35 } 35 }
36 36
37 void IdleDetector::ResetTimer() { 37 void IdleDetector::ResetTimer() {
38 if (timer_.IsRunning()) { 38 if (timer_.IsRunning())
39 timer_.Reset(); 39 timer_.Reset();
40 } else { 40 else
41 timer_.Start(FROM_HERE, timeout_, idle_callback_); 41 timer_.Start(FROM_HERE, timeout_, idle_callback_);
42 }
43 } 42 }
44 43
45 } // namespace chromeos 44 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698