| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
| 6 #define CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 6 #define CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/timer.h" | 10 #include "base/timer.h" |
| 11 #include "chrome/browser/chromeos/version_loader.h" |
| 11 #include "chrome/browser/idle.h" | 12 #include "chrome/browser/idle.h" |
| 12 | 13 |
| 13 using base::Time; | |
| 14 | |
| 15 namespace enterprise_management { | 14 namespace enterprise_management { |
| 16 class DeviceStatusReportRequest; | 15 class DeviceStatusReportRequest; |
| 17 } | 16 } |
| 18 | 17 |
| 19 class PrefService; | 18 class PrefService; |
| 20 | 19 |
| 21 namespace policy { | 20 namespace policy { |
| 22 | 21 |
| 23 // Collects and summarizes the status of an enterprised-managed ChromeOS device. | 22 // Collects and summarizes the status of an enterprised-managed ChromeOS device. |
| 24 class DeviceStatusCollector { | 23 class DeviceStatusCollector { |
| 25 public: | 24 public: |
| 26 explicit DeviceStatusCollector(PrefService* local_state); | 25 explicit DeviceStatusCollector(PrefService* local_state); |
| 27 virtual ~DeviceStatusCollector(); | 26 virtual ~DeviceStatusCollector(); |
| 28 | 27 |
| 29 void GetStatus(enterprise_management::DeviceStatusReportRequest* request); | 28 void GetStatus(enterprise_management::DeviceStatusReportRequest* request); |
| 30 | 29 |
| 31 static void RegisterPrefs(PrefService* local_state); | 30 static void RegisterPrefs(PrefService* local_state); |
| 32 | 31 |
| 33 // How often, in seconds, to poll to see if the user is idle. | 32 // How often, in seconds, to poll to see if the user is idle. |
| 34 static const unsigned int kPollIntervalSeconds = 30; | 33 static const unsigned int kPollIntervalSeconds = 30; |
| 35 | 34 |
| 36 protected: | 35 protected: |
| 37 // Check whether the user has been idle for a certain period of time. | 36 // Check whether the user has been idle for a certain period of time. |
| 38 virtual void CheckIdleState(); | 37 virtual void CheckIdleState(); |
| 39 | 38 |
| 40 // Used instead of Time::Now(), to make testing possible. | 39 // Used instead of base::Time::Now(), to make testing possible. |
| 41 virtual Time GetCurrentTime(); | 40 virtual base::Time GetCurrentTime(); |
| 42 | 41 |
| 43 // Callback which receives the results of the idle state check. | 42 // Callback which receives the results of the idle state check. |
| 44 void IdleStateCallback(IdleState state); | 43 void IdleStateCallback(IdleState state); |
| 45 | 44 |
| 46 // The maximum number of active periods timestamps to be stored. | 45 // The maximum number of active periods timestamps to be stored. |
| 47 unsigned int max_stored_active_periods_; | 46 unsigned int max_stored_active_periods_; |
| 48 | 47 |
| 49 private: | 48 private: |
| 50 void AddActivePeriod(base::Time start, base::Time end); | 49 void AddActivePeriod(base::Time start, base::Time end); |
| 51 | 50 |
| 51 // Callbacks from chromeos::VersionLoader. |
| 52 void OnOSVersion(chromeos::VersionLoader::Handle handle, |
| 53 std::string version); |
| 54 void OnOSFirmware(chromeos::VersionLoader::Handle handle, |
| 55 std::string version); |
| 56 |
| 52 // How often to poll to see if the user is idle. | 57 // How often to poll to see if the user is idle. |
| 53 int poll_interval_seconds_; | 58 int poll_interval_seconds_; |
| 54 | 59 |
| 55 PrefService* local_state_; | 60 PrefService* local_state_; |
| 56 | 61 |
| 57 // The last time an idle state check was performed. | 62 // The last time an idle state check was performed. |
| 58 Time last_idle_check_; | 63 base::Time last_idle_check_; |
| 59 | 64 |
| 60 // The idle state the last time it was checked. | 65 // The idle state the last time it was checked. |
| 61 IdleState last_idle_state_; | 66 IdleState last_idle_state_; |
| 62 | 67 |
| 63 base::RepeatingTimer<DeviceStatusCollector> timer_; | 68 base::RepeatingTimer<DeviceStatusCollector> timer_; |
| 64 | 69 |
| 70 chromeos::VersionLoader version_loader_; |
| 71 CancelableRequestConsumer consumer_; |
| 72 |
| 73 std::string os_version_; |
| 74 std::string firmware_version_; |
| 75 |
| 65 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); | 76 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); |
| 66 }; | 77 }; |
| 67 | 78 |
| 68 } // namespace policy | 79 } // namespace policy |
| 69 | 80 |
| 70 #endif // CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 81 #endif // CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
| OLD | NEW |