diff options
author | mitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-31 01:26:38 +0000 |
---|---|---|
committer | mitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-31 01:26:38 +0000 |
commit | 1eec7faa1e2f45236e2682bffec8e6d71d3f8a1e (patch) | |
tree | ba92ed304444a07fdc7861a401cb374e4a6ed97a /chrome/browser/extensions/extension_idle_api.h | |
parent | c9c8a03fd76095b4910141b613301226610d500e (diff) | |
download | chromium_src-1eec7faa1e2f45236e2682bffec8e6d71d3f8a1e.zip chromium_src-1eec7faa1e2f45236e2682bffec8e6d71d3f8a1e.tar.gz chromium_src-1eec7faa1e2f45236e2682bffec8e6d71d3f8a1e.tar.bz2 |
Move c/b/e/*idle* to c/b/e/api/idle/
TBR=jhawkins@chromium.org
BUG=101244
Review URL: https://chromiumcodereview.appspot.com/10750016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149108 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_idle_api.h')
-rw-r--r-- | chrome/browser/extensions/extension_idle_api.h | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/chrome/browser/extensions/extension_idle_api.h b/chrome/browser/extensions/extension_idle_api.h deleted file mode 100644 index ef10f12..0000000 --- a/chrome/browser/extensions/extension_idle_api.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_IDLE_API_H_ -#define CHROME_BROWSER_EXTENSIONS_EXTENSION_IDLE_API_H_ - -#include "chrome/browser/idle.h" -#include "chrome/browser/extensions/extension_function.h" - -class Profile; - -// Event router class for events related to the idle API. -class ExtensionIdleEventRouter { - public: - static void OnIdleStateChange(Profile* profile, - IdleState idleState); - private: - DISALLOW_COPY_AND_ASSIGN(ExtensionIdleEventRouter); -}; - -// Implementation of the chrome.idle.queryState API. -class ExtensionIdleQueryStateFunction : public AsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION_NAME("idle.queryState") - - protected: - virtual ~ExtensionIdleQueryStateFunction() {} - - // ExtensionFunction: - virtual bool RunImpl() OVERRIDE; - - private: - void IdleStateCallback(int threshold, IdleState state); -}; - -// Class used for caching answers from CalculateIdleState. -class ExtensionIdleCache { - public: - static IdleState CalculateIdleState(int threshold); - static void UpdateCache(int threshold, IdleState state); - - private: - FRIEND_TEST_ALL_PREFIXES(ExtensionIdleApiTest, CacheTest); - - struct CacheData { - // Latest moment in history after which we are certain that there was some - // activity. If we are querying for a threshold beyond this moment, we know - // the result will be active. - double latest_known_active; - // [idle_interval_start, idle_interval_end] is the latest interval in - // history for which we are certain there was no activity. - double idle_interval_start; - double idle_interval_end; - // Set iff the last recored query result was IDLE_STATE_LOCKED. Equals the - // moment the result was recorded in cache. - double latest_locked; - }; - - // We assume moment is increasing with every call to one of these two methods. - - // Tries to determine the idle state based on results of previous queries. - // |threshold| is time span in seconds from now we consider in calculating - // state. - // |moment| is the moment in time this method was called (should be equal to - // now, except in tests). - // Returns calculated state, or IDLE_STATE_UNKNOWN if the state could not be - // determined. - static IdleState CalculateState(int threshold, double moment); - - // Updates cached data with the latest query result. - // |threshold| is threshold parameter of the query. - // |state| is result of the query. - // |moment| is moment in time this method is called. - static void Update(int threshold, IdleState state, double moment); - - static int get_min_threshold(); - static double get_throttle_interval(); - - static CacheData cached_data; -}; - -#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_IDLE_API_H_ |