Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/browser/policy/device_status_collector.h

Issue 8702009: Add device status reports to policy requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Mattias' comments and added unit test. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 reports the status of an enterprised-managed ChromeOS device.
Mattias Nissler (ping if slow) 2011/11/30 12:44:29 doesn't actually do the reporting.
Patrick Dubroy 2011/12/06 14:30:36 Done.
24 class DeviceStatusCollector {
25 public:
26 explicit DeviceStatusCollector(PrefService* local_state);
27
28 void GetStatus(enterprise_management::DeviceStatusReportRequest* request);
29
30 static void RegisterPrefs(PrefService* local_state);
31
32 // Returns the max number active periods timestamps to be stored in the
33 // local state. Virtual for testing purposes.
34 virtual unsigned int max_stored_active_periods() const;
Mattias Nissler (ping if slow) 2011/11/30 12:44:29 would a local variable and a setter that tests can
Patrick Dubroy 2011/12/06 14:30:36 Good idea -- done.
35
36 // How often, in seconds, to poll to see if the user is idle.
37 static const unsigned int kPollIntervalSeconds = 30;
38
39 protected:
40 // Check whether the user has been idle for a certain period of time.
41 virtual void CheckIdleState();
42
43 // Used instead of Time::Now(), to make testing possible.
44 virtual Time GetCurrentTime();
45
46 // Callback which receives the results of the idle state check.
47 void IdleStateCallback(IdleState state);
48
49 private:
50 void AddActivePeriod(base::Time start, base::Time end);
51
52 // Since ListValue does not support int64 members, timestamps for active
53 // periods are stored as integer offsets from a reference time, which is
54 // a time_t value representing seconds since Jan 1, 1970 UTC.
55 // These methods convert to and from the offset representation.
56 bool ToInternalTime(const base::Time& time, int& out_val);
57 Time FromInternalTime(int offset);
58
59 // How often to poll to see if the user is idle.
60 int poll_interval_seconds_;
61
62 PrefService* local_state_;
63
64 // The last time an idle state check was performed.
65 Time last_idle_check_;
66
67 // The idle state the last time it was checked.
68 IdleState last_idle_state_;
69
70 base::RepeatingTimer<DeviceStatusCollector> timer_;
71
72 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector);
73 };
74
75 } // namespace policy
76
77 #endif // CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698