| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 enterprise_management::DeviceStatusReportRequest* status) override; | 71 enterprise_management::DeviceStatusReportRequest* status) override; |
| 72 bool GetSessionStatus( | 72 bool GetSessionStatus( |
| 73 enterprise_management::SessionStatusReportRequest* status) override; | 73 enterprise_management::SessionStatusReportRequest* status) override; |
| 74 void OnSubmittedSuccessfully() override; | 74 void OnSubmittedSuccessfully() override; |
| 75 | 75 |
| 76 static void RegisterPrefs(PrefRegistrySimple* registry); | 76 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 77 | 77 |
| 78 // How often, in seconds, to poll to see if the user is idle. | 78 // How often, in seconds, to poll to see if the user is idle. |
| 79 static const unsigned int kIdlePollIntervalSeconds = 30; | 79 static const unsigned int kIdlePollIntervalSeconds = 30; |
| 80 | 80 |
| 81 // The total number of CPU samples cached internally. | 81 // The total number of hardware resource usage samples cached internally. |
| 82 static const unsigned int kMaxCPUSamples = 10; | 82 static const unsigned int kMaxResourceUsageSamples = 10; |
| 83 | 83 |
| 84 protected: | 84 protected: |
| 85 // Check whether the user has been idle for a certain period of time. | 85 // Check whether the user has been idle for a certain period of time. |
| 86 virtual void CheckIdleState(); | 86 virtual void CheckIdleState(); |
| 87 | 87 |
| 88 // Used instead of base::Time::Now(), to make testing possible. | 88 // Used instead of base::Time::Now(), to make testing possible. |
| 89 virtual base::Time GetCurrentTime(); | 89 virtual base::Time GetCurrentTime(); |
| 90 | 90 |
| 91 // Callback which receives the results of the idle state check. | 91 // Callback which receives the results of the idle state check. |
| 92 void IdleStateCallback(ui::IdleState state); | 92 void IdleStateCallback(ui::IdleState state); |
| 93 | 93 |
| 94 // Samples the current CPU usage and updates our cache of samples. | 94 // Samples the current CPU and RAM usage and updates our cache of samples. |
| 95 void SampleCPUUsage(); | 95 void SampleResourceUsage(); |
| 96 | 96 |
| 97 // Returns the percentage of total CPU that each process uses. Virtual so it | 97 // Returns the percentage of total CPU that each process uses. Virtual so it |
| 98 // can be mocked. | 98 // can be mocked. |
| 99 virtual std::vector<double> GetPerProcessCPUUsage(); | 99 virtual std::vector<double> GetPerProcessCPUUsage(); |
| 100 | 100 |
| 101 // The number of days in the past to store device activity. | 101 // The number of days in the past to store device activity. |
| 102 // This is kept in case device status uploads fail for a number of days. | 102 // This is kept in case device status uploads fail for a number of days. |
| 103 unsigned int max_stored_past_activity_days_; | 103 unsigned int max_stored_past_activity_days_; |
| 104 | 104 |
| 105 // The number of days in the future to store device activity. | 105 // The number of days in the future to store device activity. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 base::OneShotTimer<DeviceStatusCollector> geolocation_update_timer_; | 180 base::OneShotTimer<DeviceStatusCollector> geolocation_update_timer_; |
| 181 | 181 |
| 182 std::string os_version_; | 182 std::string os_version_; |
| 183 std::string firmware_version_; | 183 std::string firmware_version_; |
| 184 | 184 |
| 185 content::Geoposition position_; | 185 content::Geoposition position_; |
| 186 | 186 |
| 187 // Cached disk volume information. | 187 // Cached disk volume information. |
| 188 std::vector<enterprise_management::VolumeInfo> volume_info_; | 188 std::vector<enterprise_management::VolumeInfo> volume_info_; |
| 189 | 189 |
| 190 // Cached percentage-of-CPU-used data (contains multiple samples taken | 190 struct ResourceUsage { |
| 191 // Sample of percentage-of-CPU-used across all processes (0-100) |
| 192 int cpu_usage_percent; |
| 193 |
| 194 // Amount of free RAM (measures raw memory used by processes, not internal |
| 195 // memory waiting to be reclaimed by GC). |
| 196 int64 bytes_of_ram_free; |
| 197 }; |
| 198 |
| 199 // Samples of resource usage (contains multiple samples taken |
| 191 // periodically every kHardwareStatusSampleIntervalSeconds). | 200 // periodically every kHardwareStatusSampleIntervalSeconds). |
| 192 std::deque<int> cpu_usage_percent_; | 201 std::deque<ResourceUsage> resource_usage_; |
| 193 | 202 |
| 194 // Callback invoked to fetch information about the mounted disk volumes. | 203 // Callback invoked to fetch information about the mounted disk volumes. |
| 195 VolumeInfoFetcher volume_info_fetcher_; | 204 VolumeInfoFetcher volume_info_fetcher_; |
| 196 | 205 |
| 197 chromeos::system::StatisticsProvider* statistics_provider_; | 206 chromeos::system::StatisticsProvider* statistics_provider_; |
| 198 | 207 |
| 199 chromeos::CrosSettings* cros_settings_; | 208 chromeos::CrosSettings* cros_settings_; |
| 200 | 209 |
| 201 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper | 210 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper |
| 202 // way to mock geolocation exists. | 211 // way to mock geolocation exists. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 230 hardware_status_subscription_; | 239 hardware_status_subscription_; |
| 231 | 240 |
| 232 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; | 241 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; |
| 233 | 242 |
| 234 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); | 243 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); |
| 235 }; | 244 }; |
| 236 | 245 |
| 237 } // namespace policy | 246 } // namespace policy |
| 238 | 247 |
| 239 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 248 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
| OLD | NEW |