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