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> | 8 #include <stdint.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
16 #include "base/callback_list.h" | 16 #include "base/callback_list.h" |
17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
21 #include "base/task/cancelable_task_tracker.h" | 21 #include "base/task/cancelable_task_tracker.h" |
22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
23 #include "base/timer/timer.h" | 23 #include "base/timer/timer.h" |
24 #include "chrome/browser/chromeos/settings/cros_settings.h" | 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
25 #include "chromeos/system/version_loader.h" | 25 #include "chromeos/system/version_loader.h" |
26 #include "content/public/browser/geolocation_provider.h" | 26 #include "device/geolocation/geolocation_provider.h" |
27 #include "content/public/common/geoposition.h" | 27 #include "device/geolocation/geoposition.h" |
28 #include "policy/proto/device_management_backend.pb.h" | 28 #include "policy/proto/device_management_backend.pb.h" |
29 #include "ui/base/idle/idle.h" | 29 #include "ui/base/idle/idle.h" |
30 | 30 |
31 namespace chromeos { | 31 namespace chromeos { |
32 class CrosSettings; | 32 class CrosSettings; |
33 namespace system { | 33 namespace system { |
34 class StatisticsProvider; | 34 class StatisticsProvider; |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 namespace content { | 38 namespace content { |
39 class NotificationDetails; | 39 class NotificationDetails; |
40 class NotificationSource; | 40 class NotificationSource; |
41 } | 41 } |
42 | 42 |
43 class PrefRegistrySimple; | 43 class PrefRegistrySimple; |
44 class PrefService; | 44 class PrefService; |
45 | 45 |
46 namespace policy { | 46 namespace policy { |
47 | 47 |
48 struct DeviceLocalAccount; | 48 struct DeviceLocalAccount; |
49 | 49 |
50 // Collects and summarizes the status of an enterprised-managed ChromeOS device. | 50 // Collects and summarizes the status of an enterprised-managed ChromeOS device. |
51 class DeviceStatusCollector { | 51 class DeviceStatusCollector { |
52 public: | 52 public: |
53 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper | 53 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper |
54 // way to mock geolocation exists. | 54 // way to mock geolocation exists. |
55 typedef base::Callback<void( | 55 typedef base::Callback<void( |
56 const content::GeolocationProvider::LocationUpdateCallback& callback)> | 56 const device::GeolocationProvider::LocationUpdateCallback& callback)> |
57 LocationUpdateRequester; | 57 LocationUpdateRequester; |
58 | 58 |
59 using VolumeInfoFetcher = base::Callback< | 59 using VolumeInfoFetcher = base::Callback< |
60 std::vector<enterprise_management::VolumeInfo>( | 60 std::vector<enterprise_management::VolumeInfo>( |
61 const std::vector<std::string>& mount_points)>; | 61 const std::vector<std::string>& mount_points)>; |
62 | 62 |
63 // Reads the first CPU line from /proc/stat. Returns an empty string if | 63 // Reads the first CPU line from /proc/stat. Returns an empty string if |
64 // the cpu data could not be read. Broken out into a callback to enable | 64 // the cpu data could not be read. Broken out into a callback to enable |
65 // mocking for tests. | 65 // mocking for tests. |
66 // | 66 // |
67 // The format of this line from /proc/stat is: | 67 // The format of this line from /proc/stat is: |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 bool GetOsUpdateStatus( | 181 bool GetOsUpdateStatus( |
182 enterprise_management::DeviceStatusReportRequest* request); | 182 enterprise_management::DeviceStatusReportRequest* request); |
183 bool GetRunningKioskApp( | 183 bool GetRunningKioskApp( |
184 enterprise_management::DeviceStatusReportRequest* request); | 184 enterprise_management::DeviceStatusReportRequest* request); |
185 | 185 |
186 // Update the cached values of the reporting settings. | 186 // Update the cached values of the reporting settings. |
187 void UpdateReportingSettings(); | 187 void UpdateReportingSettings(); |
188 | 188 |
189 void ScheduleGeolocationUpdateRequest(); | 189 void ScheduleGeolocationUpdateRequest(); |
190 | 190 |
191 // content::GeolocationUpdateCallback implementation. | 191 // device::GeolocationUpdateCallback implementation. |
192 void ReceiveGeolocationUpdate(const content::Geoposition&); | 192 void ReceiveGeolocationUpdate(const device::Geoposition&); |
193 | 193 |
194 // Callback invoked to update our cached disk information. | 194 // Callback invoked to update our cached disk information. |
195 void ReceiveVolumeInfo( | 195 void ReceiveVolumeInfo( |
196 const std::vector<enterprise_management::VolumeInfo>& info); | 196 const std::vector<enterprise_management::VolumeInfo>& info); |
197 | 197 |
198 // Callback invoked to update our cpu usage information. | 198 // Callback invoked to update our cpu usage information. |
199 void ReceiveCPUStatistics(const std::string& statistics); | 199 void ReceiveCPUStatistics(const std::string& statistics); |
200 | 200 |
201 // Callback invoked to update our CPU temp information. | 201 // Callback invoked to update our CPU temp information. |
202 void StoreCPUTempInfo( | 202 void StoreCPUTempInfo( |
(...skipping 18 matching lines...) Expand all Loading... |
221 // Whether a geolocation update is currently in progress. | 221 // Whether a geolocation update is currently in progress. |
222 bool geolocation_update_in_progress_ = false; | 222 bool geolocation_update_in_progress_ = false; |
223 | 223 |
224 base::RepeatingTimer idle_poll_timer_; | 224 base::RepeatingTimer idle_poll_timer_; |
225 base::RepeatingTimer hardware_status_sampling_timer_; | 225 base::RepeatingTimer hardware_status_sampling_timer_; |
226 base::OneShotTimer geolocation_update_timer_; | 226 base::OneShotTimer geolocation_update_timer_; |
227 | 227 |
228 std::string os_version_; | 228 std::string os_version_; |
229 std::string firmware_version_; | 229 std::string firmware_version_; |
230 | 230 |
231 content::Geoposition position_; | 231 device::Geoposition position_; |
232 | 232 |
233 // Cached disk volume information. | 233 // Cached disk volume information. |
234 std::vector<enterprise_management::VolumeInfo> volume_info_; | 234 std::vector<enterprise_management::VolumeInfo> volume_info_; |
235 | 235 |
236 // Cached CPU temp information. | 236 // Cached CPU temp information. |
237 std::vector<enterprise_management::CPUTempInfo> cpu_temp_info_; | 237 std::vector<enterprise_management::CPUTempInfo> cpu_temp_info_; |
238 | 238 |
239 struct ResourceUsage { | 239 struct ResourceUsage { |
240 // Sample of percentage-of-CPU-used. | 240 // Sample of percentage-of-CPU-used. |
241 int cpu_usage_percent; | 241 int cpu_usage_percent; |
(...skipping 21 matching lines...) Expand all Loading... |
263 chromeos::CrosSettings* const cros_settings_; | 263 chromeos::CrosSettings* const cros_settings_; |
264 | 264 |
265 // The most recent CPU readings. | 265 // The most recent CPU readings. |
266 uint64_t last_cpu_active_ = 0; | 266 uint64_t last_cpu_active_ = 0; |
267 uint64_t last_cpu_idle_ = 0; | 267 uint64_t last_cpu_idle_ = 0; |
268 | 268 |
269 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper | 269 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper |
270 // way to mock geolocation exists. | 270 // way to mock geolocation exists. |
271 LocationUpdateRequester location_update_requester_; | 271 LocationUpdateRequester location_update_requester_; |
272 | 272 |
273 std::unique_ptr<content::GeolocationProvider::Subscription> | 273 std::unique_ptr<device::GeolocationProvider::Subscription> |
274 geolocation_subscription_; | 274 geolocation_subscription_; |
275 | 275 |
276 // Cached values of the reporting settings from the device policy. | 276 // Cached values of the reporting settings from the device policy. |
277 bool report_version_info_ = false; | 277 bool report_version_info_ = false; |
278 bool report_activity_times_ = false; | 278 bool report_activity_times_ = false; |
279 bool report_boot_mode_ = false; | 279 bool report_boot_mode_ = false; |
280 bool report_location_ = false; | 280 bool report_location_ = false; |
281 bool report_network_interfaces_ = false; | 281 bool report_network_interfaces_ = false; |
282 bool report_users_ = false; | 282 bool report_users_ = false; |
283 bool report_hardware_status_ = false; | 283 bool report_hardware_status_ = false; |
(...skipping 23 matching lines...) Expand all Loading... |
307 running_kiosk_app_subscription_; | 307 running_kiosk_app_subscription_; |
308 | 308 |
309 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; | 309 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; |
310 | 310 |
311 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); | 311 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); |
312 }; | 312 }; |
313 | 313 |
314 } // namespace policy | 314 } // namespace policy |
315 | 315 |
316 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 316 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
OLD | NEW |