Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2932)

Unified Diff: chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h

Issue 10914060: Refine systemInfo.cpu API defintions and provide systemInfo.cpu.get impl for Windows and Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/win/windows_version.cc ('k') | chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h
diff --git a/chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h b/chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h
index 5a714dbfe360f0e9f91443ba7fbac43acd0bd22a..d163e4990f83220b75d95d1eb6b2123be08c1a69 100644
--- a/chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h
+++ b/chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h
@@ -5,6 +5,9 @@
#define CHROME_BROWSER_EXTENSIONS_API_SYSTEM_INFO_CPU_CPU_INFO_PROVIDER_H_
#include "chrome/browser/extensions/system_info_provider.h"
+
+#include <vector>
+
#include "chrome/common/extensions/api/experimental_system_info_cpu.h"
namespace extensions {
@@ -12,10 +15,39 @@ namespace extensions {
class CpuInfoProvider
: public SystemInfoProvider<api::experimental_system_info_cpu::CpuInfo> {
public:
+ typedef base::Callback<api::experimental_system_info_cpu::CpuUpdateInfo>
+ QueryCpuTimeCallback;
virtual ~CpuInfoProvider() {}
+ // Overriden from SystemInfoProvider<CpuInfo>.
+ virtual bool QueryInfo(
+ api::experimental_system_info_cpu::CpuInfo* info) OVERRIDE;
+
+ // Start sampling the CPU usage. The callback gets called when one sampling
+ // cycle is completed periodically with the CPU updated usage info for each
+ // processors. Return true if it succeeds to start, otherwise, false is
+ // returned.
+ bool StartSampling(const QueryCpuTimeCallback& callback);
+
+ // Stop the sampling cycle. Return true if it succeeds to stop.
+ bool StopSampling();
+
// Return the single shared instance of CpuInfoProvider.
static CpuInfoProvider* Get();
+
+ private:
+ // The amount of time that CPU spent on performing different kinds of work.
+ // It is used to calculate the usage percent for processors.
+ struct CpuTime {
+ int64 user; // user mode.
+ int64 kernel; // kernel mode.
+ int64 idle; // twiddling thumbs.
+ };
+
+ // Platform specific implementation for querying the CPU time information
+ // for each processor. Note that the first element is the total aggregated
+ // numbers of all logic processors.
+ bool QueryCpuTimePerProcessor(std::vector<CpuTime>* times);
};
} // namespace extensions
« no previous file with comments | « base/win/windows_version.cc ('k') | chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698