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

Side by Side Diff: chrome/browser/idle_chromeos.cc

Issue 8566024: chromeos: call GetIdleTime from power manager client (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/idle.h" 5 #include "chrome/browser/idle.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "chrome/browser/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
10 #include "chrome/browser/chromeos/cros/power_library.h" 10 #include "chrome/browser/chromeos/dbus/power_manager_client.h"
11 #if !defined(USE_AURA) 11 #if !defined(USE_AURA)
12 #include "chrome/browser/screensaver_window_finder_gtk.h" 12 #include "chrome/browser/screensaver_window_finder_gtk.h"
13 #endif 13 #endif
14 14
15 void CalculateIdleStateNotifier(unsigned int idle_treshold, 15 void CalculateIdleStateNotifier(unsigned int idle_treshold,
16 IdleCallback notify, 16 IdleCallback notify,
17 int64_t idle_time_s) { 17 int64_t idle_time_s) {
18 if (idle_time_s >= (int64_t)idle_treshold) { 18 if (idle_time_s >= (int64_t)idle_treshold) {
19 notify.Run(IDLE_STATE_IDLE); 19 notify.Run(IDLE_STATE_IDLE);
20 } else if (idle_time_s < 0) { 20 } else if (idle_time_s < 0) {
21 notify.Run(IDLE_STATE_UNKNOWN); 21 notify.Run(IDLE_STATE_UNKNOWN);
22 } else { 22 } else {
23 notify.Run(IDLE_STATE_ACTIVE); 23 notify.Run(IDLE_STATE_ACTIVE);
24 } 24 }
25 } 25 }
26 26
27 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { 27 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
28 if (CheckIdleStateIsLocked()) { 28 if (CheckIdleStateIsLocked()) {
29 notify.Run(IDLE_STATE_LOCKED); 29 notify.Run(IDLE_STATE_LOCKED);
30 return; 30 return;
31 } 31 }
32 chromeos::CalculateIdleTimeCallback* callback = 32 chromeos::CalculateIdleTimeCallback* callback =
33 new base::Callback<void(int64_t)>(base::Bind(&CalculateIdleStateNotifier, 33 new base::Callback<void(int64_t)>(base::Bind(&CalculateIdleStateNotifier,
34 idle_threshold, 34 idle_threshold,
35 notify)); 35 notify));
36 chromeos::CrosLibrary::Get()->GetPowerLibrary()->CalculateIdleTime(callback); 36 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
37 CalculateIdleTime(callback);
satorux1 2011/11/15 00:57:42 It no longer needs to be a new'ed object. Please c
Simon Que 2011/11/15 01:29:38 Done.
37 } 38 }
38 39
39 bool CheckIdleStateIsLocked() { 40 bool CheckIdleStateIsLocked() {
40 // Usually the screensaver is used to lock the screen, so we do not need to 41 // Usually the screensaver is used to lock the screen, so we do not need to
41 // check if the workstation is locked. 42 // check if the workstation is locked.
42 #if defined(USE_AURA) 43 #if defined(USE_AURA)
43 return false; 44 return false;
44 #else 45 #else
45 return ScreensaverWindowFinder::ScreensaverWindowExists(); 46 return ScreensaverWindowFinder::ScreensaverWindowExists();
46 #endif 47 #endif
47 } 48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698