Chromium Code Reviews| 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..55818d3cecebf6550b5d827d58f5ce4314647640 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 |
|
Mihai Parparita -not on Chrome
2012/09/04 20:23:47
Capitalize CPU here and elsewhere.
Hongbo Min
2012/09/05 05:31:03
Done.
|
| + // cycle is completed periodically with the cpu update information 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 processors. Note that the first element is the total aggregated |
| + // numbers of all logic processors. |
| + bool QueryCpuTimePerProcessor(std::vector<CpuTime>* times); |
| }; |
| } // namespace extensions |