diff options
author | rkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 13:32:12 +0000 |
---|---|---|
committer | rkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 13:32:12 +0000 |
commit | 97156b7e600a7be478f20c764873577a1cb27d58 (patch) | |
tree | e6913da9e372d7fbc041341be72dc69de20e75ba /chrome/browser/idle_win.cc | |
parent | 00bbb93dbd23c1b21ff9cb1df9eb3bc2f91ed1a0 (diff) | |
download | chromium_src-97156b7e600a7be478f20c764873577a1cb27d58.zip chromium_src-97156b7e600a7be478f20c764873577a1cb27d58.tar.gz chromium_src-97156b7e600a7be478f20c764873577a1cb27d58.tar.bz2 |
Chrome changes to fix the idle extension API
This change list reimplements the idle extension API to fix the following issues:
. Query is now throttled only to 1 second
. Calls to calculate the idle time are async (this is needed for chromium-os)
. OnStateChanged now fires within a reasonable time of the machine going active (1 second)
. Fixed a memory leak of the polling class
This is just the Chrome change, there will be an additional CL to integrate the ChromiumOS code changes with the API once those are in.
BUG=chromium-os:17167
TEST=Tested with the idle sample extension to confirm that idle query and idle state changed event work correctly.
Review URL: http://codereview.chromium.org/7519008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97302 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/idle_win.cc')
-rw-r--r-- | chrome/browser/idle_win.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/chrome/browser/idle_win.cc b/chrome/browser/idle_win.cc index ed45da2..c745ca9 100644 --- a/chrome/browser/idle_win.cc +++ b/chrome/browser/idle_win.cc @@ -10,9 +10,11 @@ static bool IsScreensaverRunning(); static bool IsWorkstationLocked(); -IdleState CalculateIdleState(unsigned int idle_threshold) { - if (IsScreensaverRunning() || IsWorkstationLocked()) - return IDLE_STATE_LOCKED; +void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { + if (IsScreensaverRunning() || IsWorkstationLocked()) { + notify.Run(IDLE_STATE_LOCKED); + return; + } LASTINPUTINFO last_input_info = {0}; last_input_info.cbSize = sizeof(LASTINPUTINFO); @@ -36,8 +38,9 @@ IdleState CalculateIdleState(unsigned int idle_threshold) { } if (current_idle_time >= idle_threshold) - return IDLE_STATE_IDLE; - return IDLE_STATE_ACTIVE; + notify.Run(IDLE_STATE_IDLE); + else + notify.Run(IDLE_STATE_ACTIVE); } bool IsScreensaverRunning() { |