| 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 <stdint.h> |
| 9 |
| 8 #include <deque> | 10 #include <deque> |
| 9 #include <string> | 11 #include <string> |
| 10 #include <vector> | 12 #include <vector> |
| 11 | 13 |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 14 #include "base/callback_list.h" | 15 #include "base/callback_list.h" |
| 15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 19 #include "base/task/cancelable_task_tracker.h" | 21 #include "base/task/cancelable_task_tracker.h" |
| 20 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 21 #include "base/timer/timer.h" | 23 #include "base/timer/timer.h" |
| 22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 23 #include "chromeos/system/version_loader.h" | 25 #include "chromeos/system/version_loader.h" |
| 24 #include "content/public/browser/geolocation_provider.h" | 26 #include "content/public/browser/geolocation_provider.h" |
| 25 #include "content/public/common/geoposition.h" | 27 #include "content/public/common/geoposition.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 unsigned int max_stored_future_activity_days_; | 143 unsigned int max_stored_future_activity_days_; |
| 142 | 144 |
| 143 private: | 145 private: |
| 144 // Prevents the local store of activity periods from growing too large by | 146 // Prevents the local store of activity periods from growing too large by |
| 145 // removing entries that are outside the reporting window. | 147 // removing entries that are outside the reporting window. |
| 146 void PruneStoredActivityPeriods(base::Time base_time); | 148 void PruneStoredActivityPeriods(base::Time base_time); |
| 147 | 149 |
| 148 // Trims the store activity periods to only retain data within the | 150 // Trims the store activity periods to only retain data within the |
| 149 // [|min_day_key|, |max_day_key|). The record for |min_day_key| will be | 151 // [|min_day_key|, |max_day_key|). The record for |min_day_key| will be |
| 150 // adjusted by subtracting |min_day_trim_duration|. | 152 // adjusted by subtracting |min_day_trim_duration|. |
| 151 void TrimStoredActivityPeriods(int64 min_day_key, | 153 void TrimStoredActivityPeriods(int64_t min_day_key, |
| 152 int min_day_trim_duration, | 154 int min_day_trim_duration, |
| 153 int64 max_day_key); | 155 int64_t max_day_key); |
| 154 | 156 |
| 155 void AddActivePeriod(base::Time start, base::Time end); | 157 void AddActivePeriod(base::Time start, base::Time end); |
| 156 | 158 |
| 157 // Clears the cached hardware status. | 159 // Clears the cached hardware status. |
| 158 void ClearCachedHardwareStatus(); | 160 void ClearCachedHardwareStatus(); |
| 159 | 161 |
| 160 // Callbacks from chromeos::VersionLoader. | 162 // Callbacks from chromeos::VersionLoader. |
| 161 void OnOSVersion(const std::string& version); | 163 void OnOSVersion(const std::string& version); |
| 162 void OnOSFirmware(const std::string& version); | 164 void OnOSFirmware(const std::string& version); |
| 163 | 165 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 204 |
| 203 PrefService* local_state_; | 205 PrefService* local_state_; |
| 204 | 206 |
| 205 // The last time an idle state check was performed. | 207 // The last time an idle state check was performed. |
| 206 base::Time last_idle_check_; | 208 base::Time last_idle_check_; |
| 207 | 209 |
| 208 // The maximum key that went into the last report generated by | 210 // The maximum key that went into the last report generated by |
| 209 // GetDeviceStatus(), and the duration for it. This is used to trim the | 211 // GetDeviceStatus(), and the duration for it. This is used to trim the |
| 210 // stored data in OnSubmittedSuccessfully(). Trimming is delayed so | 212 // stored data in OnSubmittedSuccessfully(). Trimming is delayed so |
| 211 // unsuccessful uploads don't result in dropped data. | 213 // unsuccessful uploads don't result in dropped data. |
| 212 int64 last_reported_day_; | 214 int64_t last_reported_day_; |
| 213 int duration_for_last_reported_day_; | 215 int duration_for_last_reported_day_; |
| 214 | 216 |
| 215 // Whether a geolocation update is currently in progress. | 217 // Whether a geolocation update is currently in progress. |
| 216 bool geolocation_update_in_progress_; | 218 bool geolocation_update_in_progress_; |
| 217 | 219 |
| 218 base::RepeatingTimer idle_poll_timer_; | 220 base::RepeatingTimer idle_poll_timer_; |
| 219 base::RepeatingTimer hardware_status_sampling_timer_; | 221 base::RepeatingTimer hardware_status_sampling_timer_; |
| 220 base::OneShotTimer geolocation_update_timer_; | 222 base::OneShotTimer geolocation_update_timer_; |
| 221 | 223 |
| 222 std::string os_version_; | 224 std::string os_version_; |
| 223 std::string firmware_version_; | 225 std::string firmware_version_; |
| 224 | 226 |
| 225 content::Geoposition position_; | 227 content::Geoposition position_; |
| 226 | 228 |
| 227 // Cached disk volume information. | 229 // Cached disk volume information. |
| 228 std::vector<enterprise_management::VolumeInfo> volume_info_; | 230 std::vector<enterprise_management::VolumeInfo> volume_info_; |
| 229 | 231 |
| 230 // Cached CPU temp information. | 232 // Cached CPU temp information. |
| 231 std::vector<enterprise_management::CPUTempInfo> cpu_temp_info_; | 233 std::vector<enterprise_management::CPUTempInfo> cpu_temp_info_; |
| 232 | 234 |
| 233 struct ResourceUsage { | 235 struct ResourceUsage { |
| 234 // Sample of percentage-of-CPU-used. | 236 // Sample of percentage-of-CPU-used. |
| 235 int cpu_usage_percent; | 237 int cpu_usage_percent; |
| 236 | 238 |
| 237 // Amount of free RAM (measures raw memory used by processes, not internal | 239 // Amount of free RAM (measures raw memory used by processes, not internal |
| 238 // memory waiting to be reclaimed by GC). | 240 // memory waiting to be reclaimed by GC). |
| 239 int64 bytes_of_ram_free; | 241 int64_t bytes_of_ram_free; |
| 240 }; | 242 }; |
| 241 | 243 |
| 242 // Samples of resource usage (contains multiple samples taken | 244 // Samples of resource usage (contains multiple samples taken |
| 243 // periodically every kHardwareStatusSampleIntervalSeconds). | 245 // periodically every kHardwareStatusSampleIntervalSeconds). |
| 244 std::deque<ResourceUsage> resource_usage_; | 246 std::deque<ResourceUsage> resource_usage_; |
| 245 | 247 |
| 246 // Callback invoked to fetch information about the mounted disk volumes. | 248 // Callback invoked to fetch information about the mounted disk volumes. |
| 247 VolumeInfoFetcher volume_info_fetcher_; | 249 VolumeInfoFetcher volume_info_fetcher_; |
| 248 | 250 |
| 249 // Callback invoked to fetch information about cpu usage. | 251 // Callback invoked to fetch information about cpu usage. |
| 250 CPUStatisticsFetcher cpu_statistics_fetcher_; | 252 CPUStatisticsFetcher cpu_statistics_fetcher_; |
| 251 | 253 |
| 252 // Callback invoked to fetch information about cpu temperature. | 254 // Callback invoked to fetch information about cpu temperature. |
| 253 CPUTempFetcher cpu_temp_fetcher_; | 255 CPUTempFetcher cpu_temp_fetcher_; |
| 254 | 256 |
| 255 chromeos::system::StatisticsProvider* statistics_provider_; | 257 chromeos::system::StatisticsProvider* statistics_provider_; |
| 256 | 258 |
| 257 chromeos::CrosSettings* cros_settings_; | 259 chromeos::CrosSettings* cros_settings_; |
| 258 | 260 |
| 259 // The most recent CPU readings. | 261 // The most recent CPU readings. |
| 260 uint64 last_cpu_active_; | 262 uint64_t last_cpu_active_; |
| 261 uint64 last_cpu_idle_; | 263 uint64_t last_cpu_idle_; |
| 262 | 264 |
| 263 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper | 265 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper |
| 264 // way to mock geolocation exists. | 266 // way to mock geolocation exists. |
| 265 LocationUpdateRequester location_update_requester_; | 267 LocationUpdateRequester location_update_requester_; |
| 266 | 268 |
| 267 scoped_ptr<content::GeolocationProvider::Subscription> | 269 scoped_ptr<content::GeolocationProvider::Subscription> |
| 268 geolocation_subscription_; | 270 geolocation_subscription_; |
| 269 | 271 |
| 270 // Cached values of the reporting settings from the device policy. | 272 // Cached values of the reporting settings from the device policy. |
| 271 bool report_version_info_; | 273 bool report_version_info_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 295 session_status_subscription_; | 297 session_status_subscription_; |
| 296 | 298 |
| 297 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; | 299 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; |
| 298 | 300 |
| 299 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); | 301 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); |
| 300 }; | 302 }; |
| 301 | 303 |
| 302 } // namespace policy | 304 } // namespace policy |
| 303 | 305 |
| 304 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 306 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
| OLD | NEW |