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. 4 5#include "chrome/browser/idle.h" 6 7#include "base/bind.h" 8 9namespace { 10 11void CalculateIdleStateCallback(int idle_threshold, 12 IdleCallback notify, 13 int idle_time) { 14 if (idle_time >= idle_threshold) 15 notify.Run(IDLE_STATE_IDLE); 16 else 17 notify.Run(IDLE_STATE_ACTIVE); 18} 19 20} // namespace 21 22void CalculateIdleState(int idle_threshold, IdleCallback notify) { 23 if (CheckIdleStateIsLocked()) { 24 notify.Run(IDLE_STATE_LOCKED); 25 return; 26 } 27 28 CalculateIdleTime(base::Bind(&CalculateIdleStateCallback, 29 idle_threshold, 30 notify)); 31} 32