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_REPORTER_H_ |
| 6 #define CHROME_BROWSER_POLICY_DEVICE_STATUS_REPORTER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/time.h" |
| 10 #include "chrome/browser/idle.h" |
| 11 |
| 12 namespace enterprise_management { |
| 13 class DeviceStatusReportRequest; |
| 14 } |
| 15 |
| 16 class PrefService; |
| 17 |
| 18 namespace policy { |
| 19 |
| 20 // Collects and reports the status of an enterprised-managed ChromeOS device. |
| 21 class DeviceStatusReporter { |
| 22 public: |
| 23 explicit DeviceStatusReporter(PrefService* local_state); |
| 24 |
| 25 void GetStatus(enterprise_management::DeviceStatusReportRequest* request); |
| 26 |
| 27 protected: |
| 28 // Check whether the user has been idle for a certain period of time. |
| 29 void CheckIdleState(); |
| 30 |
| 31 // Callback which receives the results of the idle state check. |
| 32 void IdleStateCallback(IdleState state); |
| 33 |
| 34 private: |
| 35 void AddActivePeriod(base::Time start, base::Time end); |
| 36 |
| 37 // Since ListValue does not support int64 members, timestamps for active |
| 38 // periods are stored as integer offsets from a reference time, which is |
| 39 // a time_t value representing seconds since Jan 1, 1970 UTC. |
| 40 // These methods convert to and from the offset representation. |
| 41 int ToInternalTime(const base::Time& time); |
| 42 base::Time FromInternalTime(int offset); |
| 43 |
| 44 // How often to poll to see if the user is idle. |
| 45 int poll_interval_seconds_; |
| 46 |
| 47 PrefService* local_state_; |
| 48 |
| 49 // The last time an idle state check was performed. |
| 50 base::Time last_idle_check_; |
| 51 |
| 52 // The idle state the last time it was checked. |
| 53 IdleState last_idle_state_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(DeviceStatusReporter); |
| 56 }; |
| 57 |
| 58 } // namespace policy |
| 59 |
| 60 #endif // CHROME_BROWSER_POLICY_DEVICE_STATUS_REPORTER_H_ |
OLD | NEW |