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 <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/callback_list.h" | 14 #include "base/callback_list.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/task/cancelable_task_tracker.h" | 19 #include "base/task/cancelable_task_tracker.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
23 #include "chromeos/system/version_loader.h" | 23 #include "chromeos/system/version_loader.h" |
24 #include "components/policy/core/common/cloud/cloud_policy_client.h" | |
25 #include "content/public/browser/geolocation_provider.h" | 24 #include "content/public/browser/geolocation_provider.h" |
26 #include "content/public/common/geoposition.h" | 25 #include "content/public/common/geoposition.h" |
27 #include "policy/proto/device_management_backend.pb.h" | 26 #include "policy/proto/device_management_backend.pb.h" |
28 #include "ui/base/idle/idle.h" | 27 #include "ui/base/idle/idle.h" |
29 | 28 |
30 namespace chromeos { | 29 namespace chromeos { |
31 class CrosSettings; | 30 class CrosSettings; |
32 namespace system { | 31 namespace system { |
33 class StatisticsProvider; | 32 class StatisticsProvider; |
34 } | 33 } |
35 } | 34 } |
36 | 35 |
37 namespace content { | 36 namespace content { |
38 class NotificationDetails; | 37 class NotificationDetails; |
39 class NotificationSource; | 38 class NotificationSource; |
40 } | 39 } |
41 | 40 |
42 class PrefRegistrySimple; | 41 class PrefRegistrySimple; |
43 class PrefService; | 42 class PrefService; |
44 | 43 |
45 namespace policy { | 44 namespace policy { |
46 | 45 |
47 // Collects and summarizes the status of an enterprised-managed ChromeOS device. | 46 // Collects and summarizes the status of an enterprised-managed ChromeOS device. |
48 class DeviceStatusCollector : public CloudPolicyClient::StatusProvider { | 47 class DeviceStatusCollector { |
49 public: | 48 public: |
50 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper | 49 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper |
51 // way to mock geolocation exists. | 50 // way to mock geolocation exists. |
52 typedef base::Callback<void( | 51 typedef base::Callback<void( |
53 const content::GeolocationProvider::LocationUpdateCallback& callback)> | 52 const content::GeolocationProvider::LocationUpdateCallback& callback)> |
54 LocationUpdateRequester; | 53 LocationUpdateRequester; |
55 | 54 |
56 using VolumeInfoFetcher = base::Callback< | 55 using VolumeInfoFetcher = base::Callback< |
57 std::vector<enterprise_management::VolumeInfo>( | 56 std::vector<enterprise_management::VolumeInfo>( |
58 const std::vector<std::string>& mount_points)>; | 57 const std::vector<std::string>& mount_points)>; |
59 | 58 |
60 // Constructor. Callers can inject their own VolumeInfoFetcher, or if a null | 59 // Constructor. Callers can inject their own VolumeInfoFetcher, or if a null |
61 // callback is passed, the default implementation will be used. | 60 // callback is passed, the default implementation will be used. |
62 DeviceStatusCollector( | 61 DeviceStatusCollector( |
63 PrefService* local_state, | 62 PrefService* local_state, |
64 chromeos::system::StatisticsProvider* provider, | 63 chromeos::system::StatisticsProvider* provider, |
65 const LocationUpdateRequester& location_update_requester, | 64 const LocationUpdateRequester& location_update_requester, |
66 const VolumeInfoFetcher& volume_info_fetcher); | 65 const VolumeInfoFetcher& volume_info_fetcher); |
67 ~DeviceStatusCollector() override; | 66 virtual ~DeviceStatusCollector(); |
68 | 67 |
69 // CloudPolicyClient::StatusProvider: | 68 // Fills in the passed proto with device status information. Will return |
70 bool GetDeviceStatus( | 69 // false if no status information is filled in (because status reporting |
71 enterprise_management::DeviceStatusReportRequest* status) override; | 70 // is disabled). |
72 bool GetSessionStatus( | 71 virtual bool GetDeviceStatus( |
73 enterprise_management::SessionStatusReportRequest* status) override; | 72 enterprise_management::DeviceStatusReportRequest* status); |
74 void OnSubmittedSuccessfully() override; | 73 |
74 // Fills in the passed proto with session status information. Will return | |
75 // false if no status information is filled in (because status reporting | |
76 // is disabled, or because there is no active kiosk session). | |
77 virtual bool GetSessionStatus( | |
78 enterprise_management::SessionStatusReportRequest* status); | |
Mattias Nissler (ping if slow)
2015/01/23 13:46:34
I don't think we're using this at all, remove?
Andrew T Wilson (Slow)
2015/01/23 19:16:18
We are using this. DeviceStatusCollector currently
Mattias Nissler (ping if slow)
2015/01/26 10:37:01
So the idea was that SessionStatusReportRequest wo
Andrew T Wilson (Slow)
2015/01/28 13:19:11
Per our discussion with Jin & Bin, I'm going to co
| |
79 | |
80 // Called after the status information has successfully been submitted to | |
81 // the server. | |
82 void OnSubmittedSuccessfully(); | |
75 | 83 |
76 static void RegisterPrefs(PrefRegistrySimple* registry); | 84 static void RegisterPrefs(PrefRegistrySimple* registry); |
77 | 85 |
78 // How often, in seconds, to poll to see if the user is idle. | 86 // How often, in seconds, to poll to see if the user is idle. |
79 static const unsigned int kIdlePollIntervalSeconds = 30; | 87 static const unsigned int kIdlePollIntervalSeconds = 30; |
80 | 88 |
81 // The total number of CPU samples cached internally. | 89 // The total number of CPU samples cached internally. |
82 static const unsigned int kMaxCPUSamples = 10; | 90 static const unsigned int kMaxCPUSamples = 10; |
83 | 91 |
84 protected: | 92 protected: |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 hardware_status_subscription_; | 238 hardware_status_subscription_; |
231 | 239 |
232 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; | 240 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_; |
233 | 241 |
234 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); | 242 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); |
235 }; | 243 }; |
236 | 244 |
237 } // namespace policy | 245 } // namespace policy |
238 | 246 |
239 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 247 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
OLD | NEW |