| OLD | NEW |
| 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/cros/cros_library.h" |
| 10 #include "chrome/browser/chromeos/cros/power_library.h" | 10 #include "chrome/browser/chromeos/cros/power_library.h" |
| 11 | 11 |
| 12 void CalculateIdleStateNotifier(unsigned int idle_treshold, | 12 void CalculateIdleStateNotifier(unsigned int idle_treshold, |
| 13 IdleCallback notify, | 13 IdleCallback notify, |
| 14 int64_t idle_time_s) { | 14 int64_t idle_time_s) { |
| 15 if (idle_time_s >= (int64_t)idle_treshold) { | 15 if (idle_time_s >= (int64_t)idle_treshold) { |
| 16 notify.Run(IDLE_STATE_IDLE); | 16 notify.Run(IDLE_STATE_IDLE); |
| 17 } else if (idle_time_s < 0) { | 17 } else if (idle_time_s < 0) { |
| 18 notify.Run(IDLE_STATE_UNKNOWN); | 18 notify.Run(IDLE_STATE_UNKNOWN); |
| 19 } else { | 19 } else { |
| 20 notify.Run(IDLE_STATE_ACTIVE); | 20 notify.Run(IDLE_STATE_ACTIVE); |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { | 24 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { |
| 25 if (CheckIdleStateIsLocked()) { |
| 26 notify.Run(IDLE_STATE_LOCKED); |
| 27 return; |
| 28 } |
| 25 chromeos::CalculateIdleTimeCallback* callback = | 29 chromeos::CalculateIdleTimeCallback* callback = |
| 26 new base::Callback<void(int64_t)>(base::Bind(&CalculateIdleStateNotifier, | 30 new base::Callback<void(int64_t)>(base::Bind(&CalculateIdleStateNotifier, |
| 27 idle_threshold, | 31 idle_threshold, |
| 28 notify)); | 32 notify)); |
| 29 chromeos::CrosLibrary::Get()->GetPowerLibrary()->CalculateIdleTime(callback); | 33 chromeos::CrosLibrary::Get()->GetPowerLibrary()->CalculateIdleTime(callback); |
| 30 } | 34 } |
| 35 |
| 36 bool CheckIdleStateIsLocked() { |
| 37 // TODO(sidor): Make it work. |
| 38 return false; |
| 39 } |
| OLD | NEW |