Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / idle / idle.cc
blob67432e075f159b7abefaf524a99f45a07a143d10
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
3 // found in the LICENSE file.
5 #include "ui/base/idle/idle.h"
7 #include "base/bind.h"
9 namespace ui {
10 namespace {
12 void CalculateIdleStateCallback(int idle_threshold,
13 IdleCallback notify,
14 int idle_time) {
15 if (idle_time >= idle_threshold)
16 notify.Run(IDLE_STATE_IDLE);
17 else
18 notify.Run(IDLE_STATE_ACTIVE);
21 } // namespace
23 void CalculateIdleState(int idle_threshold, IdleCallback notify) {
24 if (CheckIdleStateIsLocked()) {
25 notify.Run(IDLE_STATE_LOCKED);
26 return;
29 CalculateIdleTime(base::Bind(&CalculateIdleStateCallback,
30 idle_threshold,
31 notify));
34 } // namespace ui