summaryrefslogtreecommitdiffstats
path: root/chrome/browser/idle_linux.cc
diff options
context:
space:
mode:
authorrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-18 13:32:12 +0000
committerrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-18 13:32:12 +0000
commit97156b7e600a7be478f20c764873577a1cb27d58 (patch)
treee6913da9e372d7fbc041341be72dc69de20e75ba /chrome/browser/idle_linux.cc
parent00bbb93dbd23c1b21ff9cb1df9eb3bc2f91ed1a0 (diff)
downloadchromium_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_linux.cc')
-rw-r--r--chrome/browser/idle_linux.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/chrome/browser/idle_linux.cc b/chrome/browser/idle_linux.cc
index 2689808..eba7958 100644
--- a/chrome/browser/idle_linux.cc
+++ b/chrome/browser/idle_linux.cc
@@ -63,18 +63,21 @@ bool ScreensaverWindowExists() {
}
-IdleState CalculateIdleState(unsigned int idle_threshold) {
+void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
// Usually the screensaver is used to lock the screen, so we do not need to
// check if the workstation is locked.
gdk_error_trap_push();
bool result = ScreensaverWindowExists();
bool got_error = gdk_error_trap_pop();
- if (result && !got_error)
- return IDLE_STATE_LOCKED;
+ if (result && !got_error) {
+ notify.Run(IDLE_STATE_LOCKED);
+ return;
+ }
browser::IdleQueryLinux idle_query;
unsigned int idle_time = idle_query.IdleTime();
if (idle_time >= idle_threshold)
- return IDLE_STATE_IDLE;
- return IDLE_STATE_ACTIVE;
+ notify.Run(IDLE_STATE_IDLE);
+ else
+ notify.Run(IDLE_STATE_ACTIVE);
}