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